Recipes
Step-by-step solutions for real development tasks.
699 published
Page 4 of 20
Switch from Offset to Cursor Pagination
Use a cursor based on the last item's sort key so page 2 does not skip or duplicate items when new data arrives between requests.
Shard Tests Across CI Runners for Speed
Split the test suite into N shards by historical duration so all runners finish at the same time instead of one straggler.
Partition a Large Table by Date for Pruning
Partition by month so a query on the last 30 days scans one partition not the entire years of history.
Hash Passwords with Argon2id Tuned Parameters
Use Argon2id with memory and iteration parameters tuned to the hardware so offline cracking takes years not hours.
Guarantee Drain Safety with a Pod Disruption Budget
Set a Pod Disruption Budget so a voluntary drain like a node upgrade cannot evict the last replica and cause downtime.
Set Pipeline Artifact Retention by Type
Configure artifact retention rules so build outputs expire after 14 days but signed releases are kept for a year.
Use Restore Keys for Fallback Cache Matching
Configure cache restore keys so a partial key match still reuses a previous cache when the exact key misses.
Notify On-Call on Pipeline Failure with Context
Send a structured notification with the failing job, logs link, and last commit when a critical pipeline fails.
Route Jobs to Runners by Label
Assign runner labels so GPU jobs go to GPU runners and lint jobs go to the cheapest available runner.
Scan for Secrets Leaked in Pipeline Output
Add a secret scanning step that checks build logs and artifacts for leaked tokens before publishing.
Skip Heavy Jobs When Only Docs Changed
Use dorny paths-filter to detect doc-only changes and skip compilation and test jobs to save runner time.
Set a Pipeline Timeout Budget per Stage
Configure per-job timeouts so a hung step fails fast instead of burning runner minutes for the default six hours.
Enforce Pod Security Standards at Admission
Apply a restricted Pod Security Standard at the namespace level so privileged containers are rejected by the API server.
Spread Pods Across Zones with Topology Constraints
Add a topologySpreadConstraint so a zone failure takes down at most one replica not the whole deployment.
Use a Blameless Postmortem Template for Incidents
Fill a structured template with timeline, root cause, impact, and action items so the postmortem focuses on systems not people.
Precompute Aggregates in a Materialized View
Store the daily sum in a materialized view refreshed nightly so the dashboard query reads one row instead of scanning a million.
Prefetch Route Data on Link Hover
Add a mouseenter listener that prefetches the next route's data so navigation feels instant on click.
Automate Privacy Impact Assessment Checks
Run a data flow analysis so a new field that contains PII is flagged for review before it is added to the schema.
Add Property-Based Testing with fast-check
Replace hand-written examples with property-based generators that explore the input space and shrink failures to a minimal counterexample.
Detect N+1 Queries with an ORM Logger
Enable query logging in tests so a list endpoint that fires one query per item is visible in the log and fixed with a join.
Analyze a Slow Query Plan with EXPLAIN
Run EXPLAIN ANALYZE on the slow query so the plan shows whether it is a sequential scan, a bad join, or missing index.
Rate Limit with a Redis Token Bucket
Implement a token bucket in Redis so distributed rate limiting works across multiple instances with atomic decrements.
Pool Database Connections with RDS Proxy
Put an RDS Proxy between Lambda and the database so connection opens are pooled and a Lambda spike does not exhaust DB connections.
Guarantee Read-After-Write Consistency
Route reads from the same session to the primary or use a causal token so a user sees their own write immediately.
Route Reads to a Replica and Writes to Primary
Split the connection so read-heavy endpoints hit the replica and the primary is reserved for writes, cutting read latency by half.
Respect prefers-reduced-motion for Animations
Disable or shorten animations when the user sets reduce-motion so vestibular sensitivity is respected not ignored.
Monitor Replication Lag and Alert on Threshold
Query the replication lag and alert when it exceeds 5 seconds so a stale read replica does not serve outdated data.
Require Status Checks Before Merge with Strict Mode
Enable branch protection with strict status checks so a pull request cannot merge if any required check is pending or failing.
Rightsize Resource Requests from Metrics
Read the 95th percentile CPU and memory from metrics and set requests to p95 so pods are not throttled or over-provisioned.
Serve Responsive Images with srcset Sizes
Provide srcset with 480, 800, and 1200 widths so the browser downloads the smallest image that fills the viewport.
Retry with Exponential Backoff and Full Jitter
Add full jitter to the backoff so retries spread across time and do not synchronize into a retry storm on recovery.
Compose Reusable Workflows to Share CI Logic
Extract repeated CI steps into a reusable workflow so consumer repos call it with one line instead of duplicating YAML.
Tune Rolling Update Max Surge for Capacity
Set maxSurge to 1 and maxUnavailable to 0 so updates add a new pod before removing an old one and capacity never drops.
Show Route Transitions with Suspense Boundaries
Wrap each route in a Suspense boundary with a fallback spinner so navigation shows a skeleton instead of a blank flash.
Fail Over DNS with Route53 Health Checks
Configure a health check on the primary and a failover record so traffic routes to the standby within 30 seconds of failure.
Tier S3 Objects with Lifecycle Rules
Transition objects to Infrequent Access after 30 days and Glacier after 90 so storage costs drop without deleting data.