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 Recursive CTE — Walk a Hierarchy
`WITH RECURSIVE` lets a CTE refer to itself. The standard way to walk parent/child trees (org charts, comment threads, category nestings) in a single query.
Python Context Manager via @contextmanager
Build a custom context manager without writing a class — just a generator with one `yield`. The code before yield runs on enter, after yield runs on exit (even on exception).
SQL Pivot Without PIVOT (Conditional Aggregation)
Most databases don't have a real `PIVOT` keyword (SQL Server does). The portable answer is conditional aggregation — `SUM(CASE WHEN ...) AS col` for each pivoted value.
Rust From / Into Conversions
Implement `From` and you get `Into` for free. Then `.into()` and `T::from(x)` both work. The single most idiomatic way to express type conversions in Rust.
Go base64 Encode / Decode
`encoding/base64` has Standard, URL-safe, and Raw (no padding) variants. URL-safe replaces `+/` with `-_` so the output is safe in query strings and filenames.
Rust Async/Await with tokio
`async fn` returns a future; `.await` drives it. tokio is the de-facto runtime. The `#[tokio::main]` attribute turns `main` into the runtime entry point.
TypeScript Environment Variable Validator
Validate process.env at boot-time and exit fast if anything's missing. The returned object is typed so the rest of the code reads `env.DATABASE_URL` instead of `process.env.DATABASE_URL!`.
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.
Kotlin with — Scope an Existing Object
`with(x) { ... }` is `run` flipped: the receiver is the first argument. Reads naturally when you're doing several things to an existing object without chaining.
SQL ROLLUP — Subtotals and Grand Totals
`GROUP BY ROLLUP` adds subtotal rows (with NULL for the rolled-up columns) plus a grand total. Drop into reports without writing UNIONs by hand.
Kotlin Star Projections (List<*>, etc.)
`List<*>` means "list of something I don't need to know exactly" — read-only with Any? as element type. Useful when you genuinely don't care about the parameter.
Python asyncio.to_thread — Run Blocking Code
Wrap a blocking function so it doesn't freeze the event loop. asyncio.to_thread (3.9+) schedules the call onto the default executor and awaits the result.
PHP Average / Median / Mode
Three classic descriptive statistics over a numeric array. Built without any external math library — just sort + count.
Rust Serde — Derive Serialize / Deserialize
`#[derive(Serialize, Deserialize)]` is the one-liner that bridges Rust structs and JSON / YAML / TOML / etc. via serde's data-format crates.
TypeScript URL Builder with Type-Safe Query
Build URLs with a clean query-param API. Skips null/undefined automatically, encodes everything, and accepts arrays for repeated keys. Avoids manual string concatenation.
SQL FIRST_VALUE / LAST_VALUE
Return the first or last value within a window. Useful for "compare each row to the partition's first/last value" — for example, "how much have we grown since the user's first order?"
Kotlin kotlin.test — Basic Tests
`kotlin.test` is the multiplatform test stdlib. `@Test` marks a test; `assertEquals`, `assertTrue`, `assertFailsWith` are the workhorses.
Kotlin Ktor Client — POST JSON with Serialization
Combine Ktor + kotlinx.serialization: register the JSON plugin, declare `@Serializable` data classes, the client (de)serializes automatically.