Recipes
Step-by-step solutions for real development tasks.
699 published
Page 15 of 20
Guarantee Cleanup Runs When a Shell Script Exits
Install EXIT and signal traps that release locks, remove temp files, and kill child processes on success, failure, and Ctrl-C alike.
Trap Focus Correctly in a Modal Dialog
Move focus in on open, cycle Tab inside the dialog, return focus on close, and handle background scroll and screen-reader announcement.
Tune Argon2id Password Hashing Parameters
Pick memory, iterations, and parallelism from your hardware budget and target latency, then verify the choices against both login UX and attack cost.
Tune JVM G1 Heap Regions
Adjust G1 region size and pause target to cut GC pauses on a heap that is too large for the default region count.
Tune a PodDisruptionBudget minAvailable
Set a disruption budget that protects availability during drains without blocking voluntary disruptions entirely.
Benchmark MySQL InnoDB Flush Settings
Measure write throughput at different innodb_flush_log_at_trx_commit levels and pick the safest setting that meets the durability target.
Tune Node Heap and GC Settings from Evidence
Chart heap usage and GC pause times across load, identify premature promotion and oversized young generation, then set flags deliberately.
Tune Autovacuum for a High-Churn Table
Watch dead tuples accumulate, compute the actual churn rate, set per-table scale factors and cost limits, and verify bloat stays flat.
Tune Kubernetes Rolling Updates for Zero Downtime
Set maxSurge, maxUnavailable, readiness gates, and preStop sleep so pods replace each other without serving a single failed request.
Tune a Rust Release Profile for Throughput
Enable LTO and codegen tuning in the release profile to improve runtime throughput at the cost of build time.
Write Tests That Actually Catch Concurrency Races
Use stress loops, synchronization barriers, and race detectors to make latent races fail deterministically in the test suite.
Vacuum SQLite Safely Offline
Reclaim SQLite space with VACUUM INTO and swap the compacted file atomically to avoid blocking a live application.
Validate a TLS Certificate Chain with openssl Only
Hand-verify the served chain, intermediate match, expiration, and hostname coverage before blaming the app for handshake failures.
Validate JSONL with Expectation Suites
Define expectation suites over a JSONL dataset to catch missing fields and range violations before loading a warehouse.
Verify SameSite Cookie Behavior Across Browsers
Set deliberately misconfigured SameSite cookies in a test page, observe which requests carry them, and prove the hardening actually blocks cross-site sends.
Verify Database Transaction Rollback
Assert that a failed multi-step write leaves no partial state, using a real database in the test rather than mocks.
Verify Helm Values Override Precedence
Render charts with multiple values files to confirm the final merged values match the intended precedence before release.
Verify Provider Contracts with Consumer-Driven Pact
Publish consumer expectations as pacts, verify the provider against them in CI, and break the build on any contract drift before deploy.
Verify Rate Limiting Holds Under a Burst of Concurrent Requests
Prove that an express-rate-limit middleware actually throttles by firing concurrent bursts, checking 429 headers, and counting admitted versus rejected requests.
Verify SQLite Database Integrity Before and After Backup
Run integrity_check on the source, take an online backup with the backup API instead of copying the file, and verify the copy row-for-row.
Prove Test Isolation with Random Order Execution
Run the suite under shuffled orders and multiple seeds, identify tests that leak state into siblings, and fix the leak at the source.
Version Container Images with the Git SHA
Tag images with immutable commit SHAs and digest digests so deployments reference an exact artifact rather than a moving tag.
Virtualize a 10,000-Row List Without Breaking Search or Scroll
Render only the visible window plus overscan, restore scroll position on navigation, and keep typeahead search working against the full dataset.
Write Custom Arbitraries for Business Rules
Move property tests beyond primitives by composing fast-check arbitraries for money, date ranges, and entity graphs that respect invariants.
Write Unit Tests for Error Paths First
Inventory failure modes per dependency, force each one in a test, and assert the observable behavior users see when things go wrong.
Write Shell Scripts That Are Safe to Run Twice
Make setup and deploy scripts idempotent: guard file creation, detect prior success, and structure mutations so reruns converge instead of duplicate.
Test Access Control as a Matrix
Enumerate role, ownership, and tenant combinations, assert 401 versus 403 versus 404, and catch broken object-level authorization.
Run a Quarterly Access Review
Generate an IAM credential report, flag unused keys and administrator roles, and record reviewer sign-off before the due date.
Fuzz the API Against Its OpenAPI Schema
Drive Schemathesis from the OpenAPI document, skip destructive endpoints, and turn every unexpected 500 into a regression test.
Block Argo CD Syncs During a Release Freeze
Use sync windows to deny automatic syncs during a freeze while still allowing audited manual syncs for real emergencies.
Attest Release Archives and Verify Before Deploy
Sign a build artifact with GitHub attestations, then verify its digest and source ref in the deploy job so a swapped archive never ships.
Export Database Audit Logs to Object Storage
Enable pgaudit for DDL and role changes, ship the log stream to object storage, and keep tamper-resistant copies for compliance review.
Encrypt Backups Before Uploading
Encrypt database dumps with age recipients before they leave the host, keep the identity offline, and prove decryption during a restore test.
Switch Traffic with a Blue-Green Service Cutover
Run the new version beside the old one, flip the Service selector in one step, and keep the old ReplicaSet warm for an instant rollback.
Share a Docker Build Cache Across CI Runs
Use the GitHub Actions cache backend for BuildKit so image rebuilds reuse layers instead of reinstalling dependencies every run.
Attach Build Provenance to Release Artifacts
Generate a signed SLSA provenance attestation in GitHub Actions and verify it before deploying the container image.