Django custom decorators for view logic

Custom decorators encapsulate reusable view logic. I use functools.wraps to preserve function metadata. For class-based views, I use method_decorator. Common patterns include permission checks, rate limiting, or request validation. Decorators can modi

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:

BufReader and BufWriter for efficient I/O buffering

BufReader and BufWriter wrap readers/writers with an in-memory buffer, reducing system calls. For example, reading a file line-by-line with BufReader::new(file).lines() is much faster than unbuffered reads. I use them for parsing large files, log proc

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

String vs &str for owned vs borrowed text

String is an owned, growable UTF-8 string on the heap. &str is a borrowed string slice, often a view into a String or a string literal. I use String when I need to own, modify, or build strings. I use &str for function parameters (accepting bo

Security with Spring Security and JWT

Spring Security secures applications with authentication and authorization. I configure security with SecurityFilterChain bean defining protected and public endpoints. JWT (JSON Web Tokens) provides stateless authentication—tokens contain user claims

Kubernetes Horizontal Pod Autoscaler and resource management

The Horizontal Pod Autoscaler (HPA) automatically scales Pod replicas based on observed metrics. It monitors CPU utilization, memory usage, or custom metrics via the metrics-server. The minReplicas and maxReplicas fields set scaling bounds. targetCPUU

TypeScript types from Rails serializers

Keeping TypeScript types in sync with Rails API responses is critical but tedious. I generate TypeScript interfaces automatically from Rails serializers or JSON Schema using tools like quicktype or custom scripts. For manual definitions, I create a ty

MVVM architecture with ViewModel and LiveData

MVVM separates concerns in Android apps—Model holds data, View displays UI, ViewModel mediates with business logic. ViewModels survive configuration changes, preventing data loss during rotation. I use ViewModel class with viewModelScope for coroutine

Modal dialogs with focus trapping and accessibility

Accessible modals require focus management, keyboard navigation, and ARIA attributes. I build a reusable Modal component that traps focus inside when open, moves focus to the first interactive element, and returns it to the trigger on close. The Escap