Next.js Route Handler with auth guard

I like API routes that read like tiny, well-scoped controllers. In Next.js Route Handlers, I keep auth and input parsing right at the top, then return explicit status codes instead of throwing for expected failures. I also avoid leaking server-only de

App lifecycle and scene management

iOS 13 introduced scene-based lifecycle for multi-window support on iPad. The App and Scene delegates handle different lifecycle events. SceneDelegate manages individual scenes—windows on iPad or the single window on iPhone. It responds to state trans

Multi-tenancy for SaaS applications

Multi-tenancy serves multiple customers (tenants) from single application instance. Schema-per-tenant isolates data in separate databases. Shared schema with tenant ID column partitions data within tables. Discriminator-based approach uses JPA filters

GraphQL API with graphql-ruby gem

GraphQL provides clients flexibility to request exactly the data they need, reducing over-fetching and under-fetching compared to REST. The graphql-ruby gem integrates GraphQL into Rails with a schema-first approach. I define types for each model, fie

Counter cache for association counts

Computing counts on associations can be expensive when done repeatedly—post.comments.count executes a SELECT COUNT(*) query every time. Counter caches solve this by maintaining a denormalized count column on the parent model that increments/decrements

Rack middleware for request/response processing

Rack middleware processes HTTP requests/responses in Rails' stack. Middleware sits between web server and application, modifying requests before they reach controllers. I build custom middleware for logging, authentication, rate limiting, request modi

CSS selectors and specificity calculation rules

CSS specificity determines which styles apply when multiple rules target the same element. I calculate specificity as (inline, IDs, classes/attributes/pseudo-classes, elements/pseudo-elements). Inline styles have highest specificity at 1000. ID select

Django REST Framework viewset actions

Custom actions extend viewsets beyond CRUD operations. I use @action decorator with detail=True/False for object-level or collection-level actions. This creates endpoints like /posts/1/publish/ or /posts/recent/. I specify HTTP methods, permissions, a

Kubernetes Pod and Deployment manifests

Kubernetes orchestrates containerized workloads at scale. A Pod is the smallest deployable unit, wrapping one or more containers. Deployments manage Pod replicas with declarative updates and rollbacks. The spec.replicas field sets desired Pod count. s

Update an error summary area via turbo_stream.update

For forms with multiple fields, I like an error summary at the top. With Turbo Streams, you can update just the summary target when validation fails. This is helpful when the form is long and the user might not see inline errors immediately. The serve

cfg attribute for conditional compilation

The #[cfg(...)] attribute enables conditional compilation based on features, target OS, or build profiles. I use #[cfg(test)] for test-only code, #[cfg(target_os = \"linux\")] for platform-specific logic, and #[cfg(feature = \"...\")] for optional fea

Rails caching strategies for performance

Rails caching dramatically improves performance by avoiding expensive computations and queries. Fragment caching caches view partials. Russian doll caching nests cache fragments for efficient invalidation. Low-level caching stores arbitrary data. Rail