Safer Time-Based Deletes with “mark then sweep”

Direct deletes can be risky and slow. Mark records for deletion, then sweep in batches in a maintenance job. This gives you observability and a rollback window.

Idempotency keys for “create” endpoints

Retries are inevitable: mobile clients, flaky networks, and load balancers will resend POST requests. Without idempotency you end up double-charging or double-creating records. I store an Idempotency-Key with a sha256 hash of the request body and the

Rails API-only app setup for React frontend

When building a React SPA, I configure Rails in API-only mode to skip view rendering, asset pipeline, and session cookies. The --api flag generates a lean Rails app focused on JSON responses. I enable CORS to allow the React dev server on localhost:51

Django timezone-aware datetime handling

Django stores datetimes as UTC in the database when USE_TZ=True. I use timezone.now() instead of datetime.now() to get aware datetimes. The timezone.localtime() converts UTC to user's timezone for display. For user input, I use timezone.make_aware() t

Virtual scrolling for large lists with react-window

Rendering thousands of list items kills performance. Virtual scrolling renders only visible items plus a buffer, dramatically reducing DOM nodes. The react-window library provides FixedSizeList and VariableSizeList components that handle viewport calc

Custom error types with thiserror for domain errors

For production code, I define custom error enums using thiserror. It auto-derives Display and Error trait implementations, making errors self-documenting and composable. Each variant can wrap underlying errors (#[from]) for automatic conversion with ?

Request spec: Turbo Stream template is rendered

For controller-level confidence, I add a request spec that sets Accept: text/vnd.turbo-stream.html and asserts the response includes a turbo stream action. This is faster than a system test and catches accidental template name changes (create.turbo_st

GitHub Actions: cache + tests + build

CI has to be fast enough that developers don’t bypass it. I cache npm’s package store so we’re not re-downloading the world every run, and I split lint / test / build into separate steps so failures are obvious and logs are readable. The other non-neg

Database query explain analysis for optimization

Understanding query execution plans is essential for optimizing slow queries. Rails provides explain method on ActiveRecord relations to show PostgreSQL's query planner output. I look for sequential scans on large tables (indicating missing indexes),

AsRef and AsMut for flexible function parameters

AsRef<T> is a trait for cheap reference-to-reference conversion. It's commonly used in function parameters to accept multiple types. For example, a function taking impl AsRef<Path> can accept &Path, PathBuf, &str, or String. This i

Shell scripting for DevOps automation

Shell scripts automate repetitive DevOps tasks like deployments, backups, and health checks. I use #!/bin/bash with set -euo pipefail for strict error handling—-e exits on error, -u errors on undefined variables, -o pipefail catches pipe failures. Fun

Kubernetes Helm charts for package management

Helm is the package manager for Kubernetes, bundling manifests into reusable charts. A Chart.yaml defines chart metadata and dependencies. values.yaml provides default configuration that users can override. Templates in the templates/ directory use Go