Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
SQL Moving Average (Window Frame)
Add a frame clause (`ROWS BETWEEN N PRECEDING AND CURRENT ROW`) to compute moving averages, sliding sums, rolling stats — anything that needs a bounded look-back.
Java Generic Class with Type Parameter
Stamp out type-safe containers and helpers — same class body, multiple element types. The `<T>` declaration is what makes it generic.
TypeScript useLocalStorage — Synced State
A useState replacement that persists to localStorage and syncs across tabs via the `storage` event. Strongly typed via the initial value's type.
Bash PID File Management
Write a daemon's PID to a file at start, check on subsequent runs, clean up on exit. Avoids two copies of the same daemon when the script is invoked twice.
Bash Run on Multiple Hosts via SSH (with progress)
Iterate a host list, run the same command on each, show colored OK/FAIL summary at the end. Useful for ad-hoc fleet operations without setting up Ansible.
Kotlin Custom Property Delegate
Any object with `getValue` / `setValue` operator methods can serve as a delegate. Lets you encapsulate cross-cutting behavior (logging, persistence, validation).
PHP CSV Writer with Proper Escaping
Write rows to a CSV file using fputcsv with sensible quoting. Also writes a UTF-8 BOM so Excel opens the file with the right encoding.
HTML Sortable Table (semantic markup + JS hook)
Use `<button>` inside `<th>` and `aria-sort` on the column so screen readers announce sort state. The button is the keyboard-accessible trigger; JS only handles the actual sort.
Go goroutine + sync.WaitGroup
`go fn()` spawns a goroutine. To wait for several to finish, use `sync.WaitGroup` — call `Add` before spawning, `Done` (deferred) inside, `Wait` to block until all are done.
Kotlin Local Functions
Functions can be declared inside other functions. Closures over outer scope let you eliminate parameter-threading. Use sparingly — too many nested locals hurts readability.
TypeScript useDebounce — Debounced State
A React hook that returns a debounced version of any value. Trigger expensive effects (search, autosave, network fetches) on this value instead of the raw input.
Bash Parse --flag=value Arguments
A getopts-free arg parser handling long flags, equals-separated values, and bundled short flags. Customize as needed.
Kotlin Default Arguments + Named Parameters
Default values eliminate most overload sets. Named args make call sites self-documenting and let you skip middle parameters without thinking about positions.
Bash Most-Modified Files in Repo
Find the hottest files in a git history — useful for spotting hotspots that need refactoring or extra test coverage.
HTML Visually Hidden Utility (.sr-only)
Hides content from sighted users but keeps it discoverable by screen readers. Use for icon-only buttons, table-row context, and form-status announcements that don't need visible text.
TypeScript useFetch — Minimal Data Fetching Hook
A tiny self-contained data-fetching hook with loading/error/data states and AbortController cleanup on unmount. Good baseline before reaching for TanStack Query.
Rust Trait with Default Methods
A trait can supply default implementations — implementors override only the bits they need. Like abstract base classes, but with structural typing and zero runtime cost.
JavaScript JSON Fetch Wrapper
A thin wrapper around fetch that automatically serialises the request body to JSON, sets the Content-Type header, parses the response as JSON, and throws a descriptive error on non-OK responses. Covers the boilerplate needed for 95% of REST API calls in a single reusable function.