Recipes

Step-by-step solutions for real development tasks.

699 published

Page 10 of 20

Audit Missing Security Headers

Scan responses for missing HSTS, CSP, X-Content-Type-Options, and frame protections, then fix them with a middleware.

~30 min
security · http · hardening

Audit and Constrain npm Install Scripts in Your Supply Chain

Enumerate which dependencies declare lifecycle scripts, run installs with scripts disabled, and gate the exceptions you truly need.

~30 min
security · supply-chain · npm

Audit PostgreSQL Unused Indexes

Use pg_stat_user_indexes to find indexes that are never scanned, then drop them safely after confirming they are not unique constraints.

~35 min
postgresql · database · performance

Automate Blue-Green DNS Cutover

Switch traffic between blue and green stacks by updating DNS with a low TTL and verifying health before and after the cutover.

~35 min
dns · ops · deployment

Automate Certificate Renewal with a Deploy Hook

Configure certbot renewals with dry runs, a deploy hook that reloads the right service, and monitoring that alerts when renewal stops happening.

~20 min
deploy · tls · automation

Backfill a Warehouse Partition Safely

Backfill a single partition in place with an atomic swap so queries see either the old or the new data, never a partial mix.

~35 min
data · warehouse · operations

Batch Network Calls Without Losing Latency

Coalesce many small requests into fewer batched calls using a short scheduling window to cut round-trip overhead.

~35 min
performance · networking · javascript

Block SSH Brute Force with fail2ban

Match auth failures with a jail, ban repeat offenders with iptables or nftables, whitelist your own networks, and verify with a test ban.

~25 min
security · ssh · operations

Block Unnecessary Outbound Egress

Apply a default-deny egress policy so a compromised workload cannot reach arbitrary hosts on the internet.

~35 min
kubernetes · security · network

Blue-Green Switch with Cloudflare Workers

Route a portion of traffic between two origins using a Worker and shift weight programmatically to enable instant rollback.

~40 min
cloudflare · ops · deployment

Build argparse Subcommands

Structure a Python CLI with subparsers so each command has its own arguments and a shared top-level parser.

~30 min
cli · python · argparse

Build Interactive CLI Prompts with Validation and Safe Defaults

Ask questions only when arguments are absent, validate answers in the loop, and make non-interactive mode the escape hatch that always works.

~30 min
cli · developer-experience · nodejs

Bulk Upsert Thousands of Rows with ON CONFLICT in PostgreSQL

Stream rows through COPY or multi-row INSERT with ON CONFLICT DO UPDATE, avoiding per-row round trips and deadlocks from unordered writes.

~30 min
database · postgresql · bulk-operations

Cache API Responses in a Service Worker

Apply a stale-while-revalidate strategy in a service worker so repeat visits render instantly and refresh in the background.

~35 min
frontend · caching · service-worker

Cache Serialization with MessagePack

Swap JSON for MessagePack in a hot cache path to cut serialization CPU and payload size without changing semantics.

~30 min
performance · caching · serialization

Capture gRPC DEADLINE_EXCEEDED Traces

Instrument a gRPC client to surface deadline budgets and server spans so DEADLINE_EXCEEDED can be traced to the slow dependency.

~40 min
grpc · observability · debugging

Catch a Retry Storm by Capturing Packets with tcpdump

Capture retransmissions and connection churn at the NIC level, correlate them with application retry counters, and size backoff correctly before disabling retries.

~35 min
api · networking · reliability

Debug Webhook HMAC Signature Mismatch

Compare the raw request body bytes used for HMAC signing against the bytes received, catching re-serialisation and encoding drift.

~30 min
webhook · security · debugging

Catch Breaking OpenAPI Changes Before Release with oasdiff

Diff two OpenAPI documents with oasdiff in CI, fail the build on removed fields or narrowed types, and publish a human-readable changelog for review.

~25 min
api · openapi · ci

Choose Between Mocks, Stubs, and Fakes Deliberately

Pick test doubles by the question each test answers: stubs for state setup, mocks for interaction verification, fakes for realistic behavior.

~25 min
testing · unit-testing · design

Update a Huge Table in Safe Chunks

Rewrite millions of rows without a giant transaction by chunking on a key, committing per batch, tracking progress, and resuming after interruption.

~40 min
database · postgres · operations

Clone PostgreSQL Schema Without Data

Use pg_dump schema-only output to scaffold a staging database that matches production structure for safe query planning tests.

~25 min
postgresql · database · testing

Colorize CLI Output with ANSI Codes

Add ANSI colour to CLI output only when the stream is a terminal and NO_COLOR is unset, respecting user preference.

~20 min
cli · terminal · ux

Compare MySQL Query Plans Before and After an Index

Use EXPLAIN ANALYZE to measure real row counts and timing per step, then prove an index actually changed the plan instead of guessing.

~25 min
database · mysql · performance

Configure Docker Container Log Rotation Before It Fills the Disk

Set json-file log driver rotation options per container or daemon-wide, verify max-size and max-file take effect, and alert on remaining disk.

~20 min
deploy · docker · operations

Configure SSH Bastion Jumps and Connection Multiplexing

Centralize jump-host access with ProxyJump, reuse connections with ControlMaster, and keep per-host keys instead of a shared bastion credential.

~20 min
deploy · ssh · operations

Harden a systemd Service Against Crashes and Reboots

Set Restart, watchdog, and resource limits on a systemd unit so crashes self-heal, hangs get killed, and boot ordering is explicit.

~25 min
deploy · linux · operations

Configure External Uptime Probes That Users Agree With

Probe from outside the datacenter on the real user path, alert on consecutive failures with downtime tracking, and page on the right severity.

~25 min
deploy · observability · operations

Convert a Large Table to Partitions Online

Attach a partitioned twin, dual-write or replicate into it, backfill by range, and swap names in one transaction with minimal lock time.

~60 min
database · postgres · operations

Debounce Search Input Without Losing Keystrokes or Requests

Debounce the expensive effect, not the input value, cancel in-flight requests on new input, and keep every keystroke responsive.

~25 min
frontend · react · ux

Debounce ResizeObserver Layout Work

Throttle layout work triggered by ResizeObserver so rapid resizes do not thrash the main thread.

~25 min
frontend · performance · javascript

Debug API Payload Schema Rejection

Reproduce a 422 payload rejection and use schema validation diagnostics to find the exact property path that fails.

~25 min
api · validation · debugging

Debug Cache Variation Leaks Between Users

Prove that a shared cache is serving one user personalized response to another by testing with two identities, then fix the missing Vary header.

~25 min
api · caching · security

Debug a Failing CORS Preflight with curl

Reproduce an OPTIONS preflight by hand with curl, read the Access-Control-* response headers, and fix the exact header the browser is complaining about.

~20 min
api · cors · debugging

Debug CSS Specificity Wars with the Cascade Layers Toolbox

Identify which rule actually wins and why, quantify specificity instead of guessing, and end arms races with layers and :where.

~25 min
frontend · css · maintainability

Debug GraphQL Persisted Query Misses

Resolve persisted-query-not-found errors by checking the APQ hash registry and hash generation between client and server.

~30 min
graphql · api · debugging