Binary search isn't about search III. Loop invariant of rightmost element search

If you followed “Binary search isn’t about search” and “Binary search isn’t about search II” properly, the following statements should suffice as a summary: 1 2 L[0:l] < T < L[r:len(L)] # ordinary binary search loop invariant L[0:l] < T <= L[r:len(L)] # leftwise binary search loop invariant Let’s complete the triptych. Take a wild guess what invariant we use for rightmost element binary search: 1 L[0:l] <= T < L[r:len(L)] # rightwise binary search loop invariant A motivating example Consider again an array like...

March 9, 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

Things you should never do: Use Expect to autotype SSH passwords in scripts

Before I moved to Finland, I spent some time in the Hobbesian war of all against all that is Wisconsin1. Men were men back in that less civilized age, and “cybersecurity” a ninny-word dreamt up by social harmony types who honestly thought they had anything worth stealing in their servers. For those of us doing real work, which I must emphasize you should never do, we had Expect. And to SSH automatically into servers where we didn’t have fancy accoutrements like “keys” or “audit requirements”, we did stuff like...

February 26, 2025

SQLite is learnable

This is a response to pid1.call’s “Siren Call of SQlite on the Server”, which itself is a response to articles like Wesley Aptekar-Cassels’s “Consider SQLite” espousing SQLite as a server-side technology. Cards on the table, I both love SQLite and think pid1 has the more correct take here. When I decided on a dime after college to move countries and be with my wife, part of the package deal was that I had to throw away my dreams of easing into the software industry by resting on the laurels of my strong, but not MIT-level-known-worldwide-strong, alma mater (sorry Wildcats)....

February 18, 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

Common-sense security for SSH on a new Debian server

Last night I went to DigitalOcean and spun up a tiny new, $4/month droplet – on my own dime! It sounds crazy, but I’ve never actually wanted to pay for hosting myself before. But I have a fun little web app cooking up, one that might eventually pay that $4/month back with interests, and I decided, why not, it’s time to finally put some of my own skin in the game with this whole sysadmin thing....

September 24, 2024

Enforce GPL compliance by offering bounties?

Epistemic status: Very unclear, also I Am Not A Lawyer This Is Not Legal Advice Get Off My Lawn (N.B.: I"m using “GPL” with broad strokes here, to point at “open source licenses it’s straightforward to run afoul of”.) Policing is always hard in a world of limited resources. Especially when one is targeting sophisticated, well-monied criminal organizations, it can take an awful lot of time and effort merely to credibly reveal that wrongdoing has taken place....

September 21, 2024

The self-hosted to DevOps engineer pipeline

What’s the best way to get a job? Show someone with a job to do that you can do the job within their iron triangle. What’s the best way you can show someone you can handle a complicated k8s deployment, with 7 different CNCF-approved add-ons, zero-downtime rollouts and a whole bunch of YAML files? Probably by competently and publicly running your own complicated k8s infrastructure. Self-hosters remind me a lot of the sysadmins of yore, who mostly ended up in the profession because they just couldn’t help but mess around with their underlying computing machine until they knew all kinds of weird nooks and crannies within it....

September 18, 2024

PHP, Go, and Braindead Deployment

If you’ve been following my posts recently, you might have noticed that I’ve been working more and more with PHP lately. As someone who was curiously allergic to web dev as a teenager, it has been a strangely healing experience for me. I’d like to say it’s because my experiments with Laravel, the only OSS work of which I can point to is testing the Homestead VM’s compatibility for Shell Bling Ubuntu, convinced me....

September 16, 2024