Skip to Content
Skip to content
Tutorials

Programming Tutorials

Standalone programming tutorials for solving one specific problem at a time. Each guide starts with the exact error message, failing behavior, or design constraint, gives you a minimal reproducible script or query, and walks through the fix with real output.

Pick a language below or filter by topic and difficulty when you need a quick, practical reference you can test locally and apply right away.

SQL
Find and Fix a Deadlock Level: Advanced

Reproduce a deadlock between two money transfers, read the message, and fix it by locking rows in the same order.

SQL
Process a Job Queue With SKIP LOCKED Level: Advanced

Let two workers take different jobs from one table with FOR UPDATE SKIP LOCKED, and see what happens to a job when a worker fails.

SQL
Add a NOT NULL Column to a Big Table Without Downtime Level: Advanced

Add a NOT NULL column to a big table with a constant default, or with a nullable column, a batch backfill, NOT VALID and VALIDATE.

SQL
Walk a Tree With a Recursive CTE Level: Advanced

Walk down an employee tree, walk up to the top, count each manager's team and guard the query against a loop with CYCLE.

SQL
Back Up With pg_dump and Prove the Restore Works Level: Advanced

Take a pg_dump backup in Docker, restore it into a scratch database, compare the tables and see what a damaged backup looks like.

Go
Fix "assignment to entry in nil map" in Go Level: Beginner

Reproduce Go's nil map panic, initialize maps with make or literals, and guard struct map fields safely. After this, map writes never crash on zero-value structs.

Go
Why Go append Mutates Another Slice (and How to Stop It) Level: Beginner

See why two Go slices overwrite each other after append and prevent it with full-slice expressions or slices.Clone.

Go
Why Unexported Go Struct Fields Stay Empty in encoding/json Level: Beginner

Fix Go structs that decode to zero values in json.Unmarshal and catch misspelled JSON keys with DisallowUnknownFields.

Go
Test a Go net/http Handler Without Starting a Server Level: Beginner

Use net/http/httptest to send JSON requests, check status codes, and test validation paths in memory. After this, you can test HTTP handlers in milliseconds without opening a port.

Go
Compile a Static Go Binary Under 10 MB Level: Beginner

Compare default go build output against CGO_ENABLED=0 with -trimpath and -ldflags="-s -w", and check shared library links with ldd.

Go
Find and Fix Go Data Races With -race Level: Advanced

Trigger a real data race under go test -race, read the race detector output, and fix shared counters, maps, and slice writes using atomic, sync.Mutex, and disjoint indices.

Go
Benchmark Speed and Heap Allocations With go test -bench -benchmem Level: Advanced

Measure nanoseconds and heap allocations with testing.B and -benchmem, compare += vs strings.Builder, pre-size slices, and reuse buffers with sync.Pool.