Safe YAML decoding (KnownFields) for config files

YAML configuration is convenient, but it’s also a footgun when typos silently get ignored. I enable KnownFields(true) so unknown keys cause an error, which turns “silent misconfig” into a fast failure. That is especially useful during refactors when f

Stimulus: keyboard shortcuts that work with Turbo navigation

Keyboard shortcuts improve power-user workflows, but they must survive Turbo navigation. Attach on connect/disconnect, avoid global leaks, and scope shortcuts to the page/component.

Next.js middleware for auth gating

Protecting routes at the middleware layer prevents a whole class of ‘oops, we forgot to check auth on one page’ bugs. middleware.ts runs before rendering, so unauthenticated users get redirected early and you don’t waste work. I keep the logic simple:

Django database indexes for query performance

Database indexes dramatically speed up queries. I add indexes to frequently-filtered fields via db_index=True or Meta.indexes. Compound indexes help queries filtering on multiple fields together. For text search on PostgreSQL, I use GinIndex with Sear

DB-Level “no overlapping ranges” with exclusion constraint

Scheduling/booking is tricky. Postgres exclusion constraints prevent overlapping time ranges at the database layer—far more reliable than application checks. Rails can still validate, but the DB is the source of truth.

Turbo Streams: Create with prepend + HTML fallback

A good Hotwire endpoint responds to both Turbo and non-Turbo clients. Use respond_to and render a turbo stream that prepends the new record and updates flash/errors, while keeping an HTML fallback for crawlers, redirects, and manual testing.

Turbo Streams: custom action for flash messages

Flash updates are common enough to deserve a first-class stream action. Defining a custom turbo-stream action keeps views tidy: instead of repeating turbo_stream.update, you can write <turbo-stream action="flash">.

Django model property for computed fields

Properties let me add computed attributes to models without storing them in the database. I use @property for simple calculations like full name or age. For expensive computations, I consider caching the result in a field and updating it via signals o

Frontend: toast notifications via a small event bus

I don’t want components depending on each other just to show a toast. A tiny event bus (or context) lets any part of the app emit a toast without wiring props through five layers. The important part is keeping the API small—something like show(message

Django REST Framework schema and documentation

DRF auto-generates API schemas and documentation. I use drf-spectacular for OpenAPI 3.0 schemas. The schema describes endpoints, parameters, and responses. I customize with decorators like @extend_schema. Interactive docs via Swagger UI or ReDoc let d

Robust Webhook Verification (HMAC + Timestamp)

Webhooks are a security boundary. Verify signatures with constant-time compare, include a timestamp window to prevent replay, and store processed event IDs to make handlers idempotent.

Polymorphic associations for flexible relationships

Polymorphic associations allow a model to belong to multiple other models through a single association, which is useful for shared behaviors like comments, likes, or attachments. Instead of separate post_id and article_id columns, a polymorphic associ