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