Save your disk, write files directly into RAM with /dev/shm

Given my interest in extending the life of my SD cards and hard drives as much as possible, I’m surprised I haven’t come across /dev/shm before. In a word it’s a world-accessible RAM scratchpad, which seems baked right into POSIX, so that virtually every ~Unix~ EDIT: Linux system already has it mounted as a tmpfs by default: 1 2 ❯ mount | grep '/dev/shm' tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64) Today’s lucky 10,000, indeed....

June 26, 2025

Create multi-stage Anki card answers with HTML's <details> tag

This works as of, at least, Anki 24.06.3. According to the Mozilla Developer Network, The <details> HTML element creates a disclosure widget in which information is visible only when the widget is toggled into an open state. In standard web browsers, absent any CSS to the contrary, a <details> tag starts closed until further notice. Since Anki is basically a local web browser on top of a timer, this also works there....

June 7, 2025

Binary search isn't about search II. Loop invariant of leftmost element search

In the first “Binary search isn’t about search” post, we spoke about using assert statements to enforce your loop invariants. Our plain old everyday binary search invariant can be summarized as such: For all x in L[0:l]1, x is strictly less than T, the element we are searching for. For all y in L[r:len(L)]2, y is strictly greater than T, the element we are searching for. Or, if we want to be even terser, we could note this as simply...

March 8, 2025

Binary search isn't about search

Suppose you’re trying to track down a bug that appeared in a series of Git commits. You’ve been idly keeping track of where this bug appears in your lucky commits by hand, while busy with other things. So far you’ve compiled this table: 1 2 3 4 5 6 7 8 9 10 0000000 🧼 clean, no bug. 0000001 🧼 0000002 🧼 0000003 🧼 0000004 🧼 0000005 🧼 0000006 🐛 bug first appears here....

March 7, 2025

`python -m http.server` as ephemeral Dropbox

Ever need to download a file from a server – or get someone else to download a file from a server, who may not be comfortable with or should have access to scp or sftp? Turns out, if you have Python installed – and you probably do – it comes with a handy one-liner file server for just such an occasion: 1 python -m http.server 12345 # or whatever port you prefer Then to close the server, just Ctrl+C....

January 21, 2025