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
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.
Go select — Multiplex Channel Operations
`select` is like a switch for channels — runs whichever case is ready. Use `default` for non-blocking sends/receives; `case <-time.After(d)` for timeouts.
Bash Generate UUID
Several portable ways to mint a v4 UUID from the shell — useful for request IDs, idempotency keys, temporary filenames.
Bash Background Jobs + wait
Run several commands in parallel with `&`, then wait for all of them with `wait`. Collect exit codes via $! and check after wait returns.
HTML HTML5 Document Boilerplate
Sensible HTML5 starting template: UTF-8 charset, responsive viewport, language attribute, semantic landmarks. Drop this in every new project before adding anything else.
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.
Kotlin Jetpack Compose — Basic Composable
Compose is Android's modern declarative UI toolkit. A `@Composable` function describes UI; the runtime re-runs it when inputs change. Replaces XML layouts entirely.
Go iota — Auto-Incrementing Constants (Enums)
Go has no `enum` keyword but `iota` inside a const block gives you the same effect. Each line is the previous expression with iota auto-incremented.
Go Type Switches
When you have an `interface{}` (or any) and need to dispatch on its underlying type, use `switch v := x.(type)`. Cleaner than a chain of type-assertions.
Bash Filter Lines by Regex
grep -E (extended regex) is the right tool 95% of the time. Combine -i (case-insensitive), -v (invert), -n (line numbers), -B/-A (context lines).
Bash Count Occurrences of a Pattern
Several ways to count matches: lines containing X, total matches across a file, matches grouped by capture, etc.
Bash Check Command Exists Before Using It
`command -v` is the portable, fast way to check whether a binary is on $PATH. Avoid `which` (its behavior varies between systems).
Bash Recursive Directory Walker with Predicate
Use `find -print0` + `read -d ""` to safely iterate filenames that may contain spaces, newlines, or quotes. Standard bash for-loop over `find` output breaks on these.
Kotlin async / await for Parallel Results
`async` returns a `Deferred<T>` — like a Future. Use it when you need a RESULT back, in parallel. Call `.await()` to get the value (suspends until ready).
SQL LATERAL Join — Per-Row Subquery
PostgreSQL `LATERAL` lets a join's right-hand side reference the left-hand row — like a correlated subquery, but supplying multiple columns or rows. Perfect for "top-N per group".
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.
PHP Recursive Directory Walker
Yield every file under a directory using a generator and SPL's RecursiveIteratorIterator. Filter by extension or any other predicate without slurping all paths into memory first.
SQL UPDATE with JOIN
Update one table using values from another. Syntax varies by database — PostgreSQL uses `FROM`, MySQL puts the join in the `UPDATE` clause.