ETag handling for conditional GETs (cheap caching)

ETags are a low-effort way to cut bandwidth and CPU when clients poll for resources that rarely change. The server computes an ETag for the representation (often a version, content hash, or updated_at value) and compares it to If-None-Match. If they m

Hotwire-friendly “sort by” links that replace only the list

Sorting is a great candidate for Turbo Frames: clicking “Newest” shouldn’t reload your whole page shell. I wrap the list in a frame (e.g., id='results') and make sort links target that frame. The controller reads params[:sort] and applies an order sco

Atomic “Read + Mark Processed” with UPDATE … RETURNING

If you have a queue table, avoid races by selecting and updating in one statement. Postgres UPDATE … RETURNING is the simplest building block for a correct custom queue / maintenance pipeline.

Turbo Streams: swap a button state and counter in one response

A “follow” button usually needs two updates: the button label/state and the follower count. Turbo Streams make this trivial because one server response can carry multiple DOM operations. I render both UI pieces as partials with stable targets (dom_id(

Docker fundamentals: images, containers, and layers

Docker packages applications into lightweight, portable containers. A Dockerfile defines build instructions—each instruction creates an immutable layer. The FROM directive sets the base image. COPY and ADD bring files into the image. RUN executes comm

Database-Backed Unique Slugs with Retry

Slug generation is deceptively racy under concurrency. Use a unique index plus retry with a suffix. Keep it deterministic and fast; don’t query in a loop without bounds.

Material Design 3 theming

Material Design 3 (Material You) brings dynamic theming to Android. I define color schemes with primary, secondary, tertiary colors and their variants. MaterialTheme composable wraps the app with colorScheme, typography, and shapes. Dynamic colors use

Rails service objects for business logic

Service objects encapsulate complex business logic that doesn't belong in models or controllers. Each service performs one operation, like creating a post with side effects, processing a payment, or importing data. I create services in app/services wi

Django select_for_update for database locking

select_for_update() locks rows until transaction completes, preventing race conditions. I use it for operations requiring read-modify-write atomicity like decrementing stock or updating counters. The lock is released on transaction commit/rollback. Fo

Stimulus controller for autosaving form drafts

Losing form data due to browser crashes or accidental navigation is frustrating. An autosave controller periodically saves form state to localStorage and restores it on page load. I debounce the save operation to avoid excessive writes and clear the d

Front-end security - XSS and CSRF prevention

Front-end security protects users from malicious attacks. I prevent Cross-Site Scripting (XSS) by sanitizing user input and using textContent instead of innerHTML. Content Security Policy (CSP) headers restrict resource loading to trusted sources. Cro

HashiCorp Vault for secrets management in Kubernetes

Integrate HashiCorp Vault with Kubernetes for dynamic secrets management. Use the Vault Agent sidecar injector to automatically inject secrets into pods, configure KV secret engines, and set up Kubernetes authentication. Eliminate hardcoded secrets fr