webassembly
1 article
John Bauer · Staff Engineer at @livekit
John Bauer’s personal site: writing, work, and a few things to play with.
ls -la
ls writings/
cd writings
ls
cd ..
cat about.md
Press Tab to complete a command or path. Use ↑ / ↓ for command history.
John Bauer · Staff Billing Systems Engineer
Read the résumé · Download résumé JSON
The JSON file contains the same experience, skills, and education as the résumé page.
A Go and SDL2 project, rewritten in Rust and compiled to WebAssembly.
Run flappy or flappybird to play here. Click or tap the game, or focus it and press Space to flap.
{
"basics": {
"name": "John Bauer",
"label": "Staff Billing Systems Engineer",
"email": "notjrbauer@gmail.com",
"website": "https://bauer.gg",
"summary": "Staff engineer building billing systems at LiveKit. Previously built billing and payments infrastructure at 1Password, Cloudflare, and Segment. I focus on Go, usage-based billing, and reliable revenue systems.",
"location": {
"city": "Pittsburgh",
"countryCode": "US",
"region": "Pennsylvania"
},
"profiles": [
{
"network": "GitHub",
"username": "notjrbauer",
"url": "https://github.com/notjrbauer"
}
]
},
"work": [
{
"company": "LiveKit",
"website": "https://livekit.io/",
"position": "Staff Billing Systems Engineer",
"startDate": "2026-08-11"
},
{
"company": "Pyre",
"position": "Founder / CTO",
"startDate": "2024-08-01",
"endDate": "2026-01-31",
"summary": "Built and tested an internal operations platform for direct cremation workflows, including intake, pickup/removal, scheduling, documentation, cremation operations, payment workflow integration points, and return logistics.",
"highlights": [
"Built Go APIs and data model for case management with audit-friendly lifecycle transitions, idempotent operations, and verification gates for document/state consistency.",
"Implemented Kafka-based orchestration for case state changes, notifications, and operational handoffs across scheduling, documentation, communications, and fulfillment workflows.",
"Delivered a TypeScript/React operator console for dispatch, chain-of-custody tracking, checklists, exception handling, templated communications, and operational status visibility; deployed services on Kubernetes with logs, metrics, and runbooks."
]
},
{
"company": "1Password",
"website": "https://1password.com",
"position": "Senior Systems Engineer, Billing Platform",
"startDate": "2021-08-01",
"endDate": "2026-07-28",
"summary": "Led architecture and reliability initiatives for an event-driven billing platform across Web, Apple Pay, Google Play / Google Pay, enterprise subscriptions, partner provisioning, and internal billing operations.",
"highlights": [
"Designed and built the 1Password Billing Service, consolidating monolith-owned and scattered Go billing logic into a horizontally scalable Go service with production-grade observability and operational tooling.",
"Owned rollout for the new billing service: worker migration, CI improvements, pipeline ownership, staged adoption, and gradual movement of Stripe-related logic toward the service as a billing source of truth.",
"Improved billing correctness under concurrency by introducing message-grouped queue processing and rebuilding worker lifecycle management for graceful shutdowns/restarts, reducing deadlocks, stalled work, and duplicate-processing risk.",
"Optimized stalled-invoice correction, reconciliation syncing, invoice correction, and invoice generation workflows from multi-hour runtimes to under an hour by redesigning batch execution and tightening concurrency patterns.",
"Led a Stripe API migration from v62 to v76 across Go codebases, covering broad API changes, many call sites, deprecated product edge cases, regional tax/invoicing behavior, canary rollout, backfill, and full production cutover.",
"Owned mobile subscription and payment platform work across Apple and Google payment surfaces, including Google Play / Google Pay flows and Apple subscription APIs; migrated Apple subscription customers from 1Password 7 to 1Password 8 while preserving continuity.",
"Built the Partners API for cross-organization provisioning of accounts, users, and billing models, enabling a new partner channel, reducing manual onboarding, and supporting enterprise provisioning for a major cable-network partnership.",
"Built frontend billing experiences and internal tools including the payment form, PDF invoice generation, RED/billing-health dashboards, API docs, Docker Compose local dev stacks, and Testcontainers integration testing.",
"Led the first production migration of a service from EC2 to Kubernetes/EKS, implementing Helm, FluxCD GitOps, OIDC authentication, cross-cluster networking, GitLab CI/CD, Terraform automation, and operational runbooks; mentored 12 engineers and drove RFCs/RFDs/design reviews."
]
},
{
"company": "Cloudflare",
"website": "https://cloudflare.com",
"position": "Senior Systems Engineer, Billing",
"startDate": "2017-07-01",
"endDate": "2021-08-31",
"summary": "Owned and modernized billing, entitlements, product catalog, and subscription systems with a focus on usage metering, invoice correctness, provider migrations, and safe rollout of revenue-impacting platform changes.",
"highlights": [
"Owned usage-based billing for Workers, Rate Limiting, CDN, Load Balancing, seats, requests, and bandwidth; built internal APIs and processing pipelines powering invoices, overages, reporting, and customer lifecycle workflows.",
"Planned and executed migration of customer payment profiles from BillForward through Tract/Dell Boomi integration paths and toward Stripe-backed billing foundations, including cutover strategy, automation, backfills, and legacy-service deprecation.",
"Built correctness guardrails around billing workflows, including idempotency, retries, reconciliation, and backfills for partial failures, late events, and provider inconsistencies across globally distributed systems.",
"Introduced a Kafka-backed entitlements event stream so downstream systems could consume plan, product access, feature flag, and seat-count changes asynchronously instead of coupling directly to synchronous billing paths.",
"Implemented product catalog as the source of truth for SKU lifecycle, pricing/product metadata, entitlement mapping, rollout automation, and provisioning behavior across multiple payment providers.",
"Rewrote a core entitlements service from PHP to Go, led deprecation of legacy PHP billing services, supported migration from Marathon toward Kubernetes-native patterns, and delivered subscriptions UI, entitlement tooling, Prometheus metrics, RFCs/RFDs, and mentoring."
]
},
{
"company": "Segment",
"website": "https://segment.com",
"position": "Senior Software Engineer II",
"startDate": "2016-06-01",
"endDate": "2017-07-01",
"summary": "Owned revenue-critical billing and usage systems: Stripe-backed invoicing, webhook processing, idempotent invoice handling, and usage/overage metering.",
"highlights": [
"Owned a Go Billing Service integrating with Stripe; processed webhook events through API Gateway, Lambda, and SQS while improving correctness under retries, partial failures, and out-of-order delivery.",
"Added idempotency keys and retry-safe invoice processing; investigated and mitigated Stripe rate-limit issues that delayed invoice finalization and caused missed webhook updates, including shared-token pressure from other services.",
"Built simulation and backfill tooling to reproduce/repair historical billing issues, correct usage discrepancies, and support safer invoice recovery after provider or pipeline failures.",
"Owned counters and usage services consuming NSQ event streams, tracking usage counts, and storing metadata in Redis for overage billing, analytics, and usage reporting; mentored teammates and interviewed candidates."
]
},
{
"company": "Eazeup",
"website": "https://eazeup.com",
"position": "Senior Software Engineer",
"startDate": "2015-04-01",
"endDate": "2016-06-01",
"summary": "Migrated an Azure/C# monolith to AWS/Node.js microservices with RabbitMQ, building payment-related services, customer account workflows, operational tooling, and analytics pipelines.",
"highlights": [
"Migrated Azure/C# monolith services to AWS/Node.js microservices using RabbitMQ.",
"Built payment-related services, customer account workflows, operational tooling, and analytics pipelines.",
"Improved driver routing, ETA logic, customer account flows, and proximity-aware menu behavior."
]
},
{
"company": "Rivers Agile",
"position": "Fullstack Developer",
"startDate": "2014-12-29",
"endDate": "2015-04-01",
"summary": "Built Angular/Rails/Postgres scheduling and auditing workflows for enterprise customers and contributed to Ionic mobile applications.",
"highlights": [
"Developed scheduling and auditing workflows for enterprise customers.",
"Built Angular/Rails/Postgres application features and contributed to Ionic mobile applications.",
"Supported customer-facing workflows used by large enterprise clients."
]
},
{
"company": "Branding Brand",
"website": "http://brandingbrand.com",
"position": "Director of API Development",
"startDate": "2011-09-01",
"endDate": "2014-12-28",
"summary": "Led a backend/platform organization of roughly 20 engineers managing managers, leads, and ICs; modernized Apache/PHP services to Nginx/Node.js and built commerce APIs and third-party integrations.",
"highlights": [
"Led approximately 20 engineers across backend services, platform work, and API development.",
"Modernized infrastructure from Apache/PHP to Nginx/Node.js.",
"Built and supported commerce APIs and integrations for PayPal, ShopRunner, eBay, and major retail clients.",
"Owned code review practices, mentoring, backend interviews, hiring, and internal engineering curriculum."
]
}
],
"education": [
{
"institution": "Duquesne University",
"area": "Computer Science",
"studyType": "Bachelor of Science, Minor in Mathematics",
"startDate": "2008-06-01",
"endDate": "2011-04-01"
}
],
"skills": [
{
"name": "Backend & Revenue Platforms",
"keywords": [
"Go",
"Distributed Systems",
"Billing Platforms",
"Payments",
"Subscriptions",
"Usage-Based Billing",
"Entitlements",
"Revenue Correctness",
"Product Catalog",
"Provisioning"
]
},
{
"name": "Correctness & Reliability",
"keywords": [
"Idempotency",
"Retries",
"Reconciliation",
"Backfills",
"Event Ordering",
"Concurrency Control",
"Incident Response",
"Observability"
]
},
{
"name": "Infrastructure & Data",
"keywords": [
"Kubernetes",
"EKS",
"AWS",
"Docker",
"Terraform",
"Helm",
"FluxCD",
"GitLab CI/CD",
"Prometheus",
"MySQL",
"PostgreSQL",
"Redis",
"Kafka",
"ActiveMQ",
"RabbitMQ",
"NSQ",
"SQS"
]
},
{
"name": "Frontend & Internal Tools",
"keywords": [
"TypeScript",
"React",
"Vue",
"Svelte",
"Payment Forms",
"Subscription Management UIs",
"Billing Dashboards",
"Operator Consoles",
"Internal Billing Tooling"
]
},
{
"name": "Payment & Product Systems",
"keywords": [
"Stripe",
"Apple Pay",
"Apple Subscriptions",
"Google Play",
"Google Pay",
"Payment Provider Migrations",
"Product Catalog",
"Enterprise Provisioning"
]
}
],
"languages": [
{
"language": "English",
"fluency": "Native speaker"
},
{
"language": "Spanish",
"fluency": "un poco"
}
],
"interests": [
{
"keywords": [
"Brazilian Jiu-Jitsu",
"Muay Thai",
"Running",
"Climbing",
"Programming",
"Reading",
"Distributed Systems",
"Learning New Languages"
]
}
]
}You found the dotfile. Make yourself at home.
In May 2017 I started a Flappy Bird clone in Go with SDL2, got a bird sprite flapping its wings over a background, made 2 commits that same evening, an initial commit and then “wip” 12 minutes later, and did not touch it again for 9 years. Last week I decided I wanted it running in the browser.
This post explains why the Go version cannot compile to WebAssembly, how the Rust rewrite is split so the whole simulation tests natively, and where the unplanned time went.
The Go version renders through
go-sdl2, which is cgo bindings to
native SDL2. Go’s WebAssembly target (GOOS=js GOARCH=wasm) does not support
cgo. The moment cgo appears anywhere in the dependency graph, the wasm target
is gone; there is no flag to work around it.
Emscripten, the usual escape hatch for SDL2 projects, is a C/C++ toolchain and does not take Go either.
Apparently 2017 me suspected trouble here: the old main.go opens with a
bare import "C" and ends with a commented-out //export main2 shim, half a
plan to embed the whole game in a C host someday. It would not have helped.
So the plan became a Rust rewrite of the rendering layer against the canvas 2D API, compiled with wasm-bindgen. That sounded like a big loss until I counted. The final “wip” snapshot was 519 lines, and roughly 80 of them were game logic; the rest was SDL initialization, teardown, and error plumbing. The port loses plumbing, not a game.
Reading 9-year-old wip code is humbling. The game I remembered writing did not exist.
The bird moved with WASD, 2 pixels per keypress, in any direction. Jump()
set a speed field that nothing ever read; in the initial commit, the one
line that would have integrated it into position sat commented out, and the
“wip” commit 12 minutes later deleted it. Clicking the mouse cycled an
on-screen label through RUN, FLAP, and DEAD without changing anything else
about the world.
For those 12 minutes the initial commit’s Update() also called
spew.Dump(b.x, b.y) every frame, so the bird narrated its coordinates to
stdout 60 times a second; “wip” removed that too. Jump() took an
*sdl.Renderer argument it never used.
So the port is where the actual game got written. Gravity plus a flap impulse, with the bird’s rotation easing toward its velocity so it noses up on a flap and tips over as the fall accelerates. AABB collision against a hitbox inset 8 by 6 pixels from the drawn sprite, because near misses that count as hits feel terrible.
The ceiling clamps instead of killing you, matching the real game. And a 0.6-second lockout after death, so the panicked tap that killed you does not instantly restart the run.
config holds constants and sprite-atlas coordinates, game holds the state
machine, physics, collision, and scoring, storage persists the best score,
render draws to the canvas, and app boots everything and owns the frame
loop. The last 2 are compiled only for wasm:
#[cfg(target_arch = "wasm32")]
mod app;
#[cfg(target_arch = "wasm32")]
mod render;
Each #[cfg] attribute gates the module declaration itself, so on any
target other than wasm32 the compiler never sees app or render at all.
storage has a wasm implementation over localStorage and a host stand-in
that returns 0 and drops writes. Everything else is plain Rust with no
web-sys in sight, so cargo test runs the entire simulation natively: no
browser, no headless anything. The crate builds as both cdylib and rlib
for exactly this reason.
13 unit tests cover the state machine, scoring exactly once per pipe, the death lockout, gap margins on spawned pipes, and the collision rules.
Pipe gaps come from a hand-rolled xorshift with a fixed seed. A rand crate for one stream of unit-interval floats was not worth the bytes, and the fixed seed makes the RNG test trivial: same seed, same sequence, 1000 values all in range.
Physics run on a fixed timestep, 120 steps per second, with the usual accumulator inside the requestAnimationFrame callback:
let dt = ((now - last) / 1000.0).min(0.25);
acc += dt;
while acc >= FIXED_DT {
game.borrow_mut().step(FIXED_DT);
acc -= FIXED_DT;
}
Each frame converts the elapsed milliseconds to seconds, adds them to acc,
and steps the simulation in fixed FIXED_DT slices until the accumulator is
spent. The .min(0.25) clamp matters more than it looks. Without it, a
backgrounded tab accumulates minutes of wall time, and the moment you come
back the loop fast-forwards the bird into the ground before the tab has
finished repainting.
Most of the unplanned time went into the atlas, because the port rendered the original’s sprite coordinates faithfully and they turned out to be wrong.
The bird frames are 3 sprites, 17x12 each, at x = 3, 31, 59 in row 491 of the 512x512 atlas. The 2017 code read 20x20 boxes on a 28-pixel stride starting at (0, 490), which grabs each frame plus a ring of its neighbors’ padding.
The ground is the striped 168x56 base strip at (292, 0), tiled horizontally with the tiles overlapping by a pixel so fractional scroll offsets do not leave a hairline seam. The original had been slicing a flat green band out of the background image instead, so the ground technically scrolled but you could not see it move.
pipe.png has structure the original ignored. It is 52x320: a 24-pixel cap
at full width, then a body inset 2 pixels per side. The old code stretched
the entire texture to whatever height the pipe needed, squashing the cap. The
port draws the cap at a fixed height, stretches only the body, and gets the
top pipe by mirroring the same sprite with a canvas transform, a
scale(1.0, -1.0) about the gap edge.
I ended up re-measuring every rect off the alpha channel of the PNG rather than trusting any number I had written down in 2017.
build.sh runs cargo, then wasm-bindgen, then wasm-opt if it is installed.
With opt-level = "z", LTO, panic = "abort", and symbols stripped, the
module comes out at 56 KB raw, 26 KB gzipped, plus 22 KB of wasm-bindgen JS
glue.
It deploys as a Cloudflare Worker whose script is a thin wrapper over the
static asset store. The Worker’s main job is forcing application/wasm on
the module; without that content type the browser silently drops from
streaming instantiation to buffering the whole file first. The built output
is committed, so the CI deploy is a checkout and a wrangler call, no Rust
toolchain in the workflow.
2 known gaps remain. The score draws with fillText instead of the atlas
digits: 2 through 9 appeared to sit in a regular grid when I measured, but I
never found 0 and 1 near them and stopped hunting. And there is no sound.
You can play it in the browser. The Go original
and the Rust port sit side by side
in the repo, the 2017 code
preserved unchanged in go/.
go/ and the Rust port beside itFor years bauer.gg was 1 Cloudflare Worker written by hand in the dashboard’s code editor. There was no repo; the source of truth was an editor pane in the Cloudflare dashboard. This post walks through what that Worker did, the move to Astro, how the resume became the typed center of the site, the first design system, and the deploy that made the repo the only source of truth.
The whole site was 1 fetch handler, with my resume sitting at the bottom of the file as a big object literal. Content negotiation keyed on the request’s Content-Type header, not Accept, so a browser got the resume pretty-printed and colored. So did curl, unless you claimed to be sending JSON.
The coloring was a single regex pass over the stringified resume. The Worker left no repo behind, so this is reconstructed from memory rather than quoted:
json.replace(
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
(match) => {
let cls = 'number';
if (/^"/.test(match)) {
cls = /:$/.test(match) ? 'key' : 'string';
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return `<span class="${cls}">${match}</span>`;
}
)
The regex matches 1 of 3 shapes: a quoted string, a true/false/null
literal, or a number. Every match defaults to class number; a leading quote
demotes it to string, or to key when a colon follows. Each match comes
back wrapped in a span.
5 CSS rules finished the job: strings green, numbers darkorange, booleans blue, null magenta, keys bold. That was the entire design system.
The Worker also kept a visitor counter in Workers KV, keyed on the raw client IP with no expiry. In retrospect, storing raw client IPs indefinitely was a data-retention problem, not a feature.
That held up fine as a resume endpoint. It had no answer for writing, and I had a Flappy Bird port I wanted to write about.
The new site is Astro 5 with the Cloudflare adapter, still deployed as 1 Worker. Every route is prerendered at build time to static assets; the Worker entry point exists because the adapter emits one, not because anything renders on demand.
The client-side JavaScript is a handful of small page-local scripts: the theme toggle, the resume page’s print button, the header mark’s animation, and the wasm-bindgen glue inside the /flappy embed.
The resume survived as the center of the thing. It lives in 1 typed data
file, src/data/resume.ts, that feeds both the HTML page at
/resume and the machine-readable JSON Resume.
The JSON endpoint is a single expression, with the headers object shortened here:
export const GET: APIRoute = () =>
new Response(JSON.stringify(resume, null, 2), { headers });
Astro prerenders this route to a static file at build time.
The old content negotiation is gone on purpose. Header sniffing made caching annoying and debugging worse, and 2 explicit URLs cost nothing.
The first design was a monospace document: 1 family, the system
ui-monospace stack with no webfonts, 1px borders, square corners, orange
used sparingly, and a light and dark palette. The landing page opened with an
ASCII-art banner in a pre tag instead of a hero image.
The comment at the top of global.css stated the goal: a document, not a
marketing site. Code blocks in posts got dual-theme Shiki highlighting,
github-light and github-dark-dimmed, flipped with the site theme.
The site has since been redesigned, so the page you are reading no longer looks like that. The monospace document was the first iteration.
Deploys are GitHub Actions on push to main: npm ci, astro build,
npx wrangler deploy. The API token lives in repo secrets; the account id
sits in wrangler.jsonc, since it is not a secret.
The first deploy was a one-way door worth pausing on. Wrangler overwrites the Worker of the same name, so the moment CI ran, the hand-edited dashboard Worker was gone and the repo became the only source of truth. That was the point.
The KV counter did not make the trip. Workers analytics answers the same question without storing anyone’s IP forever.
notjrbauer@bauer.gg
1 article