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 Sort an Array
Bash itself doesn't sort arrays — you pipe through `sort`. readarray captures the sorted output back into an array, preserving each element verbatim (including spaces).
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.
Go database/sql — Open + Query
`database/sql` is driver-agnostic — pick a driver (`pgx/stdlib`, `go-sql-driver/mysql`, `mattn/sqlite3`). Always `defer db.Close()` only on app exit; the pool is meant to be long-lived.
Rust Concurrency Limit with Semaphore
Fan out N tasks but limit how many run at once via `tokio::sync::Semaphore`. Standard pattern for HTTP fan-out where you must respect a server's rate limit.
HTML Tabs (ARIA tablist pattern)
The accessible tab pattern: a `role="tablist"` container, each tab as `role="tab"`, panels as `role="tabpanel"`. `aria-selected` + `aria-controls` link them and announce state.
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.
HTML Video Element with Captions
`<video>` with multiple `<source>` formats (MP4 + WebM), `controls`, `poster`, and a captions track via `<track kind="captions">`. All shipped with the browser — no JS player needed.
Go Signal Handling with signal.NotifyContext
Go 1.16+ `signal.NotifyContext` returns a context that's canceled on the listed signals. Cleaner than the legacy `signal.Notify(channel)` dance for graceful shutdown.
HTML Multi-Column Footer
Standard site footer with grouped links, brand block, social icons, and legal/copyright. Use semantic `<nav aria-label>` on each column so screen readers announce the section labels.
Kotlin Read a File — Whole, Lines, or Stream
Stdlib extensions on `java.io.File` and `java.nio.file.Path`. Use `readText()` for small files, `useLines { }` for memory-efficient line-by-line.
TypeScript uniqueBy — Dedupe by Callback
Deduplicate an array using a derived key (object id, lowercased email, etc.). First occurrence wins. Backed by a Map for O(n) performance.
Kotlin run — Compute With Scope
`x.run { ... }` is `apply` but returns the block's LAST expression instead of `x`. Top-level `run { ... }` (no receiver) is useful for inline computation blocks.
Kotlin let — Transform or Null-Safe Scope
`x.let { it.foo }` runs the block with `x` as `it` and returns the block's last expression. Combined with `?.`, it's the canonical "do this only if non-null" pattern.
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.
Go filepath.Walk — Recursive Tree Walk
`filepath.WalkDir` (Go 1.16+) is the modern, faster version. Visit every file/dir under a root; the callback decides whether to skip or process.
Kotlin Ktor Client — POST JSON with Serialization
Combine Ktor + kotlinx.serialization: register the JSON plugin, declare `@Serializable` data classes, the client (de)serializes automatically.
Bash Find Commit That Introduced a String
`git log -S` (the "pickaxe") finds commits whose diff added or removed a given string. The fastest way to answer "when did this line first appear?"
TypeScript Deferred / Externally-Resolvable Promise
Create a Promise whose `resolve` and `reject` are exposed externally. Useful when you need to settle a promise from outside its executor — e.g. waiting on an event-driven response.