Dom Christie

Tagged: til

πŸ“š til

To have a scrollable element scroll to the bottom by default (CSS only, without JavaScript), use display: flex; flex-direction: column-reverse. Via StackOverflow.

πŸ“š til

In Ruby, curly braces can be omitted from hashes not only when the hash is the last argument of a method, but also when it’s the last item in an array: [1, 2, three: :four]. Neat!

πŸ“š til

Run migrations after a deploy to Heroku. In Procfile, add a release command:

web: bin/rails server -p $PORT
release: rails db:migrate

Learnt via Justin Searls’s The Selfish Programmer talk.

πŸ“š til

Didn’t strictly learn this today, but needed to note it down so I remember. scroll-padding applies to scroll containers; scroll-margin applies to scroll items.


Calling load() before play() on a media element is recommended when switching the src. Hopefully this fixes the occasional AbortErrors I’ve been seeing on iOS.

πŸ“š til

:placeholder-shown CSS pseudo selector: could be really useful for conditionally displaying adjacent/sibling depending on whether the input has a value.


Customise how Ruby destructures an object by defining a deconstruct_keys method.

πŸ“š til

Ruby’s Enumerable#tally:

["a", "b", "c", "b"].tally  #=> {"a"=>1, "b"=>2, "c"=>1}

rails runner runs Ruby code (including Ruby files) in a Rails context from the command line:

bin/rails runner lib/code_to_be_run.rb