Laravel form requests for validation

Form requests encapsulate validation logic in dedicated classes, keeping controllers thin and focused. Each form request extends FormRequest and defines rules() and optionally authorize() methods. The authorize() method checks if the user can perform

anyhow::Context for adding error context without custom types

When prototyping or writing applications (not libraries), anyhow is my go-to. It provides Result<T> as an alias for Result<T, anyhow::Error>, which can hold any error type. The .context() method attaches additional context to errors as the

Progress indicators for long-running operations

Users need feedback during slow operations like file uploads or complex processing. I combine Turbo Streams with background jobs to show real-time progress. When an operation starts, I enqueue a job that periodically broadcasts progress updates via Ac

Django allauth for social authentication

django-allauth provides ready-made social auth (Google, Facebook, GitHub, etc.). I configure providers in settings with API keys. It handles OAuth flows, token management, and account linking. Users can login with multiple providers. I customize templ

Soft deletes with paranoia gem

Hard deletes make data recovery impossible and complicate audit trails. Soft deletes mark records as deleted without removing them from the database, preserving history and enabling undo functionality. The paranoia gem adds a deleted_at timestamp colu

Safer Feature Flagging: Cache + DB Fallback

A robust feature flag read path should be fast, but also resilient to cache outages. Cache the computed result briefly and fall back to DB if needed; keep the interface dead simple.

Custom validators and validation patterns

Rails validations ensure data integrity before persistence. I create custom validators for complex business rules. Validators inherit from ActiveModel::Validator or ActiveModel::EachValidator. EachValidator validates individual attributes; Validator v

TypeScript path aliases (tsconfig + bundler)

Deep relative imports are a maintainability tax. Once a project grows, ../../../ becomes noise and refactors get painful. I define a small set of path aliases (like @/* for app code) and keep them consistent across TypeScript, Jest/Vitest, and the bun

Transactional outbox in Node (DB write + event)

The moment you split ‘write to DB’ and ‘publish to a queue’ into two independent operations, you create a place to lose data. Publish first and a DB failure means consumers act on something that never happened. Write first and a publish failure means

Idempotent Job with Advisory Lock

I reached for idempotency the moment retries started duplicating side effects. In Advisory lock helper, I generate a deterministic lock ID and use pg_try_advisory_lock to ensure only one worker owns the critical section; the ensure block always calls

CORS configuration for cross-origin API requests

When building APIs consumed by frontend applications hosted on different domains, CORS (Cross-Origin Resource Sharing) headers are mandatory. The rack-cors gem simplifies configuration by letting me whitelist specific origins, HTTP methods, and header

Django model managers for custom querysets

Custom managers encapsulate common query patterns. I create a manager method for each frequently-used filter like published() or active(). By returning self, I can chain manager methods. For more complex queries, I create a custom QuerySet class and u