Weeknotes 63
11th September, 2022
“Line up with mathematical precision”
-
Please, I beg you –
s/Github/GitHub/
-
I found a use for ActiveRecord’s
find_in_batches
this week. I started off withfind_each
to run a backfill over thousands of records, but ended up wanting to splay the jobs out so ended up usingfind_in_batches
which will return the records you need and the batch number.Foo.find_in_batches.with_index do |group, batch| puts "Processing group #{batch}" group.each do |foo| # do something with `foo` end end
-
A would hazard a guess that a lot of Heroku customers take advantage of Review Apps, and Review Apps are configured using
app.json
.Somewhat confusingly they don’t respect the plan you specify in your
app.json
. The addons configured default to whatever the free plan is. If you want something other than the default you need to contact Heroku support who can enable that for you. -
If you’re into Elixir, or curious, you should definitely take a look at this Humble Bundle of Elixir Books. I already own quite of few of these books, but even so, it’s still a bargain and you’re also donating to charity, which is nice.
-
We had need to start auditing our
rails console
activity this week. It’s crazy how many companies won’t give you access to a database but are happy to give you unfettered access torails console
. There are a couple of gems from Basecamp that we hope can help:console1984
andaudits1984
. We’ve yet to install them, but they look promising. -
Not more Neovim plugins! Yes, always.
nvim-treesitter-context
is nice. It shows you the context of current class, method, whatever that you’re in as you navigate the file. So, say you have a method that takes up more than the available screen real estate, it will show the first line of the method at the top of the screen so you know which method you’re in as the buffer scrolls.Hat tip to Harry for clueing me in.
-
git commit -m
should be banned. Yeah, I said it. Andgit commit -a
whilst you’re at it. -
I learnt that you can add and commit a file in one go using
git commit path/to/file
– add that to the ban list too. -
Tobias Petry tweeted about a Postgres extension I hadn’t heard of – ltree.
Did you know there are alternative ways of storing trees in a database without a parent_id and many queries to get all ancestors/children or the complex nested set concept?
The extension is available on Heroku in case you were wondering. They have a surprising amount of extensions available.
Pat Shaughnessy has a series of blog posts on ltree which look very in-depth but I’ve only had time to give them a cursory look.
-
The Link Cleaner extension for Raycast has been making my life easier when preparing links for these weeknotes.
-
I was under the mistaken impression that the
arch
utility on macOS was for running programs under different architectures on an Apple Silicon CPU. But, no. It’s slightly more subtle than that:If Rosetta is installed, the system will run x64 binaries automatically, you don’t need arch
arch is only required if you want to force the use of a specific version in an universal binary (containing both x64 and arm code), e.g. to run the x64 version of a binary if it relies on plugins only available in x64.
(From: How am I running x86_64 programs without arch on Apple Silicon?).
-
A colleague set the env var
DISABLE_DATABASE_ENVIRONMENT_CHECK
this week. I’ve never seen it used before so my interest was peaked. Apparently, it disables Rails' built-in environment checking.When you first migrate your database the environment is written to a row in the
ar_internal_metadata
database table. If that value is"production"
and you try and run a destructive action likedb:schema:load
Rails will raise an exception preventing you from destroying your database – nice feature. -
Tiny design detail: nested border radii look really funky if they’re the same. To maintain the same curvature, the outer radius = inner radius + padding.
I see this a lot and it drives me mad.
-
Related, the new iPhone 14 Dynamic Island doesn’t quite line up.
you’ll never be able to unsee this, enjoy your new iPhone folks, I will be in the corner screaming into a pillow
However, this take is wrong imo. Lining things up with mathematical precision is not always what looks best.
-
I finished The Bear this week – loved it! It’s a good job the episodes are short as it’s a pretty intense watch for a show about a sandwich shop.
-
Charles Petzold on The Changes for the 2nd Edition of “Code”.
So it goes. The only consolation is that I’m not the only person in the world forced into using JavaScript. There are literally millions.
This made me laugh.
😅
(Via The Shape of Everything).