Adnan Husain
Final-year computer science. Eleven projects in four groups: systems built up from the rule, markets, tools that run entirely in the browser, and software that acts without you. Mostly Rust, with some C++ and TypeScript.
Every figure is the real rule, running. Open a part to read it.
saiyedadnanhussain@gmail.com ·
github.com/Adnan-Husayn
Systems
CHIP-8 emulator
rust · sdl2
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.
The interpreter loop and the display refresh run on separate clocks. 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.
language: Rust · display: 64 × 32 · opcodes: 35 · status: complete · github.com/Adnan-Husayn/chip-8-emulator
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.
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.
language: Rust · approach: mmap + slices · allocations: none per line · status: complete · github.com/Adnan-Husayn/grep-rs
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, per-host rate limits, a frontier that cannot grow without end.
The frontier is a bounded channel rather than a growing queue. When it fills, producers block, and that is the point. Back-pressure means one slow host stalls its own branch instead of letting the queue eat memory until the process dies.
language: Rust · runtime: Tokio · limit: per-host · status: complete · github.com/Adnan-Husayn/web-crawler
husaynex
rust
A blockchain written from first principles: blocks, hashes, a difficulty target, and a loop that keeps guessing until the leading digits come out right.
Difficulty is a target the hash must fall under, not a count of leading zeros, because a target tunes smoothly and zeros come in steps of sixteen. The nonce is an integer you increment; there is no cleverness in the search at all.
language: Rust · consensus: proof of work · written: from scratch · status: complete · github.com/Adnan-Husayn/husaynex
Markets
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.
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.
language: TypeScript · chain: Solana · Token-2022 · spread: 42× at $10k · status: live · github.com/Adnan-Husayn/haircut · haircut-fi.vercel.app
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.
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.
language: C++17 · based on: Avellaneda & Stoikov, 2008 · frontends: CLI · ImGui · web · status: complete · github.com/Adnan-Husayn/avellaneda-stoikov-market-maker
Solana arbitrage bot
rust · tokio · jito
Watches SOL/USDC on Raydium and Orca, works out whether a round trip between them pays after fees, and builds the single transaction that would capture it. It runs in simulation by default; live sending through Jito is written and guarded, and has never been run with real funds.
The second swap's minimum output is set to the input plus costs, so the whole transaction reverts on-chain unless it ends in profit. Being wrong costs a failed simulation, not money. Market state sits behind an Arc<RwLock<…>> that WebSocket pushes write into and the per-slot evaluation reads. The plain result so far: the spread is around 10 bps against roughly 29 bps of pool fees, so on public WebSockets there is usually nothing to take.
language: Rust · venues: Raydium V4 · Orca Whirlpools · execution: simulated, Jito bundles guarded · status: live monitor, no real funds · github.com/Adnan-Husayn/solana-spatial-arbitrage · adnan-husayn.github.io/solana-spatial-arbitrage/
Browser tools
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.
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.
language: TypeScript · runs: browser only · parse: pdf.js + Tesseract · status: live · github.com/Adnan-Husayn/UPInsight · upinsight.vercel.app
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.
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.
language: Rust → WASM · memory: bounded, streamed · tests: chunk edges, quoted newlines · status: live · github.com/Adnan-Husayn/localcrunch · localcrunch.vercel.app
Agents and automation
Stagehand
typescript · llm agent · qloo api
A booking and promotion agent for independent music venues. Give it a city and a few artists that sold well, and it returns a ranked shortlist of artists likely to sell there, with the taste data behind each one, plus a promo plan for any artist you pick.
A language model can name plausible venues and brands, but it has no measured overlap behind them. So the agent only uses ids and numbers returned by Qloo during the same run: the submit tools reject any id they did not receive, and the evidence on screen is built from the raw responses, so the model cannot change the numbers. Built for the Qloo Agentic Hackathon.
language: TypeScript · model: any OpenAI-compatible API · data: Qloo insights · status: live demo · github.com/Adnan-Husayn/stagehand · stagehand-venues.vercel.app
RunLookout
typescript · cloudflare workers · d1 · telegram
A monitor for automation workflows, in beta as a SaaS. Every five minutes it checks for failed runs and missed schedules, and sends a Telegram alert with a short note the operator can pass on.
A workflow that fails quietly is worse than one that errors loudly, so the check looks for absence as well as failure: a scheduled run that never happens, or a run that finishes with empty output, both raise an alert. It runs on Cloudflare Workers Free with a D1 database, so keeping the monitor up costs nothing.
language: TypeScript · runtime: Workers · D1 · alerts: Telegram · status: SaaS, in beta · app.runlookout.workers.dev/
Notes
What a tokenized stock actually costs to trade
Tokenized US stocks trade on Solana around the clock. Nobody quotes what it costs to get in and out.
I built Haircut to measure that. The method is simple: buy $N of a token, sell it back straight away, and count what doesn't come back. Nothing else is needed, and that turned out to matter.
The first version used the price Jupiter shows on screen as the reference. It gave impossible results. METAx came out at -4.4 bps, meaning I was buying below the mid. The on-screen price is an index, not the price of the pool the trade actually routes through. Once I stopped comparing against it, the round trip became the only number worth quoting.
Here is what it says, live, during US market hours. Round-tripping $10,000 of METAx costs $126. The same amount of SPYx, the S&P 500 token, costs $3. Same wallet, same minute, forty times the cost.
Two things made the measurement harder than it looked.
The first is the multiplier. xStocks use Token-2022's scaled UI amount to handle dividends and splits. The share count is the raw amount times a multiplier, so ignoring it can misstate a holding by up to 57 bps. The extension carries two values, and the one you read first is often stale. On AAPLx the obvious field was 6 bps behind, and it looked perfectly plausible. A round trip doesn't need the multiplier at all, because both legs are quoted in raw units and it cancels. It only matters when you show a balance to a person.
The second is timing. I compared a price feed that updates every ten seconds with a trade recorded an hour earlier, and measured the stock moving rather than the spread. MSTRx showed +1.00% that way and +0.16% when both sides were read seconds apart.
The oracle turned up something I didn't expect. Pyth has two feed families for each stock. The company feeds publish every few seconds, and they keep moving after the US close. The token feeds publish only when someone pays to update them. On one read, the token feeds were between a few hours and eleven days old, with no pattern and nothing on the account to say which you were looking at.
So the round trip is the number to trust, and the token's oracle price is the one to be careful with.
An agent that can only repeat what the data said
I built Stagehand for the Qloo Agentic Hackathon. It's a booking agent for small music venues. A booker types in a city and a few artists that sold well, and gets back a ranked list of artists likely to sell in that city, each with the taste data behind it.
The obvious problem with a language model here is that it will happily invent. Ask it for venues, brands and podcasts that a city's fans like, and it writes a confident list. None of it has to be true.
So I made the agent's output checkable. Every tool call goes to Qloo and the response is kept for that run. When the model submits its shortlist, the submit tool rejects any artist id it didn't receive during that run. The evidence shown on screen is built from the raw responses, not from the model's text, so the model can't change the numbers, only pick which ones to show.
Some rules came from the data, not from the design. Seed artists must never come back as recommendations, so their ids go into every artist search as exclusions, and the submit tool rejects them again by name in case the ids drift. Qloo's city search is fuzzy, so a locality only counts when its name matches the venue's city, and the state or country decides between two towns with the same name. When a city has no locality in Qloo, place search falls back to a text search, which keeps only places whose address names the city. The activity panel says which strategy worked, so a booker can see when the answer rests on a weaker match.
The part to look at first is the submit validator. It is what makes the rest of the system trustworthy. A model that can only point at things it was given is less impressive in a demo than one that writes fluent answers, and far more useful to a booker who has to explain the answer to a band.
If the Qloo key or the model key is missing, the app runs in demo mode on fixed, made-up data, and a banner says so. The live site runs on real Qloo data.
Monitoring the failures that don't throw an error
Automation breaks in a quiet way. A workflow that fails loudly is easy: somebody sees the error. The one that costs you is the workflow that stops running and tells nobody.
RunLookout checks client automations every five minutes and sends a Telegram alert in three cases: a run fails, a scheduled run never happens, or a run finishes and produces nothing. The third case is the easiest to miss. A run that succeeds with an empty result looks healthy in any view that only counts finished runs.
Missed runs are harder. The monitor can't see something that didn't happen, so it has to compare what it saw against a schedule. If a run should have started at 09:00 and nothing appeared by the next check, that's an alert. The gap is the signal.
Each alert also includes a short note the operator can pass to the client, so the message says what happened, not just that something did. The fallback notes are fixed text, and the note only gets smarter when the Cloudflare AI binding is turned on in production.
It runs on Cloudflare Workers Free with a D1 database. Every five minutes is a cheap cron, and D1 holds only the run history it needs to compare against. Locally it runs with the AI binding left out, so testing needs no Cloudflare login.
The part worth reading if you're building something similar is the Telegram sign-in. Telegram can't reach localhost, so the local setup pulls pending updates from Telegram's getUpdates and forwards them to the local webhook by hand. It's a small script, but it's the difference between being able to test the bot and not.
RunLookout is live as a beta SaaS.