TIL: Revealing Struct Information

In Elixir when we are printing struct we can hide struct’s details implementing Inspect protocol. For example the DateTime struct is doing that so when we are inspecting it it shows us pretty version instead of the detailed one. iex(1)> now = DateTime.utc_now() ~U[2020-10-06 10:59:58.388743Z] iex(2)> IO.inspect(now) ~U[2020-10-06 10:59:58.388743Z] If we want to reveal all the information that the struct contains we can use structs: false option. iex(5)> IO.inspect(now, structs: false) %{ __struct__: DateTime, calendar: Calendar....

October 6, 2021 · Michał Staśkiewicz

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