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
Bash URL-Encode and URL-Decode
Encode and decode URL-safe strings entirely in bash — no python or external tool required. Useful in pure-shell deployment scripts that need to build query strings.
Kotlin OkHttp Client (Java interop)
OkHttp is the JVM-standard HTTP library. Works fine from Kotlin; use the `await()` extension from `okhttp3.coroutines` to get suspend support.
PHP CSRF Token Generate + Verify
Per-session CSRF token helpers using hash_equals for constant-time comparison. Token is regenerated on logout but persists across requests within a session.
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.
Kotlin select — Choose Among Channels
`select { }` lets a coroutine wait on multiple suspending operations and proceed when the first one is ready — like nginx select() but for channels, deferreds, and timers.
Kotlin tailrec — Tail-Call Optimization
Mark a recursive function `tailrec` and the compiler rewrites it as a loop — no stack frame per call, no StackOverflowError on deep recursion. Function must end with itself as the FINAL expression.
Java CompletableFuture — Async Chains
`CompletableFuture` is the idiomatic way to compose async work. `thenApply` for sync transforms, `thenCompose` for async chains (flatMap), `exceptionally` for fallback on failure.
Bash Process Substitution Cheatsheet
`<(...)` makes a command's output look like a file; `>(...)` makes a command's input look like a file. Killer feature for tools that only accept filenames.
PHP Unique by Callback
Like array_unique, but the uniqueness test is a callback that returns the key to dedupe by. Useful for "unique by ID" or "unique by lowercased email" across arrays of objects/rows.
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 Get Nested Value by Dot Path
Read deeply-nested array values like Lodash _.get(). Use a "a.b.c" string instead of nested isset checks; returns a default on any missing segment.
Go Functional Options Pattern
Replace giant config structs with a variadic list of `Option` functions. Lets you add optional parameters later without breaking existing callers. The standard Go API design for constructors.
SQL date_trunc — Bucket Times into Hours/Days/Weeks
`date_trunc('day', ts)` rounds a timestamp down to the start of the day. Use for time-series GROUP BYs — daily/weekly/hourly buckets without messy arithmetic.
TypeScript Typed Fetch Wrapper
A thin fetch wrapper that returns parsed JSON typed as `T`, throws on non-2xx, and accepts an AbortSignal. Single source of truth for "how this app talks to APIs."
Rust Walk a Directory Tree
`walkdir` recursively iterates every entry under a path, skipping inaccessible directories cleanly. The standard-library alternative requires manual recursion.
Kotlin Write to a File
`writeText` overwrites; `appendText` appends. For multiple writes, use `bufferedWriter().use { }` for efficiency + auto-close.
TypeScript Shuffle (Fisher-Yates)
Uniformly shuffle an array in place using the modern Fisher-Yates algorithm. Returns the same array for chaining. Use crypto.getRandomValues for cryptographic uses.
SQL EXPLAIN / EXPLAIN ANALYZE
`EXPLAIN` shows the query plan; `EXPLAIN ANALYZE` actually runs it and shows real timings. The first tool when a query is slow — look for sequential scans on big tables.