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.

~25 min
cli · shell · reliability

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.

~30 min
frontend · accessibility · keyboard

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.

~25 min
security · authentication · crypto

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.

~45 min
performance · java · jvm

Tune a PodDisruptionBudget minAvailable

Set a disruption budget that protects availability during drains without blocking voluntary disruptions entirely.

~25 min
kubernetes · reliability · ops

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.

~45 min
mysql · database · performance

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.

~40 min
performance · nodejs · memory

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.

~30 min
database · postgres · operations

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.

~35 min
deploy · kubernetes · operations

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.

~30 min
performance · rust · build

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.

~35 min
testing · concurrency · unit-testing

Vacuum SQLite Safely Offline

Reclaim SQLite space with VACUUM INTO and swap the compacted file atomically to avoid blocking a live application.

~30 min
sqlite · database · maintenance

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.

~25 min
security · tls · openssl

Validate JSONL with Expectation Suites

Define expectation suites over a JSONL dataset to catch missing fields and range violations before loading a warehouse.

~35 min
data · quality · validation

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.

~30 min
security · cookies · csrf

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.

~35 min
testing · database · transactions

Verify Helm Values Override Precedence

Render charts with multiple values files to confirm the final merged values match the intended precedence before release.

~20 min
helm · kubernetes · ops

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.

~45 min
testing · contract-testing · ci

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.

~30 min
api · rate-limiting · load-testing

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.

~20 min
database · sqlite · backup

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.

~35 min
testing · isolation · ci

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.

~25 min
docker · ops · deployment

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.

~40 min
frontend · react · virtualization

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.

~40 min
testing · property-based · fast-check

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.

~30 min
testing · unit-testing · resilience

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.

~30 min
cli · shell · automation

Test Access Control as a Matrix

Enumerate role, ownership, and tenant combinations, assert 401 versus 403 versus 404, and catch broken object-level authorization.

~35 min
testing · security · 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.

~45 min
iam · access-control · compliance

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.

~30 min
testing · api · fuzzing

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.

~30 min
argocd · gitops · release

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.

~25 min
supply-chain · github-actions · provenance

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.

~40 min
audit · postgresql · compliance

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.

~30 min
backups · encryption · security

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.

~30 min
kubernetes · deployment · release

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.

~25 min
docker · ci · caching

Attach Build Provenance to Release Artifacts

Generate a signed SLSA provenance attestation in GitHub Actions and verify it before deploying the container image.

~35 min
supply-chain · ci · security