Weeknotes 162
4th August, 2024
“Locked out”
-
Implement the bin/rails boot command
This is handy. I had an occasion to use something like this once. We had an issue where the Rails app did not boot in production mode. This is bad. We decided to add a check in CI for it. This would’ve been useful for that.
-
I eventually managed to get my passport application notarized and sent off. This whole process has cost me £452.85 so far 😒
Now we wait.
-
Code comprehension: Chunks and Beacons – I found this interesting.
We talk about making source code readable and it turns out that this isn’t just stylistic interpretation; there is actual research into this topic. As we read through the code, what we’re scanning for are chunks and beacons.
-
ActiveRecordTracer – For posterity, I’m sure to need this one day. I remember using some hacky solution before now, but this looks a lot nicer.
You identified (or suspect) that the reason for the slowness of some code is Active Record, specifically lots of queries and/or loaded records. How do you easily detect which queries, which records are loaded the most, and the sources of those? This tool to the rescue!
-
“GitHub” Is Starting to Feel Like Legacy Software
The problem wasn’t that the line I wanted wasn’t on the page—it’s that the whole document wasn’t being rendered at once, so my browser’s builtin search bar just couldn’t find it. On a hunch, I tried disabling JavaScript entirely in the browser, and suddenly it started working again. GitHub is able to send a fully server-side rendered version of the page, which actually works like it should, but doesn’t do so unless JavaScript is completely unavailable.
I mean, really? It’s not that the page is so big that it can’t be reasonably rendered, it’s that the JavaScript can’t or won’t show the page.
I feel similar to this about Heroku too. There was a time when it innovated on a weekly basis, but now it chugs. Nothing lasts forever.
-
I learnt about the
cmdline-window
this week. I have, like a lot of vim features, only ever accidentally invoked this in the past. But it looks to be very useful.When you run a command like a search and replace (
:%s/foo/bar/
) you can’t edit the command using regular vim features – moving the cursor requires me to use the arrow keys, for example, like a heathen.By chance I came across this Reddit thread on the exact problem, and it turns out that if you issue
CTRL-f
whilst editing a command it opens the command in thecmdline-window
which allows the usual power of Vim to edit commands, and when you’re ready to execute the command you hit<enter>
✅However, I have a config peculiarity which I added some time a go, which already uses
<enter>
to clear any search highlights. The config looks like this:-- Clear search highlights when hitting <enter> vim.keymap.set('n', '<cr>', ':nohlsearch<cr>')
So I asked Claude 3.5 Sonnet how I could use enter to clear search highlights most of the time, but not in the
cmdline-window
and it gave me this:-- Clear search highlighting when hitting <enter> in normal mode, -- but not in the command-line window vim.keymap.set('n', '<cr>', function() if vim.fn.getcmdwintype() == '' then return ':nohlsearch<cr>' else return '<cr>' end end, { expr = true })
I’m not sure if this is the most idiomatic way to do this. But it works and seems reasonable enough.
-
We locked ourselves out of the house this week – it was inevitable. Due to the super speedy arrival of a locksmith, and his skill with a horseshoe shaped piece of aluminium pipe, we were back in without 25 minutes. And it only cost us £65, which I thought was very reasonable.
I don’t feel particularly safe in the house now though given the ease with which he was able to gain entry 😬