Laravel Sanctum for API authentication

Laravel Sanctum provides lightweight API authentication for SPAs and mobile apps. For SPAs on the same domain, Sanctum uses Laravel's session cookies with CSRF protection. For mobile apps or third-party clients, it issues API tokens stored in a person

Django email with attachments and templates

Django's email system supports attachments and HTML templates. I use EmailMessage for full control or EmailMultiAlternatives for HTML+text versions. For attachments, I use attach_file() or attach() methods. I render email content from templates for co

Stimulus controller for dependent select dropdowns

Dependent dropdowns are a classic UX pattern where one select populates based on another's value. With Stimulus, I handle this entirely client-side after the initial page load by storing options as data attributes or fetching them via AJAX. When the p

Factory Bot for flexible test data generation

Factory Bot creates test data with minimal boilerplate. Factories define blueprints for model creation. I use traits for variations—published posts, admin users. Sequences generate unique values. Associations automatically create related records. Tran

panic! and unwinding for unrecoverable errors

Rust panics are for bugs, not expected errors. When code panics (via panic!, unwrap(), expect(), or assertion failure), the thread unwinds by default, running destructors. I use panic! for invariant violations or \"this should never happen\" cases. Fo

Meta tags, SEO optimization, and Open Graph

Meta tags provide metadata about HTML documents for search engines and social media. I use <meta name="description"> for search result snippets (150-160 characters). The viewport meta tag ensures responsive design on mobile devices. Open Graph t

Custom confirm dialog with Stimulus (better than window.confirm)

data-turbo-confirm uses the browser confirm dialog, which is functional but not pretty. For a more polished app, I replace it with a Stimulus controller that intercepts clicks, shows a custom modal, and only proceeds if the user confirms. Turbo makes

nom for parser combinators and zero-copy parsing

Nom is a parser combinator library for building parsers from small, composable functions. It's byte-oriented and zero-copy, making it ideal for binary protocols, config files, or log parsing. I define parsers for tokens (like tag("GET") or digit1), th

ETag + conditional GET for read-heavy endpoints

For read-heavy endpoints, clients often fetch the same resource repeatedly (profile data, settings, a snip page) even when it hasn’t changed. ETags let the client send If-None-Match and the server respond with 304 Not Modified, saving bandwidth and CP

Django redis caching strategies

Redis provides fast in-memory caching for Django. I configure it as cache backend and use for session storage. I cache expensive querysets, computed values, and API responses. The cache.get_or_set() method simplifies cache-aside pattern. For cache inv

Django channels for WebSockets and async

Django Channels adds WebSocket support and async capabilities. I define consumers similar to views for handling connections. The channel layer enables communication between consumers. For real-time features like chat or notifications, Channels is esse

API documentation with Swagger/OpenAPI

Auto-generated API documentation from code annotations keeps docs in sync with implementation and reduces maintenance burden. The rswag gem generates OpenAPI 3.0 specs from RSpec request specs, providing interactive documentation via Swagger UI. I wri