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 Generic Set Type
A type-safe Set built on `map[T]struct{}` and Go generics. Has Add / Has / Delete / Size — and uses zero bytes per entry for the value side.
Go log/slog — Structured Logging
`log/slog` (Go 1.21+) is the standard structured logger. Drop-in replacement for `log` with key/value attributes and JSON output for log-pipeline ingestion.
TypeScript Truncate at Word Boundary
Cap a string at `max` characters without splitting a word, appending an ellipsis when truncated. Falls back gracefully if the last word is longer than `max`.
Go goroutine + sync.WaitGroup
`go fn()` spawns a goroutine. To wait for several to finish, use `sync.WaitGroup` — call `Add` before spawning, `Done` (deferred) inside, `Wait` to block until all are done.
Java Singleton via enum
`enum` with a single value is the simplest correct singleton implementation: lazy, thread-safe, serialization-safe, reflection-safe. Joshua Bloch's recommendation in Effective Java.
PHP Pluralize / Singularize (English basics)
A pragmatic rule-based English pluralizer covering the common cases (s, es, ies, irregular nouns). Not perfect, but good enough for UI labels like "1 item" / "3 items".
Kotlin Ktor Server — Hello World
Ktor lets you stand up an HTTP server in a few lines. Pick an engine (Netty / Jetty / CIO), declare routes, run. Coroutine-native end to end.
HTML Form Validation Attributes
Built-in client-side validation: `required`, `pattern`, `minlength`/`maxlength`, `min`/`max`. The browser blocks submission and shows a native error if anything fails. Always validate on the server too.
PHP Human-Readable "Time Ago"
Convert a timestamp into a short relative phrase: "just now", "5 minutes ago", "3 days ago". Falls back to an absolute date once the delta exceeds a year.
Kotlin Extension Functions
Add methods to ANY type — including stdlib types like String, List, or Int — without subclassing. Compiled as a static dispatched function, so no runtime overhead.
HTML Pricing Plan Card
Single-tier pricing card with plan name, price, feature list, CTA. Replicate three times for a standard pricing page; highlight the "recommended" tier with a different border color.
SQL EXTRACT — Pull Parts Out of a Timestamp
`EXTRACT(field FROM timestamp)` pulls year, month, hour, day-of-week, week, epoch — whatever you need to group, filter, or render. Standard SQL across every database.
SQL Self-Join — Org Chart / Hierarchies
A self-join is just a regular join with the same table aliased twice. The canonical example is an employee table where each row points to a manager in the same table.
Rust Rayon — Parallel Iterators
`rayon` lets you parallelize CPU-bound iterator chains by changing `.iter()` to `.par_iter()`. Handles thread-pool, work-stealing, and synchronization for you.
Rust Async Timeout
Wrap any future in `tokio::time::timeout` to fail it if it takes too long. Returns `Err(Elapsed)` on timeout; you decide what to do next (retry, fall back, propagate).
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.
PHP Set Nested Value by Dot Path
Mutate a nested array by dot path, auto-creating any intermediate arrays. Companion to getPath; together they replace a lot of isset+array_key_exists ladders.
PHP JSON Lines (NDJSON) Stream Reader
Read newline-delimited JSON (one object per line) as a generator. Each yield gives you the next decoded record without holding the whole file in memory.