Hello, and a stack smoke test

The first post on this blog, which exists mainly to prove that code blocks, math and diagrams all render the way they should.

This is a placeholder post. It exists so the build has something to chew on, and so every part of the rendering pipeline gets exercised at least once. Delete it once there’s a real post to replace it.

Code blocks

Go, with a filename title and a highlighted line:

worker.go
func worker(jobs <-chan Job, results chan<- Result) {
for job := range jobs {
results <- process(job)
}
}
// The unbuffered send above is where the goroutine parks.

TypeScript, with diff markers:

cache.ts
export function memoize<A, R>(fn: (arg: A) => R) {
const cache = new Map<A, R>();
return (arg: A) => cache.get(arg) ?? fn(arg);
return (arg: A) => (cache.has(arg) ? cache.get(arg)! : set(cache, arg, fn(arg)));
}

Shell output, which should not be highlighted as code:

$ go test -bench=. -benchmem
BenchmarkProcess-10 1284517 931.2 ns/op 248 B/op 3 allocs/op

Math

Inline first: a balanced binary search tree gives O(logn)O(\log n) lookups, and the usual argument for why a heap’s push is cheap amortized runs through the recurrence below.

T(n)=2T ⁣(n2)+O(n)    T(n)=O(nlogn)T(n) = 2T\!\left(\frac{n}{2}\right) + O(n) \implies T(n) = O(n \log n)

Diagrams

Mermaid source in the post, rendered to inline SVG at build time, so readers download no JavaScript for it:

jobs

Producer

Buffered channel

Worker 1

Worker 2

Results

What isn’t here

Interactive islands. Those arrive per-post: rename the file to .mdx, import a Preact component, and give it a client:visible directive.