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
Python Slugify (unicodedata, zero deps)
Convert any string to a URL-safe slug using only stdlib. Normalizes Unicode (NFKD), strips combining marks, lowercases, replaces non-alphanumerics with a separator.
Bash Format Date Like a Pro
`date` accepts a format string + optional override of the date being formatted. The +%FT%TZ form gives you ISO-8601 / RFC-3339 in one call.
Java Jackson — Annotations (rename, ignore, etc)
Field-level annotations let you map between snake_case JSON and camelCase Java, skip nulls, never serialize secrets, set defaults on missing fields.
Java HttpClient — POST JSON
POST a JSON body with `HttpRequest.BodyPublishers.ofString` + the right Content-Type. Pair with Jackson / Gson to serialize objects to JSON.
Go database/sql — Transaction Helper
Wrap your transaction in a function that commits on success and rolls back on error or panic. Drop-in: pass any `func(*sql.Tx) error` and forget about manual cleanup.
Python flatten — Recursively Flatten Nested Lists
Yield every leaf from arbitrarily-nested lists/tuples. Strings are intentionally treated as atomic (we don't want to "flatten" "hi" into ["h", "i"]).
SQL SELECT DISTINCT and Counting Uniques
`DISTINCT` removes duplicate rows. Combine with `COUNT(DISTINCT col)` to count uniques in aggregations — different from `COUNT(*)`.
Rust axum — Hello World HTTP Server
axum is the tokio-team's web framework — composable, type-safe handlers built on tower middleware. The hello-world is small enough to read in one screen.
PHP Date Range Iterator
Yield each date in a [start, end] interval as a DateTimeImmutable, with a configurable step. Builds on DatePeriod under the hood — but exposes a generator so you can break out early.
Bash Multipart File Upload via cURL
Upload one or more files using -F. Optional extra form fields go through the same flag — quote carefully to preserve spaces.
Rust macro_rules! — Simple Declarative Macros
Declarative macros let you write functions that take token trees instead of values. Great for boilerplate reduction; cleaner than copy-paste, simpler than proc macros.
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.
Java try-with-resources
For any `AutoCloseable` (files, streams, DB connections, locks), declare it in `try(...)` and Java auto-calls `close()` even on exception. Replaces error-prone `try / finally` blocks.
Python Word-Safe Truncate
Cap a string at `max_len` chars without splitting a word; append an ellipsis when truncated. Backs off to the last space if cutting mid-word would happen.
TypeScript Result / Either Type
Encode "this might fail" in the type signature instead of throwing. Force the caller to handle both branches at compile time. Better than try/catch for foreseeable failures.
Bash Associative Array (hash map)
Bash 4+ supports key-value associative arrays. Must `declare -A` first — Bash won't infer it. Iterate keys with !arr[@].
PHP PDO Transaction Wrapper
Run a closure inside a transaction. Commits on success, rolls back on any exception, then re-throws so the caller can react. Avoids the bug-prone copy-paste of begin/commit/rollBack.
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.