<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Andras Schmelczer</title><description>Notebook of someone who keeps reaching for the same two moves: let the hard constraint pick the data structure, then keep the API small enough to defend.</description><link>https://schmelczer.dev/</link><language>en-us</language><lastBuildDate>Sat, 06 Jun 2026 14:18:58 GMT</lastBuildDate><atom:link href="https://schmelczer.dev/rss.xml" rel="self" type="application/rss+xml"/><image><url>https://schmelczer.dev/_astro/og-default.qvqli1k1_z6Fjj.jpg</url><title>Andras Schmelczer</title><link>https://schmelczer.dev</link></image><item><title>An Obsidian Sync Built Around the Merger I Already Had</title><link>https://schmelczer.dev/articles/vault-link-obsidian-sync/</link><guid isPermaLink="true">https://schmelczer.dev/articles/vault-link-obsidian-sync/</guid><description>VaultLink: self-hosted Obsidian sync. Edit in any editor, online or off, then come back to a converged vault. The app that justified reconcile-text.</description><pubDate>Sat, 30 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I refuse to give up the editor. Obsidian on the phone, Vim on the laptop, VS Code at work, the occasional headless &lt;code&gt;sed&lt;/code&gt; across the whole vault. None of them know about each other, none of them are going to learn to, and I’m not switching to whichever sync product picks a favourite. VaultLink is the architecture that falls out of that refusal: one Rust server, one TypeScript sync engine, an Obsidian plugin, a CLI, and two test harnesses. The merge primitive underneath it all is &lt;a href=&quot;https://schmelczer.dev/articles/reconcile-text-3-way-merge/&quot;&gt;reconcile-text&lt;/a&gt;, which I wrote first. VaultLink is the question that made it worth writing, finally asked in earnest.&lt;/p&gt;
&lt;h2 id=&quot;the-constraint-that-picks-the-algorithm&quot;&gt;The constraint that picks the algorithm&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-constraint-that-picks-the-algorithm&quot; aria-label=&quot;Permalink to The constraint that picks the algorithm&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The consequence of that refusal is that the server never sees keystrokes. It sees end states: a file as it stood when sync caught it. That kills CRDTs (which need every operation) and OT-as-it’s-usually-implemented (same). It leaves you with one primitive: 3-way merge given a parent, a left, and a right. Which is reconcile-text. Which I’d written exactly because no existing tool took three independently-edited file states and gave one back.&lt;/p&gt;
&lt;p&gt;The other consequence is that the &lt;em&gt;path placement&lt;/em&gt; is its own problem. Two clients might both move the same file. A file might land on a slot another file already occupies. A rename and a content edit might race. That’s the part I underestimated.&lt;/p&gt;
&lt;h2 id=&quot;two-loops-separate-invariants&quot;&gt;Two loops, separate invariants&lt;a class=&quot;heading-anchor&quot; href=&quot;#two-loops-separate-invariants&quot; aria-label=&quot;Permalink to Two loops, separate invariants&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The sync engine is two loops, deliberately disentangled:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Wire loop&lt;/strong&gt; (&lt;code&gt;syncer.ts&lt;/code&gt;). Drains the single-consumer FIFO of pending HTTP and WebSocket ops. Updates a document’s record fields (&lt;code&gt;remoteRelativePath&lt;/code&gt;, &lt;code&gt;parentVersionId&lt;/code&gt;, &lt;code&gt;remoteHash&lt;/code&gt;) and writes content to whatever path the record currently holds. &lt;em&gt;Never moves files for path placement.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Path reconciler&lt;/strong&gt; (&lt;code&gt;reconciler.ts&lt;/code&gt;). Runs after every drained event. Best-effort pass that moves files on disk so &lt;code&gt;localPath === remoteRelativePath&lt;/code&gt;. The move graph is topologically sorted. Records with pending local events are skipped; the reconciler only operates on settled ones. Failures (slot occupied by something untracked) are silent skips; the next pass retries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The split is the load-bearing decision. It used to be one loop with both responsibilities, and the bug catalogue was a parade of slot-collision stashes, “conflict-uuid” hacks, and &lt;code&gt;MoveOnConflict.NEW&lt;/code&gt;/&lt;code&gt;EXISTING&lt;/code&gt; policy choices. Separating wire transport from path placement made most of that vanish: the wire loop can freely write &lt;code&gt;remoteRelativePath&lt;/code&gt; to whatever the server returned, even if it disagrees with the file on disk, because the reconciler won’t move anything out from under a queued user rename.&lt;/p&gt;
&lt;p&gt;Cycles in the move graph (A→B, B→C, C→A) are resolved by reading every file in the cycle into memory and writing each back to its new slot; no tmp files. A write-ahead marker at &lt;code&gt;.vaultlink/swap-&amp;#x3C;uuid&gt;.json&lt;/code&gt; lists each leg. On startup the reconciler reads the marker, hashes each &lt;code&gt;from&lt;/code&gt; to determine which legs ran, and replays the rest. &lt;code&gt;.vaultlink/**&lt;/code&gt; is hardcoded into the internal ignore pattern so the swap markers never themselves get synced.&lt;/p&gt;
&lt;h2 id=&quot;pending-creates-are-promises-not-strings&quot;&gt;Pending creates are Promises, not strings&lt;a class=&quot;heading-anchor&quot; href=&quot;#pending-creates-are-promises-not-strings&quot; aria-label=&quot;Permalink to Pending creates are Promises, not strings&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When the user creates a file locally and &lt;em&gt;then&lt;/em&gt; immediately edits or renames it before the create has been acknowledged, the engine doesn’t know the document’s id yet; the server assigns it. So queued events for that doc carry a &lt;code&gt;Promise&amp;#x3C;DocumentId&gt;&lt;/code&gt; in their &lt;code&gt;documentId&lt;/code&gt; slot, threaded back to the still-in-flight &lt;code&gt;LocalCreate&lt;/code&gt;. When the server acks the create, &lt;code&gt;resolveCreate&lt;/code&gt; fulfils the promise and &lt;code&gt;replacePendingDocumentId&lt;/code&gt; walks the queue swapping the resolved string into every dependent event.&lt;/p&gt;
&lt;p&gt;If you’re walking &lt;code&gt;events[]&lt;/code&gt; and comparing docIds with &lt;code&gt;===&lt;/code&gt;, you’ll silently fail to match until the swap happens. There’s a comment in &lt;code&gt;sync-event-queue.ts&lt;/code&gt; that warns about exactly that, in slightly more alarmed punctuation. The shape is unusual but the alternative (synchronously waiting for the create ack before letting the user type more) is the kind of thing that makes a notes app feel like a 1998 webform.&lt;/p&gt;
&lt;h2 id=&quot;mincovered-the-watermark-that-doesnt-lie&quot;&gt;MinCovered: the watermark that doesn’t lie&lt;a class=&quot;heading-anchor&quot; href=&quot;#mincovered-the-watermark-that-doesnt-lie&quot; aria-label=&quot;Permalink to MinCovered: the watermark that doesn’t lie&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The catch-up handshake says “give me everything newer than &lt;code&gt;lastSeenUpdateId&lt;/code&gt;.” If the client advances that id as it receives a stream of RemoteChange ids out of order, it’ll publish a too-high cursor, and the next reconnect will request from a point past events it never actually applied. Permanent gap. Replay-forever bug, with extra steps.&lt;/p&gt;
&lt;p&gt;The fix is a small data structure called &lt;code&gt;MinCovered&lt;/code&gt;: a contiguous-prefix tracker over a stream of integers. It advances the public min only when the next consecutive id has been processed. Out-of-order arrivals stash without bumping the cursor. Five files of test, one screen of implementation, and an entire category of confusing data-loss bugs disappears.&lt;/p&gt;
&lt;h2 id=&quot;reconcile-text-on-the-server&quot;&gt;reconcile-text on the server&lt;a class=&quot;heading-anchor&quot; href=&quot;#reconcile-text-on-the-server&quot; aria-label=&quot;Permalink to reconcile-text on the server&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The merge sits on the server. When two clients submit edits against the same &lt;code&gt;parent_version_id&lt;/code&gt;, the second submission triggers a 3-way merge against the parent and the freshly-committed first edit. Three strings in, one out. No conflict markers. The engine commits the merged result, increments the version, and broadcasts the new state to every connected client.&lt;/p&gt;
&lt;p&gt;Two restrictions, both honest:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Only &lt;code&gt;.md&lt;/code&gt; and &lt;code&gt;.txt&lt;/code&gt;.&lt;/strong&gt; Markdown that fails UTF-8 validation gets treated as binary, same as PNGs and PDFs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Last-write-wins for everything else.&lt;/strong&gt; Concurrent edits to a &lt;code&gt;.docx&lt;/code&gt; lose one of the writes. The right fix is “don’t edit binaries concurrently,” which is unsatisfying but true.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Merge quality is exactly what reconcile-text gives me. Word-level tokenisation turns most prose conflicts into two adjacent edits that coexist. If the merge looks slightly clumsy now and then, the alternative is a &lt;code&gt;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C; HEAD&lt;/code&gt; block in my notes, and I’d take the clumsy sentence every time.&lt;/p&gt;
&lt;h2 id=&quot;two-test-harnesses-one-workflow&quot;&gt;Two test harnesses, one workflow&lt;a class=&quot;heading-anchor&quot; href=&quot;#two-test-harnesses-one-workflow&quot; aria-label=&quot;Permalink to Two test harnesses, one workflow&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Distributed-sync bugs are confusing the first time and impossible the second. The fix is two harnesses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;test-client&lt;/code&gt; (fuzz).&lt;/strong&gt; N parallel processes hammering random ops against a shared server for minutes at a time. Catches bugs nobody thought to write a test for. Reproductions are noisy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;deterministic-tests&lt;/code&gt;.&lt;/strong&gt; Scripted multi-client scenarios with a step grammar (&lt;code&gt;pause-server&lt;/code&gt;, &lt;code&gt;pause-websocket&lt;/code&gt;, &lt;code&gt;barrier&lt;/code&gt;, &lt;code&gt;assert-consistent&lt;/code&gt;) using an in-memory filesystem against a real server binary. Used to capture a fuzz-found bug as a minimal repro before fixing it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The workflow: fuzz finds something, I sift logs for a root cause, write the minimal deterministic test that fails on it, fix until both that test and the fuzz pass. Without the deterministic harness, every bug fix would be vibes-based.&lt;/p&gt;
&lt;h2 id=&quot;smaller-calls&quot;&gt;Smaller calls&lt;a class=&quot;heading-anchor&quot; href=&quot;#smaller-calls&quot; aria-label=&quot;Permalink to Smaller calls&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;TS types are generated from Rust via &lt;code&gt;ts-rs&lt;/code&gt;.&lt;/strong&gt; The HTTP/WS API has one source of truth: the Serde types in the server. &lt;code&gt;scripts/update-api-types.sh&lt;/code&gt; re-emits &lt;code&gt;frontend/sync-client/src/services/types/&lt;/code&gt;. Hand-edits to those files are explicitly banned.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;sqlx::query!&lt;/code&gt; macros over a checked-in &lt;code&gt;.sqlx&lt;/code&gt; cache.&lt;/strong&gt; SQL is verified against the schema at compile time. Touching SQL means re-running &lt;code&gt;cargo sqlx prepare --workspace&lt;/code&gt;; if you forget, CI catches it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One sync engine, four consumers.&lt;/strong&gt; &lt;code&gt;sync-client&lt;/code&gt; is the engine. Obsidian plugin, standalone CLI, fuzz harness, and deterministic harness all depend on it via &lt;code&gt;file:../sync-client&lt;/code&gt;. Bugs are fixed once and inherited everywhere.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;record.localPath&lt;/code&gt; mutates in place across awaits.&lt;/strong&gt; The watcher can rename a doc while a wire-loop handler is mid-HTTP. Snapshotting &lt;code&gt;localPath&lt;/code&gt; into a local at function entry and reading it after the await reads a vacated slot. Read it live; only snapshot when you deliberately want to compare &lt;em&gt;before&lt;/em&gt; and &lt;em&gt;after&lt;/em&gt; the await.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Watermark advancement is load-bearing both ways.&lt;/strong&gt; Branches that skip a remote event without advancing &lt;code&gt;lastSeenUpdateId&lt;/code&gt; create permanent gaps that re-deliver forever. Branches that advance without applying the content lose data. The rule that survives review is: advance only if you applied the event or deliberately discarded it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-race-i-havent-structurally-fixed&quot;&gt;The race I haven’t structurally fixed&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-race-i-havent-structurally-fixed&quot; aria-label=&quot;Permalink to The race I haven’t structurally fixed&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Pause-or-disable-sync mid-flight is the one left. An HTTP that committed server-side but whose response was dropped leaves the server holding a doc the client never recorded. On resume, the offline scan finds the file again, uploads it as a new create, and server-side dedupe merges the duplicate into the existing doc. If the merge produces a deconflict file (two real divergences), the user picks up an extra file in their vault. Not data loss, but a small ugliness.&lt;/p&gt;
&lt;p&gt;The two-loop split doesn’t fix this and probably shouldn’t. The honest path is something like a persisted client-side “have I acked this op?” log, sitting in the same SQLite the engine already uses. It’s on my list, below several things I want more.&lt;/p&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Move the merge to the client.&lt;/strong&gt; Right now reconcile-text runs on the server. Putting it in the WASM build of reconcile-text on each client, and letting the server be a dumb commit log, would let the merge benefit from device-specific tokenisers (Markdown-aware on the desktop, word-level on mobile). It would also stop the server from needing to understand the file format at all.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Property tests for the move graph.&lt;/strong&gt; The cycle resolver is the part I trust least under crash. Snapshot tests can’t go where proptest can; I should be generating arbitrary move-graph + interruption combinations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A first-class “pause” with a write-ahead op log.&lt;/strong&gt; See above.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More than &lt;code&gt;.md&lt;/code&gt; and &lt;code&gt;.txt&lt;/code&gt;.&lt;/strong&gt; A canvas-aware merge for Obsidian’s &lt;code&gt;.canvas&lt;/code&gt; files is one reconcile-text tokeniser away. Not because anyone asked, but because the asymmetry annoys me.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The way I think about VaultLink now: reconcile-text was the bet. VaultLink is what I built once the bet looked like it might pay off. The interesting part of the bet was always that three independently-edited files can become one without anyone telling the system about the keystrokes that produced them. The interesting part of the application is everything you have to do &lt;em&gt;around&lt;/em&gt; that merge to stop the rest of the system from undoing it.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>web</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>Backing Up Running Databases Without Stopping Them</title><link>https://schmelczer.dev/articles/backup-container-btrfs-borg/</link><guid isPermaLink="true">https://schmelczer.dev/articles/backup-container-btrfs-borg/</guid><description>A Bash container around BorgBackup. BTRFS snapshots give atomic consistency, numeric env vars give multi-target 3-2-1, the loop is sleep not cron.</description><pubDate>Fri, 29 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Once you self-host a few services with live databases, the backup question stops being theoretical. A Postgres or SQLite file half-written when &lt;code&gt;tar&lt;/code&gt; reads it goes into the archive in a state nothing on Earth will replay; you just don’t find out until the restore. Two years in, with multiple incidents I had to actually recover from (including the photos behind the &lt;a href=&quot;https://schmelczer.dev/articles/frame-eink-photo-display/&quot;&gt;e-ink frame&lt;/a&gt;), I trust this stack precisely because the correctness argument is short: BTRFS gives me an atomic snapshot, and everything above it can be a shell script. One Alpine container, ~75 lines of Bash, pushes that snapshot to one or more &lt;a href=&quot;https://borgbackup.readthedocs.io/&quot;&gt;Borg&lt;/a&gt; repositories on a fixed interval. Multi-target is numeric env vars (&lt;code&gt;BORG_REPO_0&lt;/code&gt;, &lt;code&gt;BORG_REPO_1&lt;/code&gt;, …). No config format, no DSL; the env file is the configuration.&lt;/p&gt;
&lt;h2 id=&quot;the-problem-the-snapshot-solves&quot;&gt;The problem the snapshot solves&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-problem-the-snapshot-solves&quot; aria-label=&quot;Permalink to The problem the snapshot solves&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I self-host several databases that are mid-write at every moment of the day. &lt;code&gt;tar | borg create&lt;/code&gt; against the live volume is a race: a Postgres or SQLite file that’s half-written when borg reads it goes into the archive in a state nothing on Earth can replay. The “right” answer is to coordinate a quiesce with every database: a fan-out of &lt;code&gt;pg_dump&lt;/code&gt;, SQLite &lt;code&gt;.backup&lt;/code&gt;, Redis &lt;code&gt;BGSAVE&lt;/code&gt;, and so on, all with retry, timeouts, and per-app credentials.&lt;/p&gt;
&lt;p&gt;The cheaper answer, if you’ve put everything on one BTRFS volume, is &lt;code&gt;btrfs subvolume snapshot&lt;/code&gt;. It returns instantly with a copy-on-write fork of the entire filesystem. Every file is now atomically consistent at exactly the same instant. Run borg against the snapshot, not against the live volume.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;btrfs&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; subvolume&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; snapshot&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; /btrfs-root&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; /snapshot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;cd&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;/snapshot/btrfs-root${&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;BACKUP_RELATIVE_PATH&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;:-&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;}&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;borg&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; create&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; ...&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; ::&quot;{hostname}-{now:%Y-%m-%dT%H:%M:%S}&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The snapshot lives only for the duration of the borg run. A &lt;code&gt;trap cleanup EXIT&lt;/code&gt; deletes the subvolume whether the backup succeeded, failed, or was killed. The next run snapshots fresh.&lt;/p&gt;
&lt;p&gt;This shifts the entire correctness argument from “did I quiesce every database in time” to “does BTRFS give me a consistent snapshot.” It does. That’s why everything below it can be a shell script.&lt;/p&gt;
&lt;h2 id=&quot;multi-target-as-numeric-env-vars&quot;&gt;Multi-target as numeric env vars&lt;a class=&quot;heading-anchor&quot; href=&quot;#multi-target-as-numeric-env-vars&quot; aria-label=&quot;Permalink to Multi-target as numeric env vars&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The 3-2-1 backup rule wants three copies, two media, one offsite. My answer is a remote (rsync.net) and a local HDD, both fed from the same snapshot. The wire format for “multiple targets” is just numbered env vars:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;BORG_PASSPHRASE_0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;BORG_REMOTE_PATH_0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;borg1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;BORG_REPO_0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;username@username.rsync.net:~/backup&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;BORG_PASSPHRASE_1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;BORG_REPO_1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;/local-backup&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;backup-wrapper.sh&lt;/code&gt; loops &lt;code&gt;index=0&lt;/code&gt; upward, exports &lt;code&gt;BORG_PASSPHRASE&lt;/code&gt; / &lt;code&gt;BORG_REPO&lt;/code&gt; / &lt;code&gt;BORG_REMOTE_PATH&lt;/code&gt; from the indexed copies, runs &lt;code&gt;backup.sh&lt;/code&gt;, unsets them, increments. Stops the first time the next index has no passphrase.&lt;/p&gt;
&lt;p&gt;There’s also a no-index fallback (&lt;code&gt;BORG_REPO=...&lt;/code&gt; with no number) for the single-target case. Same script, no extra config plane.&lt;/p&gt;
&lt;p&gt;I keep coming back to this pattern for small-system orchestration. The env file &lt;em&gt;is&lt;/em&gt; the data structure. There’s no YAML parsing, no JSON schema, no config-validation layer between you and the variable that actually matters.&lt;/p&gt;
&lt;h2 id=&quot;the-scheduler-is-a-sleep-not-cron&quot;&gt;The scheduler is a sleep, not cron&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-scheduler-is-a-sleep-not-cron&quot; aria-label=&quot;Permalink to The scheduler is a sleep, not cron&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;    /src/backup-wrapper.sh&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; 2&gt;&amp;#x26;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; log_message&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;    sleep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$SLEEP_TIME&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;done&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A comment in the file says it out loud: “Using a simple sleep loop to schedule backups instead of cron to avoid concurrency issues.” Cron with a one-hour cadence and a backup that occasionally takes 70 minutes will eventually overlap itself. The sleep-loop can’t: the next run starts when the previous one is done, plus the interval. One process, one snapshot, one borg invocation. Concurrency bugs you can’t have are concurrency bugs you don’t have.&lt;/p&gt;
&lt;h2 id=&quot;healthcheck-is-a-file-mtime&quot;&gt;Healthcheck is a file mtime&lt;a class=&quot;heading-anchor&quot; href=&quot;#healthcheck-is-a-file-mtime&quot; aria-label=&quot;Permalink to Healthcheck is a file mtime&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;borg create&lt;/code&gt; succeeded? Write &lt;code&gt;date &gt; /health/backup_completion_time.log&lt;/code&gt;. The Docker healthcheck shells out every 10 seconds and compares that mtime against &lt;code&gt;MAX_BACKUP_AGE_SECONDS&lt;/code&gt; (default 86400). Older than that, container is unhealthy and whatever’s watching containers (in my case a notification hook) finds out.&lt;/p&gt;
&lt;p&gt;Two subtleties worth naming:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;First-boot grace period.&lt;/strong&gt; If &lt;code&gt;backup_completion_time.log&lt;/code&gt; doesn’t exist yet (fresh container, first backup still running), fall back to &lt;code&gt;container_start_time.log&lt;/code&gt; so the container isn’t reported unhealthy during the first scheduled run.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partial success is not success.&lt;/strong&gt; In multi-target mode, the completion log is only written if &lt;em&gt;every&lt;/em&gt; target succeeded. One repo failing means the healthcheck stays red even if the other two are fine. Stale-but-quiet was the failure mode I wanted to make impossible.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;smaller-calls&quot;&gt;Smaller calls&lt;a class=&quot;heading-anchor&quot; href=&quot;#smaller-calls&quot; aria-label=&quot;Permalink to Smaller calls&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;borg break-lock&lt;/code&gt; at the start of every run.&lt;/strong&gt; If the previous container was killed mid-backup, the repo is locked and the next &lt;code&gt;borg create&lt;/code&gt; will hang. Just break it. There’s only ever one writer because of the sleep loop.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;set -e&lt;/code&gt; after &lt;code&gt;borg init&lt;/code&gt;, not before.&lt;/strong&gt; The init line is the only one allowed to fail (first run on a fresh repo). Everything after halts on error.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;BORG_RSH=&apos;ssh -oBatchMode=yes&apos;&lt;/code&gt;.&lt;/strong&gt; Fail fast if SSH would have prompted, instead of hanging forever inside a detached container.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ServerAliveInterval 30&lt;/code&gt; in &lt;code&gt;ssh_config&lt;/code&gt;.&lt;/strong&gt; Long borg transfers across home-ISP NAT get killed if nothing flows for a few minutes. Keepalives keep the tunnel open.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;--files-cache=ctime,size,inode&lt;/code&gt;.&lt;/strong&gt; The default &lt;code&gt;mtime,size,inode&lt;/code&gt; re-hashes files when their mtime changes; on BTRFS, ctime is the more honest signal of “this content actually changed.”&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;compression=zstd,12&lt;/code&gt;.&lt;/strong&gt; The sweet spot for backup data on my hardware: substantially better than zlib, not so slow it dominates the run.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;borg compact --threshold=5 --cleanup-commits&lt;/code&gt;.&lt;/strong&gt; Reclaims space from pruned archives whenever the segment-file fragmentation crosses 5%.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;IGNORE_GIT_UNTRACKED=true&lt;/code&gt;.&lt;/strong&gt; Optional. Walks every &lt;code&gt;.git&lt;/code&gt; dir under the snapshot, runs &lt;code&gt;git ls-files --others --exclude-standard&lt;/code&gt;, and feeds the result into &lt;code&gt;--exclude-from&lt;/code&gt;. Skips &lt;code&gt;target/&lt;/code&gt;, &lt;code&gt;node_modules/&lt;/code&gt;, build caches; anything the repo already knows isn’t worth keeping.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;SYS_ADMIN&lt;/code&gt; capability on the container.&lt;/strong&gt; Needed for &lt;code&gt;btrfs subvolume snapshot&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; from inside the namespace. The narrower capability set didn’t have a way through.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A test rig that restores into an empty volume on a schedule.&lt;/strong&gt; “Backups exist” is not the property I care about. “Backups restore” is. I have anecdotal evidence after every incident; I don’t have a green checkmark before one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A failure notifier separate from the healthcheck.&lt;/strong&gt; Docker healthcheck-unhealthy is one signal; I’d also want an explicit push (ntfy, email, Telegram) on first failure of a run, so I don’t have to be watching the container state.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallel targets when network and disk don’t compete.&lt;/strong&gt; The current loop is strictly sequential: rsync.net then local HDD. They share neither bandwidth nor spindles; they could run in parallel and halve the wall-clock. Sequential made the wrapper trivial; the trade was knowable and I made it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Two years in, the part I’d defend hardest is the snapshot. Everything above it is a wrapper that could be rewritten in an afternoon. The snapshot is what makes the wrapper allowed to be one.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A Physics Practice App for the Hungarian Érettségi</title><link>https://schmelczer.dev/articles/fizika-erettsegi-practice-app/</link><guid isPermaLink="true">https://schmelczer.dev/articles/fizika-erettsegi-practice-app/</guid><description>A static jQuery site I built in high school to drill past exam questions. 659 questions, a decade of past papers, still online and still used.</description><pubDate>Thu, 28 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I needed it. In my last year of high school I was about to sit the &lt;em&gt;emelt szintű&lt;/em&gt; (advanced-level) physics érettségi, and the practice material I could find online was either paywalled or scattered across PDFs that wouldn’t tell you whether your answer was right. So one evening I started typing past exam questions into a JSON file. A few weeks later I had something resembling a study tool, and a few weeks after that I had 659 questions covering more than a decade of past papers.&lt;/p&gt;
&lt;p&gt;The site is intentionally small. A static frontend on jQuery, four CSS files, a JSON blob of questions, a folder of scanned diagrams from the original papers. You pick a topic (&lt;em&gt;Mechanika, Hőtan, Elektromosság, Atomfizika&lt;/em&gt;) or hunt down a specific year’s exam, get a randomised quiz, answer, and the page colours each row green or red. Past results sit in &lt;code&gt;localStorage&lt;/code&gt;, because the audience was high schoolers; account-less was the privacy answer.&lt;/p&gt;
&lt;p&gt;It outgrew Firebase eventually. I moved the data to a small Express backend so I could keep editing questions without a paid plan, with a JSON file and an image folder as the storage layer. The admin routes have no auth; instead, the service stays off the public internet and I edit through an SSH-forwarded localhost. Fine for a one-person CMS, terrible advice for anything with multiple editors.&lt;/p&gt;
&lt;p&gt;What I’d change if I were starting it now:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Astro instead of jQuery plus a Node server.&lt;/strong&gt; The whole thing could be one static site that re-renders on push. No backend, no CSP fiddling, no Docker.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Markdown source, not a hand-edited JSON file.&lt;/strong&gt; Editing questions in JSON is fine until you forget a comma at 1am and the site stops loading.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A real licence note on the question text.&lt;/strong&gt; The papers are public exam material, but it’s worth saying so somewhere on the page.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s been online in some form for eight years. Every spring I get a few emails from students asking whether I’ll add the latest year’s paper. I usually do, eventually. The thing I made for myself in 2017 is still doing its job for someone else’s last year of high school, and that’s the only metric on it I actually care about.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>web</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>25 Million UK Property Rows in a Single Rust Process</title><link>https://schmelczer.dev/articles/perfect-postcode-rust-property-server/</link><guid isPermaLink="true">https://schmelczer.dev/articles/perfect-postcode-rust-property-server/</guid><description>Notes on perfect-postcode.co.uk. Every numeric feature is u16-quantised in a row-major array, so filter eval is two integer compares per row.</description><pubDate>Thu, 28 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A user told me the map felt sluggish when they dragged it across Manchester with four filters on. They were right. The previous version round-tripped to a database, decoded floats, and lost the budget for a single pan inside the first filter. The rewrite is one Rust binary that holds the entire UK property history in RAM and treats every filter as three integer compares. Everything else in this post is the consequence of refusing to break that latency again.&lt;/p&gt;
&lt;h2 id=&quot;the-constraint-that-shapes-everything&quot;&gt;The constraint that shapes everything&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-constraint-that-shapes-everything&quot; aria-label=&quot;Permalink to The constraint that shapes everything&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The answer to &lt;em&gt;“what’s the median price in this hexagon, filtered to four-bedroom terraces under £450k with a 35-minute transit to Manchester”&lt;/em&gt; needs to come back inside a single map pan. Per visible cell, per request, every time the user moves anything. That’s the work.&lt;/p&gt;
&lt;p&gt;At the resolution we want, the inputs are roughly 25M historical transactions, each with around 150 numeric features (price, EPC, deprivation deciles, school catchment metrics, POI proximities, noise, crime, …). Naively f32 per cell, that’s ~15 GB before you count anything else: postcodes, POIs, places, tiles, travel times. The rest of the architecture is the consequence of insisting it all lives in one process on one rentable box.&lt;/p&gt;
&lt;h2 id=&quot;u16-quantisation-in-a-row-major-flat-array&quot;&gt;u16 quantisation in a row-major flat array&lt;a class=&quot;heading-anchor&quot; href=&quot;#u16-quantisation-in-a-row-major-flat-array&quot; aria-label=&quot;Permalink to u16 quantisation in a row-major flat array&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every numeric feature is encoded as &lt;code&gt;((value - feature_min) / feature_range) * 65534&lt;/code&gt;. Dequant is &lt;code&gt;raw * dequant_a + quant_min&lt;/code&gt;. &lt;code&gt;u16::MAX&lt;/code&gt; is reserved as &lt;code&gt;NAN_U16&lt;/code&gt; (the explicit missing-value sentinel), so the live range is 65534, not 65535. Per feature we keep a &lt;code&gt;(min, scale, p1, p99)&lt;/code&gt; tuple and a 100-bucket histogram for the UI sliders.&lt;/p&gt;
&lt;p&gt;Storage is a single &lt;code&gt;Vec&amp;#x3C;u16&gt;&lt;/code&gt; laid out row-major: &lt;code&gt;feature_data[row * num_features + feat_idx]&lt;/code&gt;. Sixteen features fit in one 64-byte cache line; a row scan stays in L1 for several rows at a time. With 25M rows × ~150 features × 2 bytes, the property matrix is around 7.5 GB, comfortably inside a 16 GB instance once the rest of the data joins it.&lt;/p&gt;
&lt;p&gt;The precision loss is real but bounded: 0.01–0.1% per feature on the data we have, below the noise floor of any downstream statistic. The win is that the hot loop never touches an &lt;code&gt;f32&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-hot-loop-is-three-integer-compares&quot;&gt;The hot loop is three integer compares&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-hot-loop-is-three-integer-compares&quot; aria-label=&quot;Permalink to The hot loop is three integer compares&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;ParsedFilter&lt;/code&gt; carries &lt;code&gt;min_u16&lt;/code&gt; and &lt;code&gt;max_u16&lt;/code&gt;: the user’s bounds requantised against the same per-feature &lt;code&gt;(min, scale)&lt;/code&gt; at parse time. The row test is literal:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;rust&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; raw &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; feature_data[base &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;feat_idx];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;raw &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; NAN_U16&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; &amp;#x26;&amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; raw &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;min_&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;u16&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; &amp;#x26;&amp;#x26;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; raw &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;#x3C;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;max_&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;u16&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No string keys. No &lt;code&gt;f32&lt;/code&gt; decoding. Enum features go through a pre-built &lt;code&gt;FxHashSet&amp;#x3C;u16&gt;&lt;/code&gt; of allowed raw values, same shape.&lt;/p&gt;
&lt;p&gt;Two small parse-time choices made this fast in practice:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Sort filters by selectivity.&lt;/strong&gt; &lt;code&gt;numeric.sort_unstable_by_key(|f| f.max_u16.saturating_sub(f.min_u16))&lt;/code&gt; puts the narrowest ranges first. A 50-filter request usually short-circuits on filter two or three.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reject inverted ranges at parse time.&lt;/strong&gt; &lt;code&gt;min &gt; max&lt;/code&gt; errors out, so &lt;code&gt;saturating_sub&lt;/code&gt; can’t wrap a huge u16 into the sort key and silently reorder things.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;spatial-a-csr-grid-plus-precomputed-h3&quot;&gt;Spatial: a CSR grid plus precomputed H3&lt;a class=&quot;heading-anchor&quot; href=&quot;#spatial-a-csr-grid-plus-precomputed-h3&quot; aria-label=&quot;Permalink to Spatial: a CSR grid plus precomputed H3&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Two indexes, used for different things.&lt;/p&gt;
&lt;p&gt;A 0.01° (~1 km) regular grid in CSR layout (a single flat &lt;code&gt;values: Vec&amp;#x3C;u32&gt;&lt;/code&gt; of row indices and an &lt;code&gt;offsets: Vec&amp;#x3C;u32&gt;&lt;/code&gt; of per-cell starts) answers bbox queries. CSR avoids the 24-byte-per-cell &lt;code&gt;Vec&lt;/code&gt; header you’d pay with &lt;code&gt;Vec&amp;#x3C;Vec&amp;#x3C;u32&gt;&gt;&lt;/code&gt;, which is the difference between a few MB and a few hundred MB at UK scale. &lt;code&gt;for_each_in_bounds&lt;/code&gt; is the variant that skips the result allocation; aggregators stream into it directly.&lt;/p&gt;
&lt;p&gt;An H3 cell at resolution 12 is precomputed per property at boot, stored as &lt;code&gt;Vec&amp;#x3C;u64&gt;&lt;/code&gt;. Lower-resolution cells are derived via &lt;code&gt;CellIndex::parent()&lt;/code&gt;; fast and exact. The hexagon endpoint thresholds at &lt;code&gt;PARALLEL_THRESHOLD = 50_000&lt;/code&gt;: below, plain serial aggregation; above, &lt;code&gt;rayon::par_chunks()&lt;/code&gt; with &lt;code&gt;chunk = max(1000, rows / num_threads)&lt;/code&gt;. Below the threshold, rayon’s per-chunk overhead dominates the work it’s parallelising; it’s worse than the obvious thing. Above, the slope flips.&lt;/p&gt;
&lt;p&gt;A small per-thread &lt;code&gt;FxHashMap&amp;#x3C;u64, u64&gt;&lt;/code&gt; H3 cache inside each rayon chunk takes care of properties touched by multiple aggregations within the same chunk.&lt;/p&gt;
&lt;h2 id=&quot;state-is-an-arc-clone-away&quot;&gt;State is an Arc-clone away&lt;a class=&quot;heading-anchor&quot; href=&quot;#state-is-an-arc-clone-away&quot; aria-label=&quot;Permalink to State is an Arc-clone away&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;AppState&lt;/code&gt; is large and immutable after the boot-time loads. &lt;code&gt;SharedState = RwLock&amp;#x3C;Arc&amp;#x3C;AppState&gt;&gt;&lt;/code&gt; wraps it; every handler does &lt;code&gt;shared.load_state()&lt;/code&gt;: a brief read lock, an &lt;code&gt;Arc::clone&lt;/code&gt;, no further lock contention for the request.&lt;/p&gt;
&lt;p&gt;The standard read-mostly pattern, but worth naming for one reason: it makes hot-reloading the parquet trivial later. Build a new &lt;code&gt;AppState&lt;/code&gt; from disk, take the write lock, swap the &lt;code&gt;Arc&lt;/code&gt;, drop the old one when the last in-flight request finishes. None of the handlers need to change.&lt;/p&gt;
&lt;p&gt;On top of that there’s a per-endpoint &lt;code&gt;ConcurrencyLimitLayer::new(N)&lt;/code&gt;. The expensive endpoints (filter-counts, hexagon-stats, screenshot, export) get 3–5; the cheap ones get 20–30. It is the simplest backpressure you can write and it does most of the work.&lt;/p&gt;
&lt;h2 id=&quot;pocketbase-as-the-distributed-lock&quot;&gt;PocketBase as the distributed lock&lt;a class=&quot;heading-anchor&quot; href=&quot;#pocketbase-as-the-distributed-lock&quot; aria-label=&quot;Permalink to PocketBase as the distributed lock&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For mutations that need exclusion (subscription state transitions, redeem-invite races), there is no Redis. Instead, &lt;code&gt;acquire_pocketbase_lock&lt;/code&gt; does an optimistic create against a &lt;code&gt;locks&lt;/code&gt; collection. If create succeeds, we own it; if it fails on conflict, we fetch the existing lock, check &lt;code&gt;expires_at_unix&lt;/code&gt;, and if it’s expired we delete and retry. Owner ID is a 24-char random string so stale-lock detection doesn’t rely on host identity or wall-clock skew.&lt;/p&gt;
&lt;p&gt;Release is a &lt;code&gt;Drop&lt;/code&gt; handler that spawns a tokio task to delete the record; async cleanup keeps the synchronous drop path free of I/O. 100 ms retry, 10-second acquire deadline. Coarse, but correct, audit-loggable in PocketBase, and adds zero new infrastructure to operate.&lt;/p&gt;
&lt;h2 id=&quot;cost-capping-the-llm-endpoint&quot;&gt;Cost-capping the LLM endpoint&lt;a class=&quot;heading-anchor&quot; href=&quot;#cost-capping-the-llm-endpoint&quot; aria-label=&quot;Permalink to Cost-capping the LLM endpoint&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The AI filter parser is a Gemini call. Two structural choices made it cheap enough to leave on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;One system prompt, computed once.&lt;/strong&gt; &lt;code&gt;build_system_prompt(features, mode_destinations)&lt;/code&gt; runs at boot. The feature catalogue, the enum of available travel modes, the few-shot examples: all concatenated once into a &lt;code&gt;String&lt;/code&gt; on &lt;code&gt;AppState&lt;/code&gt;. Every request reuses the same bytes, which Gemini’s input cache likes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A &lt;code&gt;search_destinations&lt;/code&gt; tool with a closed enum of modes.&lt;/strong&gt; The LLM doesn’t get to invent place slugs. It can call the function; the server slugifies and resolves against the loaded travel-time directory using a word-overlap matcher tolerant of &lt;code&gt;kings-cross&lt;/code&gt; vs &lt;code&gt;King&apos;s Cross&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On top: a per-week token budget (&lt;code&gt;AI_FILTERS_WEEKLY_TOKEN_LIMIT = 10_000_000&lt;/code&gt;) and a 2,000-token output cap. The budget is the actual cost guarantee; the per-call cap is belt-and-braces.&lt;/p&gt;
&lt;h2 id=&quot;smaller-calls&quot;&gt;Smaller calls&lt;a class=&quot;heading-anchor&quot; href=&quot;#smaller-calls&quot; aria-label=&quot;Permalink to Smaller calls&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;mlockall(MCL_CURRENT | MCL_FUTURE)&lt;/code&gt; at startup.&lt;/strong&gt; The hot dataset has to never page out. With &lt;code&gt;CAP_IPC_LOCK&lt;/code&gt; it works; without it we log and continue.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;malloc_trim(0)&lt;/code&gt; after each big load.&lt;/strong&gt; Polars leaves a high allocator water-mark after parquet scans. Trimming after each major load gives back hundreds of MB of RSS before steady state.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prometheus path normalisation.&lt;/strong&gt; &lt;code&gt;/api/tiles/5/16/10&lt;/code&gt; becomes &lt;code&gt;/api/tiles/:z/:x/:y&lt;/code&gt; before it becomes a label. Otherwise &lt;code&gt;/.env&lt;/code&gt;, &lt;code&gt;/wp-admin/...&lt;/code&gt;, and bot scans explode cardinality.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Median-half eviction over LRU.&lt;/strong&gt; Token, share-bounds, and superuser-token caches evict the older half on overflow instead of one entry at a time. Cheap, and it spreads the re-validation cost instead of triggering a thundering herd.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;spawn_blocking&lt;/code&gt; for Polars I/O.&lt;/strong&gt; Parquet scans are CPU-bound. They block the tokio executor if you let them; they don’t if you don’t.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;Box&amp;#x3C;[T]&gt;&lt;/code&gt; instead of &lt;code&gt;Vec&amp;#x3C;T&gt;&lt;/code&gt; for aggregator accumulators.&lt;/strong&gt; No &lt;code&gt;capacity&lt;/code&gt; field, 8 bytes saved per slot. At hundreds of hexagons × six features per request it adds up.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;String interning, three times.&lt;/strong&gt; Postcodes (~2.5M unique from 25M rows) live in a &lt;code&gt;lasso::RodeoReader&lt;/code&gt;; each row stores a &lt;code&gt;Spur&lt;/code&gt; (~4 bytes). Address tokens are flattened into one buffer with per-row &lt;code&gt;(offset, length)&lt;/code&gt; arrays. The same pattern for enum value strings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free-zone bbox check, not point check.&lt;/strong&gt; Unlicensed queries must have their &lt;em&gt;entire&lt;/em&gt; bbox inside &lt;code&gt;FREE_ZONE_BOUNDS&lt;/code&gt;. Point-in-zone would be convenient and wrong; it would let users pan to anywhere from a free-zone centre.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Share-link bounds are server-computed.&lt;/strong&gt; &lt;code&gt;bounds_from_view(lat, lon, zoom)&lt;/code&gt; derives the bbox from a UK-aware longitude/latitude span (&lt;code&gt;half_lat = half_lon * 0.6&lt;/code&gt;) and clamps it. Legacy short URLs without server-stored bounds grant nothing.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pin the allocator.&lt;/strong&gt; I rely on &lt;code&gt;malloc_trim&lt;/code&gt; to keep RSS predictable. A jemalloc with explicit purge would behave better than glibc plus periodic trimming, especially under sustained load.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One bench for the hot loop.&lt;/strong&gt; I trust the structure but I have no number for &lt;em&gt;filter throughput per row per filter under typical load&lt;/em&gt;. That number would tell me when the u16 trick stops being enough.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Move free-zone bounds to PocketBase.&lt;/strong&gt; &lt;code&gt;FREE_ZONE_BOUNDS&lt;/code&gt; is a &lt;code&gt;const&lt;/code&gt;. It’s been right for the demo region for a year. The next time it changes I’ll regret hardcoding it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A typed query DSL instead of &lt;code&gt;;;&lt;/code&gt;-separated strings.&lt;/strong&gt; The current filter wire format is &lt;code&gt;name:min:max;;name:val1|val2&lt;/code&gt;. Cheap to parse, awful to evolve. A small JSON envelope would survive the next feature.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There’s something a little embarrassing about a binary that just memory-maps a country. But the architecture made the latencies trivial, and the latencies are most of what a user feels.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>web</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>An E-Ink Photo Frame That Sleeps When the House Is Empty</title><link>https://schmelczer.dev/articles/frame-eink-photo-display/</link><guid isPermaLink="true">https://schmelczer.dev/articles/frame-eink-photo-display/</guid><description>A Pi, a 6-colour e-ink panel, and a self-hosted Immich library. Photos picked by date and favourites, gated on Home Assistant presence, Atkinson-dithered.</description><pubDate>Wed, 27 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In 2024, researchers found family-blog photos of Brazilian children inside the LAION training set. Self-hosting your photos used to be a preference; it’s a safeguarding decision now. Nixplay’s cloud-tied frames have bricked. Funimation deleted libraries people had paid for. I wanted a photo frame on the hallway wall, and I wasn’t going to hand the family album to a vendor who could close the doors on it.&lt;/p&gt;
&lt;p&gt;So it’s a Raspberry Pi Zero 2W driving Waveshare’s &lt;a href=&quot;https://www.waveshare.com/wiki/PhotoPainter&quot;&gt;PhotoPainter&lt;/a&gt; panel, pulling from my self-hosted &lt;a href=&quot;https://immich.app/&quot;&gt;Immich&lt;/a&gt; library, part of the same &lt;a href=&quot;https://schmelczer.dev/articles/backup-container-btrfs-borg/&quot;&gt;self-hosting setup I back up with btrfs and borg&lt;/a&gt;. A few hundred lines of stdlib Python on top of the reference driver.&lt;/p&gt;
&lt;h2 id=&quot;why-a-stupid-amount-of-engineering-for-a-picture-on-a-wall&quot;&gt;Why a stupid amount of engineering for a picture on a wall&lt;a class=&quot;heading-anchor&quot; href=&quot;#why-a-stupid-amount-of-engineering-for-a-picture-on-a-wall&quot; aria-label=&quot;Permalink to Why a stupid amount of engineering for a picture on a wall&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;That’s the point. Albert Borgmann once distinguished &lt;em&gt;devices&lt;/em&gt; (which efficiently deliver a commodity and disappear into the wall) from &lt;em&gt;focal things&lt;/em&gt;, which gather a practice around them. A Nest Hub is a device; it shows you photos the way a microwave delivers heat. The frame is a focal thing. I curated the weights. I hung it where the light was right. I tweak it when something feels off. It doesn’t sell my attention back to me; it asks me to pay some.&lt;/p&gt;
&lt;p&gt;The medium helps. E-ink doesn’t glow and doesn’t beep. From across the room it reads as &lt;em&gt;image&lt;/em&gt;, not as &lt;em&gt;screen&lt;/em&gt;, and that one perceptual difference changes how often I actually look at it.&lt;/p&gt;
&lt;h2 id=&quot;the-presence-gate&quot;&gt;The presence gate&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-presence-gate&quot; aria-label=&quot;Permalink to The presence gate&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The cron line does most of the work. Every 15 minutes, the script checks the time of day, then asks Home Assistant whether anyone in &lt;code&gt;HA_PRESENCE&lt;/code&gt; is home. If not, it quits. The panel keeps showing the last photo, because e-ink, so you walk in to whatever was there when the house emptied.&lt;/p&gt;
&lt;p&gt;The point isn’t power saving. John Berger drew a line between photographs kept inside a context of lived meaning (private), and ones severed and circulated (public). Google Photos hands you the public mode dressed as the private. A wall in the hallway, lit only when your people are home, restores the context. The same photograph means something different surfacing while you’re cooking dinner than it does in a feed at 11pm.&lt;/p&gt;
&lt;h2 id=&quot;how-a-photo-gets-picked&quot;&gt;How a photo gets picked&lt;a class=&quot;heading-anchor&quot; href=&quot;#how-a-photo-gets-picked&quot; aria-label=&quot;Permalink to How a photo gets picked&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The pool is biased the way memory is biased: four buckets, weighted ~30% “on this day” (dropping to ~10% if only the ±3-day fallback fires), ~18% favourites, ~36% the last 30 days, ~36% everything else. Within those buckets, orientation-match against the current frame gets 4x the weight of mismatch, because cropping landscape to portrait works less often than the reverse.&lt;/p&gt;
&lt;p&gt;A 7-day rolling history filters repeats. Before accepting a candidate, the picker runs &lt;code&gt;heads_fit_in_crop&lt;/code&gt; against Immich’s detected face boxes, extended upward to cover the skull and padded by &lt;code&gt;HEAD_SAFETY_MARGIN&lt;/code&gt;: if the planned crop would slice into any visible head, that candidate is rejected and another is drawn. A wall photo with half a face in it is worse than the same photo not on the wall at all.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;face_aware_crop&lt;/code&gt; does the actual cropping: resize-cropping to fill the frame while biasing the window around detected faces. A landscape shot with room around the subject usually crops cleanly to portrait this way; the guardrail above catches the ones that don’t.&lt;/p&gt;
&lt;h2 id=&quot;tuning-the-pipeline-somewhere-else&quot;&gt;Tuning the pipeline somewhere else&lt;a class=&quot;heading-anchor&quot; href=&quot;#tuning-the-pipeline-somewhere-else&quot; aria-label=&quot;Permalink to Tuning the pipeline somewhere else&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Iterating on the Pi means waiting 12+ seconds per refresh. Both the face-aware crop and the dither were tuned in Jupyter against a local pool of a few hundred photos, then frozen and shipped.&lt;/p&gt;
&lt;p&gt;The dither is where the choice visibly matters. The panel can only show black, white, red, yellow, blue, green; no intensity control, every pixel is one of those six. I compared Floyd-Steinberg, Stucki, and a couple of ordered variants. Atkinson kept the highest perceived contrast on the 6-colour palette without smearing skin tones into the nearest yellow. Pure-Python Atkinson on the Pi Zero was unusably slow, so the inner loop runs through &lt;code&gt;numba&lt;/code&gt; with perceptual-weighted nearest-colour matching (0.299/0.587/0.114). Roughly 100x faster after the JIT cache warms.&lt;/p&gt;
&lt;h2 id=&quot;the-weekend-reimplementable-rule&quot;&gt;The weekend-reimplementable rule&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-weekend-reimplementable-rule&quot; aria-label=&quot;Permalink to The weekend-reimplementable rule&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Hundred Rabbits, a couple who live offshore on a sailboat doing permacomputing in practice, hold themselves to a rule: any system they depend on should be reimplementable in a weekend. The frame meets the bar. A few hundred lines of stdlib Python on a documented panel, reading from an HTTP endpoint that returns JPEGs. It came together over an afternoon with Claude Code plus a couple of weekends tuning the picker and the dither; the repo is public partly as a reference for anyone wanting to do something similar. If Immich disappears tomorrow the selection logic is eighty lines I can repoint at whatever replaces it.&lt;/p&gt;
&lt;h2 id=&quot;smaller-calls&quot;&gt;Smaller calls&lt;a class=&quot;heading-anchor&quot; href=&quot;#smaller-calls&quot; aria-label=&quot;Permalink to Smaller calls&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Capture age and EXIF location painted as text.&lt;/strong&gt; White on a black stroke, written &lt;em&gt;after&lt;/em&gt; dithering, so the labels stay sharp on the 6-colour palette.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Swap masked, journald volatile.&lt;/strong&gt; The SD card is the most likely thing to die on this build. Don’t write to it unless you have to.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Wifi power-save reconnect job.&lt;/strong&gt; The Pi Zero 2W’s wifi drops if power-save kicks in. A separate &lt;code&gt;wifi-check.sh&lt;/code&gt; every five minutes brings it back.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lower-power hardware.&lt;/strong&gt; The Pi Zero 2W is overkill and idles 14 minutes out of every 15. The Waveshare board didn’t have an RTC interrupt pin soldered, and rather than hack one in, I’d reach for an ESP32 next time. Deep sleep has plenty of time to do the image work inside a 15-minute window.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A bigger panel and a small light.&lt;/strong&gt; The &lt;a href=&quot;https://shop.pimoroni.com/products/inky-impression&quot;&gt;Inky Impression&lt;/a&gt; 13” with a custom frame and integrated lighting would help most in the evenings, when the e-ink reads muddled under warm lamps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A daytime cadence curve.&lt;/strong&gt; 15 minutes is constant. It should slow at night and speed up around the times we’re actually in the hallway.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The frame is small, slow, and almost entirely silent. It does one thing for one household and doesn’t tell anyone about it. The smallness is the point. There should be more of this kind of thing.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>embedded</category><category>systems</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A WebGPU Drawing Garden Where Agents Rewrite Your Strokes</title><link>https://schmelczer.dev/articles/fleeting-garden-webgpu-drawing/</link><guid isPermaLink="true">https://schmelczer.dev/articles/fleeting-garden-webgpu-drawing/</guid><description>A single-file WebGPU drawing toy. You stroke a colour, agents follow it, and a 3×3 matrix per vibe gives each preset its personality.</description><pubDate>Fri, 22 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Nine numbers in &lt;code&gt;{-1, 0, 1}&lt;/code&gt; arranged in a 3×3 matrix decide an entire vibe’s personality. That constraint is what kept me up: proving simplicity can be expressive, that you don’t need a behaviour function per preset. A WebGPU drawing toy where you stroke a colour, agents spawn along it, and the garden slowly overwrites the patch you laid down. One static HTML file, six compute stages, none of them skippable.&lt;/p&gt;
&lt;h2 id=&quot;why-physarum-needed-a-knob&quot;&gt;Why physarum needed a knob&lt;a class=&quot;heading-anchor&quot; href=&quot;#why-physarum-needed-a-knob&quot; aria-label=&quot;Permalink to Why physarum needed a knob&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Physarum-style agent sims are everywhere and most of them stop being interesting after thirty seconds, because they converge to the same family of branching shapes no matter what you feed them. Seeding the initial condition isn’t enough; the input has to keep being a force inside the loop, otherwise you’re just watching the attractor settle.&lt;/p&gt;
&lt;p&gt;My second self-imposed constraint was that one engine had to produce six visibly different presets without forking. The first prototype had a &lt;code&gt;switch (preset)&lt;/code&gt; with one behaviour function per vibe and it was already painful at vibe two. I needed the personality to live in data, not code.&lt;/p&gt;
&lt;h2 id=&quot;the-reaction-matrix&quot;&gt;The reaction matrix&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-reaction-matrix&quot; aria-label=&quot;Permalink to The reaction matrix&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Each vibe is a 3×3 table of colour-to-colour affinities. When an agent of colour &lt;code&gt;i&lt;/code&gt; looks at the trail in front of it, it weights the three channels of that sample by row &lt;code&gt;i&lt;/code&gt; of the matrix, then uses the sign to pick left, right, or straight. That’s it. The whole behaviour rule.&lt;/p&gt;
&lt;p&gt;Three examples of what nine numbers can do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aurora Mycelium:&lt;/strong&gt; cyclic, each colour chases the next. Agents wind into ribbons.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Velvet Observatory:&lt;/strong&gt; every off-diagonal entry negative. Colours repel into separate islands.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Paper Lantern Fog:&lt;/strong&gt; matrix filled with ones. Colours collapse into one cooperative blob.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Adding a tenth number to the matrix would tax every existing vibe. Tuning the nine I have is a text edit. Six presets in, I haven’t extended it.&lt;/p&gt;
&lt;h2 id=&quot;the-compute-work-broken-into-small-jobs&quot;&gt;The compute work, broken into small jobs&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-compute-work-broken-into-small-jobs&quot; aria-label=&quot;Permalink to The compute work, broken into small jobs&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Six stages, ten WGSL files, each one short enough that I can hold it in my head when something breaks:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Agent step:&lt;/strong&gt; sample the trail at a sensor offset, pick a turn, move, deposit colour. ~300 lines, the longest one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Diffusion:&lt;/strong&gt; blur and decay so old marks soften. The boring one, and the one you can’t skip: without it, strokes stay forever and the garden collapses into noise.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Brush:&lt;/strong&gt; write user strokes into both the trail texture and a separate “source” texture the agents can read.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Eraser:&lt;/strong&gt; two variants: one clears a region of the trail, the other kills agents in a radius.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agent generation:&lt;/strong&gt; spawn along strokes, resize the buffer when the cap changes, compact after erasure so dead slots don’t waste GPU time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Render:&lt;/strong&gt; read the trail, apply palette and grain.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The bind-group setup overhead from running more pipelines was lost in the noise next to the simulation cost. The win was that when the eraser shader started killing the wrong agents, I opened one file and reasoned about it without touching anything else.&lt;/p&gt;
&lt;h2 id=&quot;smaller-calls&quot;&gt;Smaller calls&lt;a class=&quot;heading-anchor&quot; href=&quot;#smaller-calls&quot; aria-label=&quot;Permalink to Smaller calls&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Adaptive cap, circular buffer.&lt;/strong&gt; If FPS drops, the cap shrinks; if there’s headroom, it grows. When the cap is hit, new agents overwrite older ones. The decay you see, a stroke vanishing thirty seconds after you drew it, isn’t an explicit eraser, it’s the buffer wrapping around.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;URL is the share format.&lt;/strong&gt; The chosen vibe is in the query string. The “send your friend this preset” link is just a URL with &lt;code&gt;?vibe=tidepool-lantern&lt;/code&gt; on it. The parser is tolerant about accents and casing because people retype these.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One HTML file.&lt;/strong&gt; All CSS and JS inline. The piano samples sit beside it. Self-contained enough to email or drop on a USB stick.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The intro animation (agents fly in to spell the title, then transition to steady state) couples three shaders through a single &lt;code&gt;progress: 0 → 1&lt;/code&gt; value. It’s the bit I’d least want to refactor today. Next time I’d model the intro as its own dispatch with its own buffer and hand off cleanly.&lt;/li&gt;
&lt;li&gt;Mobile works, but the toolbar fights the canvas for screen and the agent cap has to shrink hard to keep frame time down. A proper fix means rethinking the toolbar and exposing the cap-vs-resolution tradeoff to the user.&lt;/li&gt;
&lt;li&gt;The simulation has invariants that proptest would falsify in minutes: agent count under the cap, every stroke produces a positive-coloured deposit on the next frame, and the eraser doesn’t leak agents past its radius. Snapshot tests aren’t the right tool here.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>graphics</category><category>simulation</category><category>web</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A 3-Way Text Merger That Never Shows Conflict Markers</title><link>https://schmelczer.dev/articles/reconcile-text-3-way-merge/</link><guid isPermaLink="true">https://schmelczer.dev/articles/reconcile-text-3-way-merge/</guid><description>reconcile-text merges Markdown notes from three editors I don&apos;t control, with no history. Why git, CRDTs, and diff-match-patch each failed me.</description><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;why-i-wrote-it&quot;&gt;Why I wrote it&lt;a class=&quot;heading-anchor&quot; href=&quot;#why-i-wrote-it&quot; aria-label=&quot;Permalink to Why I wrote it&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I keep Markdown notes in three editors I don’t control the internals of: Vim on my laptop, VS Code on my work machine, Obsidian on my phone. When two of them edit the same note between syncs, I have three files: the last-synced parent and two divergent children. That’s the input. I want one merged file out, and I want to hand it back to the editors without conflict markers, because &lt;code&gt;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C;&amp;#x3C; HEAD&lt;/code&gt; is not something a notes app should ever show me.&lt;/p&gt;
&lt;p&gt;Every existing tool got close and missed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git merge-file&lt;/code&gt; does exactly the right thing structurally, then writes markers into the output. That’s correct for source code and wrong for prose.&lt;/li&gt;
&lt;li&gt;CRDTs and OT both assume you own the editing pipeline down to the keystroke. I don’t. I’m looking at three files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;diff-match-patch&lt;/code&gt; doesn’t take a common ancestor. On adjacent edits it quietly produces wrong output. I have a runnable example in the repo.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the library does exactly one thing: pure function from three strings to one. No async, no networking, no concurrency, no plugins. Anything outside that boundary is somebody else’s library.&lt;/p&gt;
&lt;h2 id=&quot;the-decisions-worth-naming&quot;&gt;The decisions worth naming&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-decisions-worth-naming&quot; aria-label=&quot;Permalink to The decisions worth naming&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Myers diff per side, then weave the diffs.&lt;/strong&gt; Each child is diffed against the parent, the two edit scripts are optimised so adjacent changes group cleanly, then a single weaving pass interleaves them into one ordered op sequence that produces the merged text. The weave borrows the shape of operational transformation, but the inputs are batched complete diffs, not live keystrokes, so it only runs once per merge.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tokeniser is the user knob.&lt;/strong&gt; This is the choice I’d defend hardest. Most of what people want when they say “merge differently” isn’t a new algorithm; it’s a different unit. Word-level tokenisation turns most “conflicts” in prose into two adjacent edits that coexist. Line-level makes it behave like &lt;code&gt;git merge-file&lt;/code&gt;. Markdown-level merges on headings and list items. Same engine, four different products depending on what you call a token.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cursors are first-class merge inputs.&lt;/strong&gt; Each cursor has a stable ID and rides through the merge so a collaborative editor can ask “where did this cursor go?” without reconstructing it from the output text. This is the bit that made it useful to anything that wasn’t just &lt;a href=&quot;https://schmelczer.dev/articles/vault-link-obsidian-sync/&quot;&gt;the Obsidian sync plugin I wrote alongside it&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Rust core is generic; the FFI surface is not.&lt;/strong&gt; Inside Rust, the tokeniser is a &lt;code&gt;dyn Fn(&amp;#x26;str) -&gt; Vec&amp;#x3C;Token&amp;#x3C;T&gt;&gt;&lt;/code&gt;. That dies the moment you try to pass it through wasm-bindgen or pyo3. The fix was a closed enum of built-in tokenisers for non-Rust callers, with the generic version reserved for Rust users. Not elegant, but the alternative was per-binding glue forever.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WASM size mattered enough to tune for it.&lt;/strong&gt; The release profile is aggressive about size, and the JS package ships a small leak detector that warns if you forget to free wasm-bindgen objects. I lost an afternoon to that the first time and didn’t want anyone else to.&lt;/p&gt;
&lt;h2 id=&quot;whats-held-up-what-id-change&quot;&gt;What’s held up, what I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#whats-held-up-what-id-change&quot; aria-label=&quot;Permalink to What’s held up, what I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Kept:&lt;/strong&gt; the never-emits-markers, never-drops-edits guarantee. It’s the only reason a sync engine can call this library without an escape hatch.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kept:&lt;/strong&gt; the comparison example against &lt;code&gt;diff-match-patch&lt;/code&gt;. It’s a runnable program in the repo showing exact inputs where the alternative is wrong. Way more convincing than a benchmark table.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cut:&lt;/strong&gt; the snapshot tests do well on regressions and badly on unknown edge cases. Three-way merging is exactly what proptest was made for, and I should have written generators on day one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Next:&lt;/strong&gt; I want to be more explicit about the boundary. reconcile-text is a merge primitive, not a live collab engine. If you have a keystroke stream and a real-time channel, use Yjs or Automerge. This library is for when you don’t.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;if-you-take-one-idea-from-this&quot;&gt;If you take one idea from this&lt;a class=&quot;heading-anchor&quot; href=&quot;#if-you-take-one-idea-from-this&quot; aria-label=&quot;Permalink to If you take one idea from this&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Prose deserves a merger that prefers a slightly clumsy sentence over a marker. Code doesn’t. That one asymmetry is the whole reason the library exists in the shape it does; everything else fell out of taking it seriously.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>tools</category><category>web</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A Python Framework Where Doing the Right Thing Is the Default</title><link>https://schmelczer.dev/articles/greatai-ai-deployment-api/</link><guid isPermaLink="true">https://schmelczer.dev/articles/greatai-ai-deployment-api/</guid><description>My MSc thesis. 33 catalogued ML deployment habits, a decorator-shaped Python API, and a survey of working engineers on which actually got adopted.</description><pubDate>Sat, 09 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;By the end of 2021 I had stopped believing the people skipping ML deployment best practices were the problem. They knew the list. They agreed with the list. They had a deadline, and every item on the list cost five lines of glue. My MSc thesis turned that into the actual research question: not “what should engineers do” but “what API shape makes doing the right thing cheaper than not.” The framework that fell out, &lt;code&gt;great-ai&lt;/code&gt;, is a decorator on a plain Python function. The thesis behind it is the part worth reading.&lt;/p&gt;
&lt;h2 id=&quot;the-thing-nobody-wants-to-admit&quot;&gt;The thing nobody wants to admit&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-thing-nobody-wants-to-admit&quot; aria-label=&quot;Permalink to The thing nobody wants to admit&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The literature has a long list of habits you should adopt when shipping an ML service: track inputs, version models, expose health, log decisions, keep predictions reproducible. Everyone agrees with the list. Almost nobody implements all of it.&lt;/p&gt;
&lt;p&gt;I spent the bulk of the thesis catalogueing 33 such habits, proposing 6 more, and surveying engineers on which actually got applied in their day jobs. The data was pretty clear about the failure mode: it wasn’t ignorance, it wasn’t laziness, it wasn’t budget. It was that the cost of doing the right thing, five lines of glue per habit multiplied across a stack, was higher than the visible cost of skipping it. So skipping it became the default.&lt;/p&gt;
&lt;p&gt;So the real research question wasn’t “what should engineers do.” It was “what API shape makes doing the right thing cheaper than not.”&lt;/p&gt;
&lt;h2 id=&quot;the-frameworks-bet&quot;&gt;The framework’s bet&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-frameworks-bet&quot; aria-label=&quot;Permalink to The framework’s bet&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A decorator on a plain function.&lt;/strong&gt; &lt;code&gt;@GreatAI.create&lt;/code&gt; turns a regular Python function into a deployed service with metadata, request tracing, and a versioned interface. No inheritance, no project layout, no enforced directory structure. The mental cost is one import.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implicit behaviour only for cross-cutting concerns.&lt;/strong&gt; Logging, versioning, metadata are implicit. Anything touching business logic stays explicit. The rule: if it would surprise me when I’m debugging, it shouldn’t be implicit.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Own the contract, leave the storage alone.&lt;/strong&gt; Where you persist logs, models, or metrics is your choice; GreatAI defines the shape and provides defaults. The model registry stays somebody else’s library.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The survey backed up the central premise: ease of use and functionality both matter for adoption, and they’re independent axes. A framework that ticks every box and is awkward will lose to a smaller one that doesn’t.&lt;/p&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;I’d narrow further. Anything GreatAI did that overlapped with MLflow, BentoML, or modern observability stacks would go. The durable bit was always the decorator and the catalogue behind it.&lt;/li&gt;
&lt;li&gt;I’d publish the survey instrument separately. The 33-habit catalogue and the adoption-vs-impact methodology outlive the framework. People still ask about that part.&lt;/li&gt;
&lt;li&gt;I’d stop calling them “best practices.” I used that phrase in the thesis and it aged into corporate-speak. The honest name is “things that hurt later if you skip them.”&lt;/li&gt;
&lt;/ul&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>ai</category><category>systems</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A 2D Ray Tracer for the Browser, Tuned for the Phone in Your Pocket</title><link>https://schmelczer.dev/articles/sdf-2d-ray-tracing/</link><guid isPermaLink="true">https://schmelczer.dev/articles/sdf-2d-ray-tracing/</guid><description>My BSc thesis library. The mobile GPU shaped the architecture: tile-based passes, deferred shading, shaders generated per scene and device.</description><pubDate>Fri, 08 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Winter 2020, BSc thesis deadline closing in, and the thing had to run acceptably on my advisor’s laptop the day he graded it. That single shipping pressure exposed every lazy assumption in the architecture and picked the design: tile-based passes, deferred shading, shaders generated per scene and per device. A 2D ray tracer in the browser via signed distance fields: soft shadows, smooth reflections, no triangle mesh. The other half of the thesis was &lt;a href=&quot;https://schmelczer.dev/articles/declared-shared-simulation-code/&quot;&gt;decla.red&lt;/a&gt;, the multiplayer game that proved the renderer survived a real game loop.&lt;/p&gt;
&lt;h2 id=&quot;what-mobile-gpu-actually-meant&quot;&gt;What “mobile GPU” actually meant&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-mobile-gpu-actually-meant&quot; aria-label=&quot;Permalink to What “mobile GPU” actually meant&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A 2D SDF ray tracer is conceptually simple: for each pixel, march along a ray, sample the distance field, accumulate light. The implementation that works on a desktop NVIDIA card spends so much per pixel that a mobile GPU melts. So the design problem was never “can SDFs do soft shadows” (yes, easily), it was “what work can I avoid per pixel without giving up the look.”&lt;/p&gt;
&lt;p&gt;Three constraints did most of the design work:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;WebGL1 and WebGL2 both supported.&lt;/strong&gt; No “modern browser only” cheat. That ruled out anything that needed compute shaders or storage buffers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No per-scene hand-tuned shader.&lt;/strong&gt; This is a library; users plug in their own scene descriptions. The renderer has to compile something appropriate at runtime.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Acceptable on a phone.&lt;/strong&gt; Not “good when the user owns the right hardware.” It had to be acceptable on the laptop my advisor used to grade the thesis.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;how-it-actually-runs&quot;&gt;How it actually runs&lt;a class=&quot;heading-anchor&quot; href=&quot;#how-it-actually-runs&quot; aria-label=&quot;Permalink to How it actually runs&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tile-based rendering.&lt;/strong&gt; Group pixels and reason about them together. Most regions of a frame share the same nearby geometry, so you can early-out enormous swathes of pixel work if you know the tile’s bounds. This was the single biggest perf win.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deferred shading.&lt;/strong&gt; Separate “find the surface” from “shade the surface.” Shadow casting and reflections need the same geometry queries; doing them once per pixel and reusing the result was worth the extra texture bandwidth.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Generated shaders per scene and device.&lt;/strong&gt; If a scene has no reflective surfaces, the generated shader doesn’t carry the reflection path. If the device only supports WebGL1, the shader doesn’t reach for WebGL2 features. Static feature flags do this badly; runtime generation does it well.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TypeScript scene descriptions, no DSL.&lt;/strong&gt; I prototyped a small DSL for SDF authoring and threw it away. Pride’s expensive. Users describe scenes in plain TypeScript and the library compiles them down. A DSL would have meant one more language to teach and one more compiler to debug.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;held-up-didnt-hold-up&quot;&gt;Held up, didn’t hold up&lt;a class=&quot;heading-anchor&quot; href=&quot;#held-up-didnt-hold-up&quot; aria-label=&quot;Permalink to Held up, didn’t hold up&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Held up:&lt;/strong&gt; the mobile constraint forced structural perf work instead of cosmetic perf work. When something only runs on a desktop GPU you mistake headroom for good architecture, and the rude awakening comes from a user.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Held up:&lt;/strong&gt; keeping the library boundary clean. A demo can hide a messy implementation; a published package can’t.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Didn’t:&lt;/strong&gt; I had no instrumentation around shader variants. Today I’d ship a small &lt;code&gt;?debug=1&lt;/code&gt; overlay that prints exactly which shader got compiled for that session and why.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Didn’t:&lt;/strong&gt; the docs are words about ray marching. The ideas are visual; the explanation should have been too. Diagrams next time.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>graphics</category><category>web</category><category>systems</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>One Game Library, Imported by Both the Client and the Server</title><link>https://schmelczer.dev/articles/declared-shared-simulation-code/</link><guid isPermaLink="true">https://schmelczer.dev/articles/declared-shared-simulation-code/</guid><description>A mobile multiplayer browser game where client and server linked the same TypeScript module. One source of truth, one fewer class of bug.</description><pubDate>Thu, 07 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;My thesis was a renderer; proving it in a real multiplayer loop was the point. A real game loop is a worse audience than a tech demo. That’s the point. So through autumn 2020 I built decla.red on top of &lt;a href=&quot;https://schmelczer.dev/articles/sdf-2d-ray-tracing/&quot;&gt;SDF-2D&lt;/a&gt;: a conquest-style space shooter, two teams, small planets, ray-traced 2D rendering, browser and mobile. The architecture decision worth remembering came out of needing the server and the client to stop lying to each other: one TypeScript module containing the game rules, linked by both sides of the wire.&lt;/p&gt;
&lt;h2 id=&quot;the-split-that-usually-goes-wrong&quot;&gt;The split that usually goes wrong&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-split-that-usually-goes-wrong&quot; aria-label=&quot;Permalink to The split that usually goes wrong&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Real-time multiplayer has an awkward two-machine problem. The server has to be authoritative or the game is cheatable; the client has to feel immediate or the game is unplayable. If you write the rules twice, once on each side, they will drift. Eventually a player’s screen will say one thing and the server will think another.&lt;/p&gt;
&lt;p&gt;I wanted the server’s “compute the next state” function and the client’s “predict the next state locally” function to be literally the same function. So I put the rules in a shared TypeScript library, published nothing, and had both &lt;code&gt;package.json&lt;/code&gt; files link to it.&lt;/p&gt;
&lt;p&gt;The win wasn’t elegance, it was the bugs that didn’t happen. Client prediction stopped being an approximation of the server; it &lt;em&gt;was&lt;/em&gt; the server, run optimistically and reconciled when the authoritative update came back.&lt;/p&gt;
&lt;h2 id=&quot;other-choices-worth-a-sentence&quot;&gt;Other choices worth a sentence&lt;a class=&quot;heading-anchor&quot; href=&quot;#other-choices-worth-a-sentence&quot; aria-label=&quot;Permalink to Other choices worth a sentence&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;k-d trees for spatial queries.&lt;/strong&gt; Once the world held more than a few dozen objects, naive collision and proximity checks dominated the server tick. A k-d tree dropped them out of the profile.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Message-passing object model.&lt;/strong&gt; Lifted from Smalltalk’s &lt;code&gt;doesNotUnderstand:&lt;/code&gt; idea. Entities respond to messages they care about and ignore the rest. Easier to extend than the inheritance tree I tried first, and less brittle.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Firebase only for server discovery.&lt;/strong&gt; Not for game state, just for “which servers are currently in the pool.” Tiny consistent store, didn’t need to write one.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Observability for desync.&lt;/strong&gt; Multiplayer systems live or die by visibility into divergence. I had logs; I needed dashboards showing the rate, the shape, and the triggering interaction for every prediction miss. Without those, debugging was guessing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don’t tangle rendering and networking in the same tree.&lt;/strong&gt; Both were interesting, both put different kinds of pressure on the architecture, and the directories grew into each other. Separate top-level folders from day one next time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skip multi-server until the math demands it.&lt;/strong&gt; I wired up multi-server early because it sounded right. With 16–32 clients per server I was nowhere near needing it; the complexity wasn’t free.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>games</category><category>web</category><category>systems</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A 50 FPS Game Engine on an 8-Bit Microcontroller</title><link>https://schmelczer.dev/articles/ad-astra-attiny85-game-engine/</link><guid isPermaLink="true">https://schmelczer.dev/articles/ad-astra-attiny85-game-engine/</guid><description>A handheld game built from the PCB up: ATtiny85V, OLED, IR receiver, EEPROM, 8 MHz 8-bit ALU. 50 FPS floor.</description><pubDate>Wed, 06 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I’d done microcontroller work on dev boards before and it always felt like I was renting the hardware. As soon as I had a real board with my own soldering on it, bugs stopped feeling like software inconveniences and started feeling like consequences of choices I’d made in KiCad. That shift was most of the value of doing it this way. Four years on from &lt;a href=&quot;https://schmelczer.dev/articles/lights-synchronized-to-music/&quot;&gt;my first hardware project&lt;/a&gt;, the lesson was that owning the whole stack down to the copper changes how you debug.&lt;/p&gt;
&lt;p&gt;This one is a handheld game built from the PCB up around an ATtiny85V: 8-bit ALU at 8 MHz, no FPU, no SIMD, 8 KB of flash. Anything I built had to fit inside that, or I’d be staring at a brick.&lt;/p&gt;
&lt;h2 id=&quot;the-bits-worth-showing&quot;&gt;The bits worth showing&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-bits-worth-showing&quot; aria-label=&quot;Permalink to The bits worth showing&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SIMD-on-an-8-bit-ALU display driver.&lt;/strong&gt; The OLED is 128×64 monochrome, 1024 bytes per frame. The driver packs four pixels into a byte and processes them with bit-parallel tricks. That’s how the frame budget stayed under 20 ms with room for game logic.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prototype-based inheritance, in C.&lt;/strong&gt; Entities share behaviour by pointing at a struct of function pointers. No vtable, no class, no allocator. Cheap dispatch and the whole object model fits on one screen.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Atomic EEPROM commits.&lt;/strong&gt; Sprite data and save state both live in EEPROM. The commit path writes a new region, then swaps a tiny header pointer. Pull the battery mid-write and the previous version is intact.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PNG-to-C sprite pipeline.&lt;/strong&gt; A Python script turns PNG artwork into static C arrays the firmware can include directly. Asset workflow without ever leaving the source tree.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A host-side emulator.&lt;/strong&gt; Debugging firmware directly on hardware was character-building and slow. A small SDL-based simulator linking the same C code would have shortened the iteration loop from “reflash and hope” to “rebuild and run.”&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Power numbers I’d actually trust.&lt;/strong&gt; I have peak and standby draw. I don’t have a curve over a real gameplay session, so I honestly can’t say how long the battery lasts under load. I can only say it outlasted my patience.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A development log for the driver.&lt;/strong&gt; The display driver and the EEPROM commit protocol are the parts I’d still defend. They deserved diagrams and measurements at the time, not the half page of comments I left them with.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>embedded</category><category>games</category><category>systems</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>Syncing State with an Immutable Trie</title><link>https://schmelczer.dev/articles/life-towers-immutable-tries/</link><guid isPermaLink="true">https://schmelczer.dev/articles/life-towers-immutable-tries/</guid><description>A visual goal tracker whose lasting idea was the sync model: an immutable trie so structural diffs are trivial and only deltas cross the wire.</description><pubDate>Tue, 05 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In August 2019 I wanted a goal tracker I’d actually open, on whichever device was nearest, without watching it disagree with itself. Nothing off the shelf fit, so I built one over a couple of weekends. The tower metaphor was the part friends saw; the part that aged well was the sync model that fell out of needing the same state in three places at once.&lt;/p&gt;
&lt;h2 id=&quot;the-problem-in-one-paragraph&quot;&gt;The problem in one paragraph&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-problem-in-one-paragraph&quot; aria-label=&quot;Permalink to The problem in one paragraph&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Pick any non-trivial mutable object graph, sync it across devices, and you end up either sending the whole thing on every change (wasteful) or writing ad-hoc diff logic per shape (brittle). I wanted a representation where the &lt;em&gt;shape&lt;/em&gt; of the data made the diff fall out for free.&lt;/p&gt;
&lt;h2 id=&quot;the-trie-concretely&quot;&gt;The trie, concretely&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-trie-concretely&quot; aria-label=&quot;Permalink to The trie, concretely&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A goal in Life Towers is a path of strings. &lt;code&gt;Health / Running / 5k&lt;/code&gt;. Tasks under a goal hang off the leaf. A user’s whole state is a tree, and a trie is exactly the data structure that makes that tree’s &lt;em&gt;identity&lt;/em&gt; manipulable.&lt;/p&gt;
&lt;p&gt;Two properties did the heavy lifting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Structural sharing.&lt;/strong&gt; When you tick off a task under &lt;code&gt;Health / Running / 5k&lt;/code&gt;, the new root reuses every untouched subtree by reference. The &lt;code&gt;Career&lt;/code&gt; branch and the &lt;code&gt;Reading&lt;/code&gt; branch are the same objects they were before. Comparing the old and new roots is mostly pointer equality; only the path that actually changed gets walked.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Immutability.&lt;/strong&gt; Updates produce new structure instead of mutating. “Where I was” and “where I am” become two pointers, not two snapshots. The diff between them is whatever’s not shared, and that walk is O(changes), not O(state).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The sync loop falls out:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Client holds the last root the server acknowledged plus its own current root.&lt;/li&gt;
&lt;li&gt;To send: walk only the unshared paths, emit one op per changed leaf. In practice that’s a handful of bytes for a typical edit, no matter how large the rest of the tree is.&lt;/li&gt;
&lt;li&gt;Server applies, returns its new root.&lt;/li&gt;
&lt;li&gt;Client rebases any in-flight edits by replaying them on top.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There’s no conflict resolution layer because the operations commute on the structure. Two clients adding tasks under different branches produce non-overlapping deltas that compose trivially. The hard cases (two clients editing the same leaf) are tiny and obvious, because they’re the &lt;em&gt;only&lt;/em&gt; place the deltas touch the same path.&lt;/p&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Property tests around the rebase.&lt;/strong&gt; The reconcile path is exactly where a generator finds bugs that hand-written tests never think to write. I had hand-written cases; I’d start with &lt;code&gt;proptest&lt;/code&gt; now.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A standalone spec for the wire format.&lt;/strong&gt; The part worth lifting out was the protocol, not the goal tracker. A short spec would let me (or anyone) reimplement it in a different stack without re-deriving everything from the Python source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Strip the visual experiment.&lt;/strong&gt; The tower visualisation was fun but it bound the storage to a UI metaphor. The sync model should be a library; the towers should be a separate toy.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;if-you-take-one-idea-from-this&quot;&gt;If you take one idea from this&lt;a class=&quot;heading-anchor&quot; href=&quot;#if-you-take-one-idea-from-this&quot; aria-label=&quot;Permalink to If you take one idea from this&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Most sync problems are diff problems pretending to be transport problems. Pick the data structure that makes the diff free, and the protocol almost writes itself. The corollary: if you’re writing a lot of “if this changed, send that” code, you’re using the wrong structure.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>web</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>Two Graphs Are Simpler Than One: A Cooling System Simulator</title><link>https://schmelczer.dev/articles/nuclear-cooling-simulation/</link><guid isPermaLink="true">https://schmelczer.dev/articles/nuclear-cooling-simulation/</guid><description>Live cooling-system sim for a PLC cybersecurity event. Splitting flow and heat into two graph passes kept it cheap and the behaviour believable.</description><pubDate>Mon, 04 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Trying to solve flow and heat as a coupled system would have been a real CFD problem and I had two weeks. A cybersecurity event in late 2018 needed a cooling-system simulator that contestants could poke at through PLCs over a weekend, and the deadline shaped every decision after it: cheap to compute, plausible to a non-specialist, runs all weekend on one server. The useful design move was modelling flow and heat as &lt;strong&gt;two separate graph passes&lt;/strong&gt;, not one combined PDE.&lt;/p&gt;
&lt;h2 id=&quot;what-the-event-needed&quot;&gt;What the event needed&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-the-event-needed&quot; aria-label=&quot;Permalink to What the event needed&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The challenge was about PLCs. Contestants would change setpoints, valves, or pump speeds, and we needed them to see whether their action made the plant stable, wasted coolant, or melted something. That meant:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Multiple monitoring clients had to update from one simulation server in near real time.&lt;/li&gt;
&lt;li&gt;The system had to be configurable enough that the event organisers could ship me a new plant on Friday night and have it running Saturday morning.&lt;/li&gt;
&lt;li&gt;It had to be obvious. A simulator nobody understands isn’t a teaching tool, it’s noise.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-split-that-made-it-cheap&quot;&gt;The split that made it cheap&lt;a class=&quot;heading-anchor&quot; href=&quot;#the-split-that-made-it-cheap&quot; aria-label=&quot;Permalink to The split that made it cheap&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Instead of the coupled solver:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Flow first, as graph traversal.&lt;/strong&gt; Walk the pipe graph from the pumps, accumulate pressure, distribute water to nodes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Heat second, as a linear system.&lt;/strong&gt; Build the adjacency matrix from the flow result, add boundary conditions (heaters, exchangers, base temperatures), solve for node temperatures with NumPy.&lt;/li&gt;
&lt;li&gt;Repeat both passes per tick.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is wrong as physics. It’s right as a model. Flow doesn’t react to instantaneous heat in any way contestants could perceive, and the cost of solving them separately was a tiny fraction of solving them together. The clean phase boundary also meant when “the heat is weird,” I knew exactly which pass to look at.&lt;/p&gt;
&lt;h2 id=&quot;why-the-editor-mattered&quot;&gt;Why the editor mattered&lt;a class=&quot;heading-anchor&quot; href=&quot;#why-the-editor-mattered&quot; aria-label=&quot;Permalink to Why the editor mattered&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The simulator’s most-used UI was the &lt;em&gt;input&lt;/em&gt; editor, a separate JavaFX tool where you laid out the plant, set parameters per element, and exported JSON the sim ate. I wrote up the editor’s &lt;a href=&quot;https://schmelczer.dev/articles/graph-editor-javafx-simulation-input/&quot;&gt;own story here&lt;/a&gt;, because in hindsight it deserved to be its own project.&lt;/p&gt;
&lt;p&gt;The lesson: a simulation is only as useful as its input pipeline. If editing the plant requires editing source, organisers won’t use it.&lt;/p&gt;
&lt;h2 id=&quot;what-id-change&quot;&gt;What I’d change&lt;a class=&quot;heading-anchor&quot; href=&quot;#what-id-change&quot; aria-label=&quot;Permalink to What I’d change&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;State what the model claims.&lt;/strong&gt; A convincing sim needs an honest README about what it does and doesn’t model. Mine didn’t. Anyone who took the numbers seriously could have walked away believing more than the model deserved.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recorded scenarios as regression tests.&lt;/strong&gt; Sim projects drift in ways that look plausible on screen. Storing “this input over 60 seconds produces these outputs” would have caught me when I broke the temperature solver on Saturday morning at the event.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skip JavaFX.&lt;/strong&gt; Cross-platform packaging was painful and the desktop dependency made the editor harder to hand off than it should have been. A web-based editor in the same browser the monitors used would have meant one fewer install for the organisers.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>simulation</category><category>systems</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>Predicting EUR/USD With Hanning Windows</title><link>https://schmelczer.dev/articles/foreign-exchange-prediction-experiment/</link><guid isPermaLink="true">https://schmelczer.dev/articles/foreign-exchange-prediction-experiment/</guid><description>A weekend frequency-domain experiment that did a passable job on EUR/USD. I would not have trusted it with my money, and I didn&apos;t.</description><pubDate>Sun, 03 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In the autumn of 2019 I was an undergrad with a few weekends free and the quiet conviction that I could find a small edge on EUR/USD. The screenshots were flattering: the prediction (blue) hugged the actual rate (green) in a way that looked like skill. A linear regression in the frequency domain, dressed up. I did not trade real money with it, and that restraint is the only thing about the project that aged well.&lt;/p&gt;
&lt;p&gt;The pipeline:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Smooth the input series.&lt;/li&gt;
&lt;li&gt;Differentiate.&lt;/li&gt;
&lt;li&gt;Short-time Fourier transform with overlapped, Hanning-windowed frames.&lt;/li&gt;
&lt;li&gt;Extrapolate the frequency-domain coefficients.&lt;/li&gt;
&lt;li&gt;Invert everything back to a predicted price series.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A Python server (NumPy, SciPy, Flask) ran the model. An MQL4 client on a broker terminal called the server and would have placed trades if I’d dared.&lt;/p&gt;
&lt;p&gt;What I actually learned: even a naive model can show a sometimes-profitable backtest, and that’s the trap. The real game is built by people with co-located servers, microsecond ticks, and millions in infrastructure. This project taught me how far my edge wasn’t.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>My Notes: A Markdown App for Android</title><link>https://schmelczer.dev/articles/my-notes-android-markdown-app/</link><guid isPermaLink="true">https://schmelczer.dev/articles/my-notes-android-markdown-app/</guid><description>A small Android note app built on Markwon. The idea wasn&apos;t new; the point was learning a platform that wasn&apos;t the web.</description><pubDate>Sat, 02 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In November 2019 I wrote my own notes app for Android, used it daily for a while, and then it lost a long battle with Obsidian. The loss was the lesson: I learned what I actually wanted from a notes app by watching mine fail to be it. Years later that same itch is why I wrote &lt;a href=&quot;https://schmelczer.dev/articles/reconcile-text-3-way-merge/&quot;&gt;reconcile-text&lt;/a&gt;; by then I was editing the same notes in Vim, VS Code, and Obsidian, and nothing existed to merge three independently-edited copies back into one.&lt;/p&gt;
&lt;p&gt;The app itself was small: Markdown notes, hashtag filtering, Markwon for rendering. Every developer writes their own notes app eventually and the bar for shipping one isn’t high. What I actually wanted was a few weeks outside the web stack, somewhere with different conventions about lifecycle, storage, and resource constraints. Android delivered that. I’d still recommend “write a small thing on a new platform” as a way to recalibrate what you take for granted.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A Unity City Where Bad PLC Code Made Cars Crash</title><link>https://schmelczer.dev/articles/city-simulation-unity-traffic/</link><guid isPermaLink="true">https://schmelczer.dev/articles/city-simulation-unity-traffic/</guid><description>A REST-controlled traffic-light sim for a cybersecurity event. Bad PLC code showed up as car crashes, the most honest feedback loop I&apos;ve shipped.</description><pubDate>Fri, 01 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Most security challenges punish wrong answers with a red “incorrect.” This one punished them with car wrecks, and people learned faster. A PLC cybersecurity event in the summer of 2018 needed something visceral; I built a small Unity city where the traffic lights were driven by a REST API and contestants wrote the control logic.&lt;/p&gt;
&lt;p&gt;All decisions ran on the server and got broadcast to clients. The harder problem wasn’t the simulation; it was making the broadcast fault-tolerant on conference Wi-Fi without flooding it. I built it solo, including the models and animations in Blender. Not a flex, just context for why everything’s a little janky.&lt;/p&gt;
&lt;p&gt;There was also a HUD overlay for tweets. It felt clever at the time and dated horribly. Skip that part.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>simulation</category><category>systems</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A Colour Grader Where Distance Was the Whole Idea</title><link>https://schmelczer.dev/articles/photo-colour-grader/</link><guid isPermaLink="true">https://schmelczer.dev/articles/photo-colour-grader/</guid><description>Pick a colour, transform every nearby colour as a function of distance. A proof-of-concept grader I built to try one interaction idea.</description><pubDate>Thu, 30 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In June 2018 I got tired of every grader I tried making me think in masks. I wanted to point at “this orange” in a photo from one of my &lt;a href=&quot;https://schmelczer.dev/articles/photo-site-generator/&quot;&gt;walks&lt;/a&gt;, nudge it, and have the neighbouring reds and yellows come along by however much made sense. Distance in colour space, not a brush. So I built the proof.&lt;/p&gt;
&lt;p&gt;The UI was a colour wheel where you’d click to drop a marker, drag to move it, click anywhere to add another. Each marker had its own settings; transformations fell off smoothly with distance from the picked colour. No masks, ever.&lt;/p&gt;
&lt;p&gt;I never built it into a real tool. The idea still feels right: distance in colour space is the natural unit for prose-style editing of an image. If I returned to it, I’d reach for WebGL instead of canvas. The interaction only earns its keep if the preview is live on a real photo, and canvas couldn’t get there.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>graphics</category><category>web</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>Avoid</title><link>https://schmelczer.dev/articles/avoid-early-web-game/</link><guid isPermaLink="true">https://schmelczer.dev/articles/avoid-early-web-game/</guid><description>My first browser game. Tiny, archived for honesty.</description><pubDate>Wed, 29 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Keeping it here because pretending the older work didn’t happen would be dishonest. The first browser game I wrote, January 2018. It isn’t good, but it was the moment a &lt;code&gt;&amp;#x3C;canvas&gt;&lt;/code&gt; element stopped being mysterious.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>games</category><category>web</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A 3D Voxel Game in C, Built While Learning Pointers</title><link>https://schmelczer.dev/articles/platform-game-c-sdl/</link><guid isPermaLink="true">https://schmelczer.dev/articles/platform-game-c-sdl/</guid><description>My Basics of Programming project. 3D platformer in C with SDL 1.2, destructible terrain, time-slowdown powerups, and a great many segmentation faults.</description><pubDate>Tue, 28 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Autumn 2017, Basics of Programming, a deadline that forced me to learn C the hard way. I’d write almost none of it the same way today, and I’d defend every choice in it anyway. A 3D voxel platformer in pure C with SDL 1.2. No engine, no scripting layer.&lt;/p&gt;
&lt;p&gt;Maps were randomly generated and destructible voxel by voxel, so the player could dig their way out of trouble or wall off flying enemies that merged into larger ones as they got closer. Powerups let you shoot, or slow down time at the cost of points.&lt;/p&gt;
&lt;p&gt;What I actually learned was pointers, painfully, through an adequate number of segfaults. The course was meant to teach the basics of programming; for me it was the moment programming stopped feeling like a list of facts and started feeling like a thing I could build with. The next time I reached for C it was on hardware that punished waste; see &lt;a href=&quot;https://schmelczer.dev/articles/ad-astra-attiny85-game-engine/&quot;&gt;Ad Astra&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First-project privilege.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>games</category><category>systems</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A Photo Site That Generated Itself From a Folder</title><link>https://schmelczer.dev/articles/photo-site-generator/</link><guid isPermaLink="true">https://schmelczer.dev/articles/photo-site-generator/</guid><description>A Webpack script that turns a folder of photos into a static site with responsive image variants. Mostly here as an excuse to talk about walks.</description><pubDate>Mon, 27 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I take walks with a camera. Most of what I shoot isn’t good, but the act of walking slowly with a frame to think about is the most reliable way I know to come back with an idea for whatever I’m working on. In the summer of 2016 I wanted somewhere to put the few frames that survived, and I wasn’t going to maintain a CMS for it.&lt;/p&gt;
&lt;p&gt;So a Webpack script: point it at a directory of full-size photos, get a static site with responsive variants per image. Drop in a new photo, run the build, deploy. The pipeline mattered less than making the habit visible. The same habit later produced a &lt;a href=&quot;https://schmelczer.dev/articles/photo-colour-grader/&quot;&gt;colour grader&lt;/a&gt; for the same shots.&lt;/p&gt;
&lt;p&gt;If I rebuilt it today I’d use Astro, which is what this site runs on.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>web</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>My First Real Project: LEDs Driven by an FFT</title><link>https://schmelczer.dev/articles/lights-synchronized-to-music/</link><guid isPermaLink="true">https://schmelczer.dev/articles/lights-synchronized-to-music/</guid><description>A Raspberry Pi music player that drove RGB strips through MOSFETs. The first thing I started and actually finished.</description><pubDate>Sun, 26 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Spring 2016. I had a Raspberry Pi, a couple of 12V RGB LED strips someone had given me, a handful of MOSFETs from an electronics kit, and zero idea what I was doing. I wired one of the MOSFETs backwards and it got hot enough to leave a small mark on the breadboard. I learned to read a datasheet, slowly, by needing one. This was the first thing I started and actually finished.&lt;/p&gt;
&lt;p&gt;The plan was something like: play music, look at it, make the lights match. I got bands wrong first. Mapping raw audio amplitude to brightness made the lights pulse with anything (clipping, voice, fan noise), a strobing mess that hurt to look at. Reading about Fourier transforms long enough to type &lt;code&gt;numpy.fft.fft(audio_chunk)&lt;/code&gt; into a REPL was the moment the project started actually behaving like the thing I’d imagined. Bass-heavy frequency bins went to red; mids to green; highs to blue. Smoothing the output over a few frames stopped the seizure-inducing flicker.&lt;/p&gt;
&lt;p&gt;The frontend was a vanilla web page on the same Pi: pick a track, tweak the band thresholds, see what changed. No framework. Just a &lt;code&gt;&amp;#x3C;select&gt;&lt;/code&gt;, a few sliders, and an &lt;code&gt;XMLHttpRequest&lt;/code&gt;. It worked.&lt;/p&gt;
&lt;p&gt;It’s not impressive in 2026. The thing I actually keep from it isn’t the FFT or the MOSFETs; it’s the discovery that I’d rather have a finished janky thing than an elegant unfinished one. Most of the projects on this site are downstream of that discovery; &lt;a href=&quot;https://schmelczer.dev/articles/ad-astra-attiny85-game-engine/&quot;&gt;the ATtiny85 handheld&lt;/a&gt; four years later is the same instinct with the soldering iron held steadier. I’d still recommend the same path to anyone learning: pick something physical, plug things together until they work, accept that the first version will be ugly.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>systems</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item><item><title>A JavaFX Editor for the Cooling Simulator</title><link>https://schmelczer.dev/articles/graph-editor-javafx-simulation-input/</link><guid isPermaLink="true">https://schmelczer.dev/articles/graph-editor-javafx-simulation-input/</guid><description>Companion editor for the cooling-system sim. Drag-and-drop graph layout, JSON export, upload-to-backend. Small tool, mattered more than I expected.</description><pubDate>Sat, 25 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Non-technical event organisers needed to rewire a cooling plant in real time without me hovering. That was the brief, and it ruled out every interface I’d have enjoyed writing. The &lt;a href=&quot;https://schmelczer.dev/articles/nuclear-cooling-simulation/&quot;&gt;cooling system sim&lt;/a&gt; was only as useful as the tool that fed it, so in late 2018 I built a JavaFX desktop editor: lay out the plant as a graph, edit each element’s parameters in a side panel, export JSON, or upload straight to the backend.&lt;/p&gt;
&lt;p&gt;Small tool, and the whole event hinged on it. If I built it again I’d skip JavaFX and put the editor in the browser next to the monitoring clients. One install fewer for everyone, and one fewer reason for someone to call me over.&lt;/p&gt;</content:encoded><dc:creator>Andras Schmelczer</dc:creator><category>simulation</category><category>tools</category><author>andras@schmelczer.dev (Andras Schmelczer)</author></item></channel></rss>