To have a scrollable element scroll to the bottom by default (CSS only, without JavaScript), use display: flex; flex-direction: column-reverse
. Via StackOverflow.
Tagged: til
History API states persist between reloads
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!
Ruby's Array#inquiry, Rails' truncate with block
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.
CSS media feature: @media (hover|any-hover: hover) {β¦}
, useful for preventing annoying ghost hover states on touch devices. Via Sam Selikoff on Twitter.
rbenv-gem-migrate to migrate gems to a new version
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 AbortError
s Iβve been seeing on iOS.
: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.
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