Recipes
Step-by-step solutions for real development tasks.
699 published
Page 12 of 20
Find the Hot Path in Node with a CPU Flame Graph
Capture a sampling profile under load, read the flame graph width-first to find the widest frames, and verify the fix with a second capture.
Flatten Nested JSON Arrays into Queryable Rows
Unwind arbitrary-depth arrays into flat rows with jq or Node streaming, keeping parent context and path provenance on every record.
Fuzz a JSON Parser with Property Tests
Generate random and adversarial inputs to assert your JSON handling never crashes and always round-trips valid documents.
Deduplicate Fuzzy-Matched Records Without Losing Real Rows
Generate similarity-scored candidate pairs, review the match threshold with humans, and merge duplicates through an auditable, reversible process.
Gate Deployment on a Smoke Test Suite
Run a fast post-deploy smoke suite that exercises critical paths and blocks promotion when any check fails.
Generate Realistic Test Data with Faker
Produce a million-row dataset with believable distributions, seeded reproducibility, and referential integrity, then load it with COPY.
Handle SIGINT Cleanup in a CLI
Trap interrupt signals to remove temporary files and flush progress so Ctrl-C does not leave a broken state.
Audit and Harden sshd Configuration
Disable password and root login, restrict algorithms to current best practice, verify with ssh -Q and a controlled restart, and keep an escape session open.
Harden TLS Cipher Suites
Restrict a server to modern TLS versions and strong ciphers, then verify with a scanner and client handshake tests.
Harden a Base Image with Non-Root User and Read-Only Rootfs
Run containers as a dedicated UID with a read-only root filesystem, writable tmpfs mounts, and dropped capabilities verified by a breakout attempt.
Hunt Down idle in transaction Sessions in PostgreSQL
Find sessions holding a transaction open while doing nothing, measure their age and lock footprint, and close the leak at the application layer.
Hydrate Islands Progressively
Hydrate interactive components on idle or on visibility so static content is interactive without blocking the main thread.
Implement CLI Config Precedence
Define a clear precedence of flags over environment over config file over defaults so behaviour is predictable.
Implement Progressive Delivery Steps
Roll out a change in controlled increments with automated analysis between steps so a bad release is caught early.
Implement Webhook Signature Verification That Handles Time
Verify HMAC signatures with constant-time comparison, reject timestamps outside a tolerance window, and block replayed delivery ids.
Build an Incremental ETL Load with a Watermark Column
Track a monotonically increasing watermark, copy only rows past it, and make the job restartable by advancing the mark transactionally.
Inspect and Defragment etcd Safely
Check etcd database size and fragmentation, then defragment one member at a time with a backup first.
Inspect HTTP Cache Vary Header Mismatch
Detect a missing or wrong Vary header that serves one user language or encoding to another through a shared cache.
Inspect HTTP Keep-Alive Timeout Resets
Use packet capture to prove whether intermittent connection resets come from idle keep-alive timeouts on a proxy or the origin server.
Inspect WebSocket Frames with websocat
Connect to a live WebSocket endpoint with websocat, send handcrafted frames, watch server pushes arrive, and diagnose protocol issues the browser hides.
Instrument Unit Tests with a Coverage Threshold
Enable coverage instrumentation and set an enforceable threshold so new code cannot merge below the agreed bar.
Isolate HTTP 502 Upstream Reset
Correlate gateway access logs with upstream connection resets to prove which backend instance is closing connections early.
Lazy-Load Route Chunks in Vite
Split routes into dynamic imports so the initial bundle stays small and heavy views load on demand.
Diagnose Container CPU Throttling
Read cgroup throttling counters to prove whether a container's latency comes from CPU limits rather than slow code.
Manage Focus After SPA Navigation
Move focus to the new view heading on client-side navigation so keyboard and screen-reader users are not stranded.
Measure PostgreSQL Index Bloat
Use pgstattuple and statistics to estimate index bloat and decide whether a REINDEX is worth the lock cost.
Measure TLS Handshake Overhead and Session Reuse
Time full versus resumed TLS handshakes with curl and openssl, quantify the certificate chain cost, and decide where connection reuse pays off.
Merge Multiple Parquet Files Safely
Consolidate many small Parquet files into fewer larger ones to cut metadata overhead and improve scan efficiency.
Migrate a Runtime Image to Distroless Safely
Shrink the attack surface by moving from a full base image to distroless, keeping debug shells reachable via a separate debug tag, and verify in CI.
Mine Access Logs for Status and Latency Anomalies
Turn nginx or app access logs into ranked tables of error rates, slow paths, and suspicious clients using only jq, awk, and sort.
Mock Time with Sinon Fake Timers
Control time in tests with fake timers so debounce, retry, and timeout logic is deterministic instead of flaky.
Measure Node Event Loop Delay Before Blaming the CPU
Track lag between scheduled and actual timer execution, correlate spikes with request logs, and find the synchronous code responsible.
Build Multi-Architecture Images with buildx
Build and push amd64 and arm64 variants in one command so the same tag runs on mixed clusters.
Turn a Full Table Scan into a Covered Query in MySQL
Confirm the scan with EXPLAIN, design a composite covering index, and verify Extra shows Using index so the query never touches the row.
Reload nginx Without Dropping Connections
Use nginx -s reload with correct worker shutdown settings, verify old workers drain, and confirm zero 502s during configuration changes.
Optimize Array Deduplication with a Set
Replace O(n squared) deduplication loops with a hash set so large arrays dedupe in linear time.