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
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 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.
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 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.
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.
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.
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.
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.
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.
Kotlin kotlin.test — Basic Tests
`kotlin.test` is the multiplatform test stdlib. `@Test` marks a test; `assertEquals`, `assertTrue`, `assertFailsWith` are the workhorses.
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?"
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.
Python pairwise — Rolling Pair Iterator
`pairwise([a, b, c, d])` yields `(a, b), (b, c), (c, d)` — built into itertools since 3.10. Perfect for "diff consecutive elements" patterns (deltas, rate-of-change, validation between rows).
Java AtomicInteger / LongAdder
Lock-free atomics for shared counters. `AtomicInteger` for low contention; `LongAdder` for high contention (shards internally — much faster under heavy parallel load).
Kotlin Ktor Client — POST JSON with Serialization
Combine Ktor + kotlinx.serialization: register the JSON plugin, declare `@Serializable` data classes, the client (de)serializes automatically.
Rust reqwest GET + JSON Deserialize
`reqwest` is the standard HTTP client. Combined with serde, you can fetch and parse a JSON API response into a typed struct in three lines.
SQL Sessionization — Group Events into Sessions
Stitch a stream of events into "sessions" where events more than N minutes apart start a new session. Uses LAG + a SUM-OVER trick to assign session IDs.