LIVE SPECIMEN — L. candidum — interact with the systemLIVE SPECIMEN — L. candidum, exploded — interact with the system--.- ms
Adnan HusainSystems · markets · browser tools
I take things apart to find out how they work.
Systems software developer
Final-year computer science. Nine projects in three groups: systems built up from the rule, markets, and tools that run entirely in the browser. Mostly Rust, with some C++ and TypeScript.
Every figure is the real rule, running. Scroll to take it apart.
- drawn by
- Adnan Husain
- sheet
- 01 of 01
- parts
- 09
- scale
- 1 : 1
- units
- px
- status
- final year
Parts list
drag to reorder · alt + arrows to move · order is saved
- P-0164 × 32 PX CHIP-8 emulator rust · minifb Systemscomplete
- P-02ZERO COPIES A grep clone rust · memmap · regex Systemscomplete
- P-03PENDING → 0 Concurrent web crawler rust · tokio · reqwest Systemscomplete
- P-04DIFFICULTY husaynex rust · blake3 Systemscomplete
- P-05INVENTORY SKEW Avellaneda-Stoikov market maker c++17 · imgui · implot Marketscomplete
- P-06BPS / ROUND TRIP Haircut typescript · solana · pyth Marketslive
- P-07SPREAD Δ Solana arbitrage bot rust · tokio · jito Marketsin progress
- P-080 BYTES SENT UPInsight typescript · pdf.js · web workers · ocr Browser toolslive
- P-0910 MB CHUNKS LocalCrunch rust · wasm · web worker Browser toolslive
R-14 partsP-01 – P-04
Systems
built up from the rule
P-0164 × 32 PX
CHIP-8 emulator
rust · minifb
An interpreter for a 1970s virtual machine: 35 instructions, 4 KB of memory, and a display that draws sprites by XOR, so anything overlapping erases rather than stacks.
Anything overlapping erases rather than stacks.
The interpreter loop and the timers run on separate clocks: 700 Hz for instructions, 60 Hz for the timers, both independent of the display refresh. Share one and instruction throughput fights frame timing: fast enough to feel responsive and the display tears; slowed to 60 Hz and the games crawl.
P-02ZERO COPIES
A grep clone
rust · memmap · regex
Line-by-line matching spent most of its time allocating rather than comparing. Memory-mapping the file and matching over borrowed slices removed the copies entirely.
Nothing is copied in order to be looked at.
Profiling put the allocator above the matcher. Memory-mapping hands you the file as one borrowed slice, so a match becomes a pair of offsets into memory the kernel already paged in. Nothing is copied in order to be looked at.
P-03PENDING → 0
Concurrent web crawler
rust · tokio · reqwest
Throughput is bounded by other people’s servers, not by my code, so the work is restraint: capped concurrency, robots.txt and per-origin crawl delays, hard limits on pages and depth.
The crawl ends when nothing is pending, not when the queue looks empty.
The queue is unbounded on purpose. Workers both consume and produce, so a bounded queue deadlocks the moment every worker blocks on a full one. What bounds the crawl instead is the visited set and a page slot reserved atomically before each fetch. A pending counter covers queued plus in-flight work; when it reaches zero the queue closes and the workers exit.
P-04DIFFICULTY
husaynex
rust · blake3
A blockchain written from first principles: blocks, hashes, a difficulty, and a loop that keeps guessing until the leading digits come out right.
The nonce is an integer you increment. There is no cleverness in the search at all.
Each block commits to the hash of the one before it, so validation is recomputation: index continuity, the previous hash, the block’s own hash, then the proof of work. Change one byte and that block’s hash moves, the next block is left pointing at a hash that no longer exists, and repairing it means mining every later block again. Difficulty is a count of leading hex zeros, so it moves in steps of sixteen. The nonce is an integer you increment; there is no cleverness in the search at all.
R-23 partsP-05 – P-07
Markets
prices, spreads, inventory
P-05INVENTORY SKEW
Avellaneda-Stoikov market maker
c++17 · imgui · implot
An implementation of the Avellaneda-Stoikov paper: a market maker quoting both sides of a mid-price, with the quotes moving as inventory, volatility and time left in the session change. One engine drives a CLI, a native GUI and a browser dashboard, run against a random walk or real historical prices.
Quote around the price you are indifferent at, not the mid.
I built it to understand how market making actually works rather than to produce anything new, and the code was the easy half. The idea worth the attention is the reservation price: not the mid, but the price you are indifferent to holding your current inventory at. Quote around that instead and the skew that unloads a position falls out of the model rather than being bolted on. Everything the paper leaves out (an order book with depth, queue position, what happens when its assumptions do not hold) is where the rest of the work went.
P-06BPS / ROUND TRIP
Haircut
typescript · solana · pyth
What a tokenized stock actually costs to trade on Solana. Buy $N and sell it straight back; whatever does not come back is the cost. Round-tripping $10,000 of METAx costs $126, the same trade in SPYx costs $3.
round trip · buy $10,000, sell it straight back
Whatever does not come back is the cost.
A round trip needs no reference price, and that matters: Jupiter’s price is an index, not the mid of the pool you route through, and measuring against it put METAx at −4.4 bps, buying below mid. Both legs are quoted in raw units, so Token-2022’s scaled-UI multiplier cancels too; ignore it anywhere else and a holding is off by up to 57 bps.
P-07SPREAD Δ
Solana arbitrage bot
rust · tokio · jito
Two exchanges disagree on a price for a few hundred milliseconds. Polling returned too late, so market state lives in memory and WebSocket pushes mutate it in place.
- compute budget
- swap A
- swap B
- jito tip
- simulate
One shared truth, briefly locked.
State sits behind an Arc<RwLock<…>>: many readers evaluating, one writer applying each push. Channels were the alternative, but then every consumer keeps its own copy of the book and they drift under load. One shared truth, briefly locked.
R-32 partsP-08 – P-09
Browser tools
the file never leaves the tab
P-080 BYTES SENT
UPInsight
typescript · pdf.js · web workers · ocr
UPI and bank statement analytics that runs entirely in the browser. Drop in a PhonePe or Google Pay PDF; it comes back as categorised transactions, recurring payments and cashflow, and none of it leaves the device.
pdf.js text layer · sample statement
transactions
Anchor on the one thing every transaction has: a date and a time.
Statements are chaos as text, so parsing anchors on the one thing every transaction has: a date and time. Lines are split into blocks at those anchors, then vendor, amount, UTR and direction are pulled out of each block. Extraction runs in a Web Worker so the page never freezes, and scanned pages with no text layer fall back to OCR.
P-0910 MB CHUNKS
LocalCrunch
rust · wasm · web worker
A data profiler that runs in the browser. Drop in a CSV and get column types, distributions, missing values, duplicates and quality problems, then filter and explore, and the file never leaves your machine.
Size is limited by time, not memory.
A Rust engine compiled to WebAssembly streams the file through a worker in 10 MB chunks, so size is limited by time, not memory. Chunks rarely end on a record, so the unfinished tail is carried into the next one. Stats are single-pass (Welford), duplicates are 64-bit row fingerprints rather than rows, and medians come from a reservoir sample.
Nwriting
Notes, in progress
not published yet
- N-01What XOR sprites taught me about statein draft
- N-02Polling is a bet that nothing happenedin draft
- N-03Reading a binary with no documentationoutlined