Ownership transfer prevents double-free and use-after-free

Rust's ownership system guarantees memory safety without garbage collection. Each value has exactly one owner, and when ownership is transferred (moved), the previous owner can't use it anymore. This prevents double-frees and use-after-free bugs at co

Add/remove nested fields with Stimulus (no cocoon)

Nested fields are a common Rails pain point, and the old solution was heavy JS gems. With Stimulus, I keep it minimal: render a hidden <template> containing the fields with a placeholder index, then on “Add” clone it and swap the placeholder for

Table-driven tests for HTTP handlers with httptest

Go’s table-driven tests are one of the best “boring but effective” practices. For handlers, I use httptest.NewRecorder and httptest.NewRequest so tests run fast without networking. Each case specifies method, path, body, expected status, and sometimes

Tailwind CSS with Rails asset pipeline

Tailwind CSS provides utility-first styling that pairs perfectly with Rails component-driven architecture. I configure Tailwind to scan templates for class names and generate only the CSS being used. The standalone CLI runs during development with --w

Retry on 429 with Retry-After parsing

Rate limits are normal in production; what matters is how clients behave when they hit them. Instead of hammering an upstream with immediate retries, I parse Retry-After (seconds) and sleep before retrying. I still keep an upper bound so one request d

std::process::Command for spawning external processes

std::process::Command runs external programs and captures their output. I use it for CLI tools that wrap other commands, build scripts, or integration tests. Methods like .arg(), .env(), and .current_dir() configure the process. .output() runs and wai

Turbo Frames modal: load, submit, then close via stream

A modal is just a frame boundary. Load the modal content into a dedicated frame, then on submit broadcast/stream a close action plus a list update. You get “SPA modal UX” without a frontend router.

Deadlock-Aware Retry Wrapper

Deadlocks happen under load. When the operation is safe to retry, rescue the deadlock exception and retry with jitter. Keep retries bounded and log when it happens.

Data archival and retention strategies

Data archival moves old data to cheaper storage. I use partitioning for time-based archival. Detach old partitions, export to S3, drop table. Archive tables store historical data with reduced indexes. Understanding retention policies prevents runaway

Rails Kredis for higher-level Redis operations

Kredis provides typed Redis structures as Active Model attributes, simplifying common patterns like counters, flags, and lists. Instead of raw Redis commands, I define kredis accessors on models that handle serialization automatically. Counters track

Database security and access control

Database security protects data from unauthorized access. I use GRANT/REVOKE for permissions—SELECT, INSERT, UPDATE, DELETE. Role-based access control groups permissions. Row-level security filters data per user. Column-level security restricts sensit

Deref and DerefMut for smart pointer ergonomics

Implementing Deref lets your type automatically coerce to its target type. For example, Box<T> derefs to T, and String derefs to str. This enables method calls and conversions without explicit unwrapping. I implement Deref for wrapper types and