Recipes
Step-by-step solutions for real development tasks.
699 published
Page 14 of 20
Review sudoers for Privilege Escalation Paths
Dump effective sudo rules per user, hunt wildcard and NOPASSWD grants that escape their intent, and tighten them with command argument pinning.
Roll Forward a Failed DB Migration
Prefer a corrective forward migration over a rollback when a schema change has already run, to avoid data-loss surprises.
Roll Back a Bad Deployment with kubectl rollout undo
Inspect revision history, undo to the last good revision by number, and verify the rollback actually landed by comparing live pod specs.
Roll Out a Content Security Policy via Report-Only
Deploy a strict CSP in report-only mode first, collect violation reports from real users, fix the causes, then enforce once reports fall silent.
Rotate a Live API Key Without Downtime
Issue a second key, deploy dual-key acceptance, shift traffic to the new key, then revoke the old one after a quiet observation window.
Rotate SSH Authorized Keys Safely
Roll SSH authorized keys with an overlap window so each operator can verify their new key before the old one is removed.
Run E2E Tests Against docker compose
Spin up the full stack with docker compose in CI, wait for readiness, run E2E tests, and tear everything down deterministically.
Run a Bulk Delete with a Checkpoint Table and Dry Run
Stage the doomed rows into a checkpoint table, review the dry-run count, delete in bounded batches, and keep an instant restore path.
Sanitize User-Submitted HTML with DOMPurify
Clean rich-text input on the server with a strict allow-list, keep hooks for URL schemes, and prove the result with XSS payload tests.
Scaffold Projects from Templates with Variable Substitution
Build a template directory with delimited placeholders, substitute values safely without regex injection, and verify the result compiles.
Scan Dependencies with OSV-Scanner
Scan lockfiles and container images for known vulnerabilities with OSV-Scanner and fail CI only on actionable findings.
Schedule an ECS Task with EventBridge
Run a periodic containerised job on a schedule with EventBridge rules and verify retries and logging.
Scrub PII from a Dataset with pandas
Detect and pseudonymise direct identifiers in a dataframe before sharing it with analysts.
Make Randomized Tests Reproducible with Seeds
Route all randomness through one seeded generator, print the seed on failure, and replay the exact failing sequence with one flag.
Set Statement Timeout per Role
Apply a default statement_timeout to reporting roles so a runaway query cannot monopolise connections and starve the pool.
Deploy from GitHub Actions Without Long-Lived Keys
Replace stored cloud credentials with OIDC federation, scope the trust policy to your repo and environment, and verify no secrets remain.
Shard Tests Across Parallel Databases for Speed
Give each test shard its own schema or database, run shards concurrently, and eliminate cross-test interference that serial runners hid.
Detect and Shrink a Bloated Postgres Table
Estimate dead tuple bloat with pgstattuple, reclaim space without exclusive locks using pg_repack, and verify the size actually dropped.
Shrink SQLite with Page Reclaim
Lower the page size and auto_vacuum settings to reclaim free pages and keep a local SQLite file compact between maintenance runs.
Sign and Verify Release Artifacts
Sign release binaries and container images with a keyless signature and verify them at deploy time to block tampered artifacts.
Design Skeleton Loading That Tells the Truth
Match skeleton geometry to the real content layout, avoid fake progress bars, and measure perceived completion against actual readiness.
Snapshot REST API Contracts
Capture normalised response snapshots for REST endpoints so unintended contract changes fail review instead of reaching clients.
Speed Up Bulk Inserts with COPY Instead of Row-by-Row
Replace thousands of single INSERT round trips with one COPY stream, measure the difference, and keep the loader resumable and idempotent.
Tune SQLite WAL Mode for Concurrent Readers and a Writer
Enable WAL journaling, set busy_timeout and synchronous pragmas, and prove readers keep working while a write transaction commits.
Standardize Timestamps and Timezones in a Dirty Dataset
Detect mixed formats and zone-less entries, normalize everything to UTC instants, and keep the original string alongside for audit.
Transform Gigabyte Files with Constant Memory Streams
Replace readFileSync loops with pipeline streams, apply backpressure-aware transforms, and verify output equivalence on a sample.
Stub Third-Party API Failures to Prove Client Resilience
Spin up WireMock with fault scenarios for latency, 500s, and 429 throttling, point the client at it, and prove retries, timeouts, and fallbacks actually work.
Template an Idempotent Ansible Role
Write an Ansible role that converges to the same state on repeated runs, using declarative modules instead of shell tasks.
Test Error Branches with Injected Failures
Inject dependency failures at call boundaries to exercise catch and fallback paths that normal runs never reach.
Test Graceful Shutdown Signal Handling
Assert that a service stops accepting new work, drains in-flight requests, and exits within the shutdown deadline on SIGTERM.
Trace API 429 Throttling Windows
Align 429 responses with rate-limit headers to reconstruct the client quota window and stop retries from extending the lockout.
Trace One Request Across Services with a Correlation ID
Propagate a single x-request-id through gateway, service, and job tiers, then stitch per-service logs into one timeline to find the slow hop.
Break a Slow HTTP Response into DNS, TLS, and Server Time
Use the curl write-out timer to split one slow request into name lookup, connect, TLS, time-to-first-byte, and transfer phases, then aim the fix at the right layer.
Track Deployments in Sentry to Correlate Errors with Releases
Send release events from CI, tag each deploy with git SHA and environment, and use release stats to catch error-rate regressions within minutes.
Track GraphQL Operation Usage to Find Abusive Queries
Fingerprint every GraphQL operation by name and hash, aggregate call counts and depth, and spot the one client sending giant or unbounded queries.
Transform CSV to NDJSON in a Stream
Convert a large CSV to newline-delimited JSON with a streaming reader and writer so memory stays flat regardless of file size.