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 Web Crypto — AES-GCM Encrypt & Decrypt
Encrypts and decrypts text using AES-GCM (256-bit) via the browser's native Web Crypto API — no external library needed. A random 96-bit IV is generated per encryption and prepended to the output so decryption can recover it. Suitable for encrypting sensitive data client-side before storage.
TypeScript clamp / lerp / mapRange
Three numeric utilities you reach for constantly in animation, UI math, and audio code. Generic enough to use anywhere, no Math.* dance required.
PHP Atomic Counter with flock
A single-file counter that survives concurrent increments correctly using flock + read-modify-write inside the locked region. Useful for crude visitor or job-id counters when you don't want a DB.
HTML Figure + Figcaption (Images, Code, Charts)
`<figure>` groups self-contained illustrative content with its caption. Use it for images, code blocks, charts, diagrams — anything that's referenced from the surrounding text but stands on its own.
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.
PHP Find Open TCP Port
Probe whether a remote host:port accepts connections, with a configurable timeout. Useful for quick health checks in deploy scripts.
Python Multipart File Upload
POST a file (or several) as multipart/form-data using requests, with optional extra form fields. Lets you upload to /avatar-style endpoints without manual boundary construction.
Bash Safe Bash Script Template
Start every script with the same skeleton: strict error mode (errexit, nounset, pipefail), an IFS reset, and a main() function. Catches silent failures that have lost engineers weeks of debugging.
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.
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.
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.
SQL Transactions and Isolation Levels
Wrap related changes in a transaction so they commit or roll back together. Isolation levels trade consistency for concurrency — pick the weakest one that meets your correctness needs.
Bash cURL GET with Timeout + Retry
A sensible default cURL invocation: short connect timeout, total timeout, retry on transient failures with backoff, fail-on-error.
Bash Print a Boxed Banner
Wrap a string in a Unicode box for important headers. Auto-sizes to the longest line. Helps milestone messages stand out in long CI logs.
Kotlin MockK — Kotlin-Idiomatic Mocking
MockK plays well with Kotlin: final classes, coroutines, top-level functions, all mockable. `every { ... } returns ...` is the canonical setup.
Rust Parse Strings to Typed Values
`str::parse::<T>()` works for every type that implements `FromStr` — every numeric type, `bool`, `IpAddr`, `Uuid` (with the crate), etc. Returns `Result` so you can chain with `?`.
TypeScript const Assertions for Literal Types
`as const` freezes a value as deeply readonly and infers the narrowest possible literal types. Replaces enums for most use cases — better tree-shaking, no runtime cost.
HTML Product Page with Schema.org Markup
Marking up a product page with the Schema.org `Product` type unlocks Google's rich snippets — price, rating, availability appear directly in search results. JSON-LD is the recommended format.