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
JavaScript i18n Minimal Translator
A tiny internationalisation helper that loads a locale dictionary and resolves translation strings by dot-notation key. Supports variable interpolation via {{placeholder}} syntax. Falls back to the key itself when a translation is missing, keeping the UI readable during development. Swap the locale at runtime without a page reload.
JavaScript Middleware Pipeline
A simple Koa/Express-style middleware runner for client-side use. Middleware functions receive a context object and a next() function — call next() to pass control to the next middleware or skip it to short-circuit the chain. Useful for building plugin systems, request pipelines, and composable validation logic.
JavaScript Flatten Object (Dot Notation)
Flattens a deeply nested object into a single-level object with dot-notation keys. Useful for comparing configs, building form field names from nested data, logging structured objects to analytics, or preparing data for flat key-value stores like Redis or environment variables.
JavaScript Cookie Helpers (Get / Set / Delete)
Minimal cookie utilities: getCookie retrieves a value by name, setCookie writes a cookie with optional expiry days and path, deleteCookie removes it by setting an expired date. No library needed for simple first-party cookie management. For complex scenarios (SameSite, Secure, partitioned) extend the options object.
JavaScript Serialize Form to Object
Converts all named form fields into a plain JavaScript object using the FormData API. Handles text inputs, selects, textareas, and checkboxes. Multiple values for the same name (e.g. multi-select, checkboxes) are collected into an array. Ready to JSON.stringify and POST to an API.
HTML ARIA Live Region for Dynamic Announcements
Use `aria-live` on a container so screen readers announce its content changes (toast notifications, form errors, loading states). `polite` waits for a pause; `assertive` interrupts.
HTML HTML5 Document Boilerplate
Sensible HTML5 starting template: UTF-8 charset, responsive viewport, language attribute, semantic landmarks. Drop this in every new project before adding anything else.
Java Optional — Stop Returning Null
`Optional<T>` makes "may be absent" part of the type signature so callers can't forget the null check. `map`, `orElse`, `ifPresent` chain naturally — no `if (x != null)` boilerplate.
Python unique_everseen — Order-Preserving Dedupe
Remove duplicates while preserving original order (set() loses order on collisions). Optional key function lets you dedupe by a derived value — e.g., lowercased email.
Java JUnit 5 — Parameterized Tests
`@ParameterizedTest` runs the same test with multiple inputs. Use `@CsvSource`, `@MethodSource`, or `@EnumSource` for data. Eliminates copy-paste in test classes.
Bash Trap Signals for Cleanup
Use `trap` to delete temp files / kill background workers when the script exits — even on Ctrl-C or an unhandled error. Single most-undervalued bash feature.
Java HttpClient — Synchronous GET (Java 11+)
`java.net.http.HttpClient` ships in the JDK — no Apache HttpClient or OkHttp needed for most cases. Reuse one client across the app; configure timeouts and follow-redirects up front.
Kotlin Generic Class and Function
`<T>` declares a type parameter. Use it on classes (`Box<T>`) and functions (`fun <T> identity(x: T) = x`). Type bounds (`T : Comparable<T>`) constrain what T can be.
Kotlin kotlinx.serialization — JSON Basics
Compile-time code generation for JSON serialization. Annotate `@Serializable` on a data class; `Json.encodeToString` and `Json.decodeFromString` are typed.
SQL EXTRACT — Pull Parts Out of a Timestamp
`EXTRACT(field FROM timestamp)` pulls year, month, hour, day-of-week, week, epoch — whatever you need to group, filter, or render. Standard SQL across every database.
Java Optional with Streams
`Optional::stream` (Java 9+) bridges optionals into the Stream API — collect all the `Some` values from a list of optionals, drop the empties, in one pipeline.
HTML Comment / Review Markup with Schema
Comments and reviews can also have Schema.org markup. The `Review` type appears under products in Google search results with star ratings; `Comment` is for general user feedback.
Bash Background Jobs + wait
Run several commands in parallel with `&`, then wait for all of them with `wait`. Collect exit codes via $! and check after wait returns.