Reading List

The most recent articles from a list of feeds I subscribe to.

Sqlc: 2024 check in

Quick thoughts on whether sqlc is still the direction for Go projects now that we’ve been using it for three years.

Function calling in large language models

It's hard to pay attention when your context goes out the window.

Supercronching videos for embedding in websites with ffmpeg

TL;DR: I convert it from video to gif to video

Debugging application state triggered by focus

In any modern browser’s element inspector, you can force an element into a :hover or :focus state to debug styling issues. Sometimes, you want to debug an issue of an element in focus with a state controlled by JavaScript. Unfortunately, the forced states from the developer console aren’t always enough. (Edit: unless you use Chrome apparently, scroll to the end for an alternative solution!)

Toggling focus in devtools

I came across this problem when I was styling a custom <select> component in React. The dropdown menu is only visible when the input is focussed, but I couldn’t inspect this state with the devtools. Whenever I wanted to browse the element tree, the devtools became the active element on the page and the menu disappeared.

Luckily, I came across a tiny snippet to help debug in this situation.

window.setTimeout(() => { debugger; }, 5000);

This will wait five seconds until it halts all code execution with a debugger breakpoint. With this snippet, I load the page, set everything up into the state I want to inspect—5 seconds is more than enough time—and wait for the timeout to fire. When the debugger is triggered, I can browse and tinker with the element tree without worrying about the page updating.

In React, I wrapped this in a useEffect call to run once for the component I wanted to debug.

useEffect(() => {
  window.setTimeout(() => { debugger; }, 5000);
}, []);

After I shared this post on Twitter, Bram tweeted that Chrome DevTools have a feature to circumvent this problem. With the “Emulate a focussed page” setting, the web page will remain in a focussed state when you’re playing around in DevTools. Read more in the Chrome DevTool release notes.

The Art of Decision-Making

In a New Yorker article titled The Art of Decision-Making, Joshua Rothman explores the paradox of how we can spend a lot of energy fretting over small decisions, while the big life decisions seem to come naturally.

We agonize over what to stream on Netflix, then let TV shows persuade us to move to New York

An interesting point he makes is how our aspirations can take a long time to come to fruition. How can we guide our actions if we don’t even know if we’ll still want the results by the time we get there?

To aspire […] is to judge one’s present-day self by the standards of a future self who doesn’t yet exist. But that can leave us like a spider plant putting down roots in the air, hoping for soil that may never arrive.

As the life we crave can change dramatically.

Before having children, you may enjoy clubbing, skydiving, and LSD; you might find fulfillment in careerism, travel, cooking, or CrossFit; you may simply relish your freedom to do what you want. Having children will deprive you of these joys. And yet, as a parent, you may not miss them. You may actually prefer changing diapers, wrangling onesies, and watching “Frozen.” These activities may sound like torture to the childless version of yourself, but the parental version may find them illuminated by love, and so redeemed. You may end up becoming a different person—a parent. The problem is that you can’t really know, in advance, what “being a parent” is like.