Guard Rails for Dangerous Admin Actions

Admin actions are production sharp edges. Require a typed confirmation string, log actor + request_id, and run the dangerous work in a background job. This reduces accidental incidents.

Error wrapping that stays inspectable with errors.Is and errors.As

In production, you want errors that are both human-readable and machine-checkable. I wrap errors with %w so callers can still match them using errors.Is and errors.As. This avoids string comparisons like if err.Error() == ..., which break on refactors

Laravel API resources for JSON transformation

API resources transform Eloquent models into JSON responses with full control over structure and data exposure. I create resource classes that extend JsonResource and define a toArray() method returning the desired JSON structure. Resources hide sensi

Django database migrations best practices

Migrations track database schema changes. I use makemigrations after model changes and review generated migrations. For data migrations, I create empty migrations with makemigrations --empty and write RunPython operations. I test migrations on dev dat

Modern CSS features: container queries and :has() selector

Container queries enable responsive components based on container size using @container at-rule. I set container-type: inline-size to create query containers. The @container (min-width: 400px) queries container width instead of viewport. Named contain

Morphing page refreshes with turbo_refreshes_with

When a page has lots of dynamic pieces but I still want “just refresh it” semantics, I use Turbo’s morphing refreshes. With turbo_refreshes_with method: :morph, Turbo updates the DOM by morphing rather than doing a full replace, which tends to preserv

React Query for server state management

React Query eliminates boilerplate for fetching, caching, and syncing server data. Instead of managing loading/error/data states manually with useState, I define queries with useQuery that handle caching, background refetching, and stale data automati

Panic recovery middleware that fails closed and logs context

Even well-tested services panic occasionally: a nil pointer from an unexpected edge case, a slice bounds bug, or a library doing something surprising. If you don’t recover, one request can crash the entire process and turn a small bug into an outage.

Turbo Frames: Inline edit that swaps form <-> row

Inline editing works best when the frame boundary is small and stable (one row). Render the display state inside a frame, then link to edit inside the same frame. Submit swaps it back. This keeps controllers simple and UI snappy.

Performance profiling with rack-mini-profiler and tools

rack-mini-profiler reveals performance bottlenecks in Rails apps. It displays database queries, rendering time, memory allocation on every page. I use Flamegraphs to visualize where time is spent. Memory profiling identifies allocation hotspots. Query

Django database read-write split with routers

Database routers enable read-write splitting for scaling. I direct reads to replicas and writes to primary. The router examines hints and model to make routing decisions. For read-heavy apps, this distributes load across multiple databases. I use usin

Django query optimization with only and defer

The only() method loads specified fields only, while defer() excludes specified fields. This reduces data transfer and memory usage. I use only() when I need just a few fields from large models. For read-only displays, this prevents loading unnecessar