pgxpool initialization with max connections and statement timeout

Postgres stability depends on respecting its limits. I configure pgxpool with explicit MaxConns and MaxConnLifetime so the service doesn't accidentally open too many connections during bursts. I also set a session statement_timeout in AfterConnect, wh

Character counter for textareas with Stimulus

A character counter is small, but it removes uncertainty for users (especially when there’s a limit). I implement it with Stimulus so it stays reusable: attach to a wrapper, declare input + output targets, and compute remaining characters based on an

tRPC router pattern for type-safe APIs

Maintaining separate REST types and frontend client types can be a lot of overhead in TypeScript-heavy teams. With tRPC, the API types flow directly to the client, which reduces duplication and keeps refactors safe. Runtime validation still matters, s

Prettier config for consistent formatting

Formatting consistency matters, but humans shouldn’t be the ones enforcing it in code review. Prettier makes diffs smaller and reviews more focused on logic. I keep the config minimal and aligned with team expectations (singleQuote, trailing commas, ~

Action Cable for real-time WebSocket communication

Action Cable brings WebSocket support to Rails, enabling real-time features like live notifications, collaborative editing, or chat systems. Clients subscribe to channels that broadcast updates when server-side events occur. I use Redis as the pub/sub

Consistent JSON responses (content-type + error envelopes)

One of the easiest ways to reduce frontend complexity is to be consistent about API responses. I keep a small helper that always sets Content-Type: application/json; charset=utf-8, uses a stable error envelope (error + optional details), and returns c

Django formsets for editing multiple objects

Formsets handle multiple forms on one page. I use modelformset_factory for editing existing objects and inlineformset_factory for related objects. The extra parameter controls empty forms shown. I validate formsets with formset.is_valid() and save wit

Django sitemap generation for SEO

Sitemaps help search engines discover and index pages. Django's sitemap framework generates XML sitemaps automatically. I create sitemap classes for each content type, defining items(), lastmod(), changefreq(), and priority(). For large sites, I use s

Graceful shutdown for Node HTTP servers

Deploys got a lot calmer once I treated SIGTERM as a first-class signal instead of an afterthought. In Kubernetes (and most PaaS platforms), you’re expected to stop accepting new requests quickly while finishing in-flight work. The worst failure mode

Track in-flight requests with atomic counters

In-flight request count is a simple but powerful saturation signal. I keep an atomic.Int64 gauge that increments at the start of a request and decrements in a defer, which makes it robust even on early returns. This gauge can be exported via expvar, P

Pagination links that escape a Turbo Frame with _top

Sometimes a frame is great for partial navigation, but sometimes you explicitly want a full-page visit. Pagination is a common case: when the page number changes, I often want the URL to update and the browser history to behave normally. You can tell

Use dom_id everywhere to keep Turbo replacements deterministic

Turbo Stream updates are easiest when every meaningful element has a stable id. Rails’ dom_id helper makes this painless: dom_id(@post) yields post_123, and dom_id(@post, :header) yields header_post_123. I use this pattern throughout Hotwire UIs so I