TIL: Check Command Origin in Vim

If we want to check from where the command came from we can use :verbose :com COMMAND...

January 27, 2021 · Michał Staśkiewicz

TIL: Length Property on Function Shows Arity

In JavaScript when we show length property on the function we get back the arity(number of arguments) of that function. function importantFunction(first, second) {} importantFunction.length // 2 function complexFunction(first, second, third) {} complexFunction.length // 3 ...

January 7, 2021 · Michał Staśkiewicz

TIL: Setup Nat on Mac

Networking on mac can be tricky, the same applies to NAT. If we want our mac to act as NAT we need: Enable forwarding sudo sysctl -w net.inet.ip.forwarding=1 Create a file with our NAT rules for eg nat_rules with our configuration nat on en0 from en1 to any -> (en0) Start PF via pfctl sudo pfctl -d # stop pfctl sudo pfctl -F all -f ./nat_rules # flush all rules and load new ones sudo pfctl -e # start pfctl ...

December 11, 2020 · Michał Staśkiewicz

TIL: Emulate Vision Deficiencies With Chrome

Chrome has a built-in tool for emulating various vision deficiencies which can be helpful when we are checking the accessibility of the website. To turn on the emulation: Open DevTools Go to the Rendering tab At the bottom of the page we have “Emulate vision deficiencies” dropdown where we can choose from various vision disabilities like blurred vision. ...

December 4, 2020 · Michał Staśkiewicz

TIL: Debugging Git Push(ssh) Hanging

Sometimes when we try to push some changes to the repository git push can hang and we cannot get any meaningful information. We can check the GitHub status page but when everything is green there what can we do to get more information(applies only for ssh) Create script like ~/sshv.sh #!/bin/bash ssh -vvv "$@" Add permissions chmod u+x ~/sshv.sh Push to the repo GIT_SSH=~/sshv.sh git push <rest of your command>...

December 2, 2020 · Michał Staśkiewicz

TIL: Github Shortcut Domains

Github have two shortcut domains repo.new - for creating new repository gist.new - for creating new gist...

July 8, 2020 · Michał Staśkiewicz

TIL: Create Self Signed Certificates for Plug Application

Add x509 hex package to deps: def deps do [ {:x509, "~> 0.8.0"} ] end Generate certificates: $ mix x509.gen.selfsigned Add certificates to you Cowboy setup: Plug.Cowboy, scheme: :https, plug: YourAppPlug, options: [ port: 8443, cipher_suite: :strong, certfile: "priv/cert/selfsigned.pem", keyfile: "priv/cert/selfsigned_key.pem", otp_app: :your_app ] } Links: x509, Plug...

February 17, 2020 · Michał Staśkiewicz

TIL: Yaml Is a Superset of Json

Having that in mind we can use JSON inside of YAML and technically it would work as a correct YAML file. # example.yml { "key": "value" } Would work the same as: # example.yml --- key: value More details: YAML specification...

January 24, 2020 · Michał Staśkiewicz

TIL: Browser Has Built in Design Mode

The browser has a built-in mode where we can easily edit the whole content. It can be useful for prototyping or quick changes during the call. document.designMode = "on"; More information: MDN...

October 28, 2019 · Michał Staśkiewicz

TIL: Anonymous Functions Can Have Multiple Heads

There is no need to use case inside of anonymous function - instead, we can create function with multiple heads. list = [1, 2, 3, {4, 5}, 6, {7, 8}] Enum.each(list, fn {first_value, secon_value} -> IO.puts("Tuple: #{first_value}, #{secon_value}") element -> IO.puts("Simple element: #{element}") end) ...

October 28, 2019 · Michał Staśkiewicz