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.
PHP Convert Camel Case ↔ Snake Case
Convert between camelCase and snake_case identifiers. Handy when mapping JS API responses (camelCase) into PHP database column names (snake_case) and vice versa.
Rust Serde — Field Rename, Skip, and Tagging
Per-field attributes let you map between Rust's snake_case and the JSON's camelCase, skip optional fields, and tag enum variants the way external APIs expect.
Rust Move vs Borrow — the Core Rule
Rust's ownership model: passing a value transfers ownership (move); taking a `&value` lets you read without taking ownership; `&mut value` lets you modify without taking ownership. Only one mutable borrow OR many immutable borrows at a time.
Kotlin Result Type — Safe Error-Returning APIs
`Result<T>` wraps "success or thrown exception" without forcing the caller into try/catch. `runCatching { ... }` is the standard producer.
HTML Picture Element — Art Direction
`<picture>` lets you serve DIFFERENT images at different breakpoints — not just different sizes of the same crop. Perfect for a wide desktop banner that becomes a square mobile poster.
HTML Radio Group with Fieldset + Legend
Always wrap radio groups (and checkboxes that share semantics) in a `<fieldset>` with a `<legend>`. Screen readers announce the legend before each option — without it, the choice is contextless.
Java java.time — Format and Parse
`DateTimeFormatter` replaces `SimpleDateFormat` (which was not thread-safe). Constants for the common formats; pattern strings for custom layouts.
Rust Untyped JSON with serde_json::Value
When you don't know the JSON shape up-front, parse into `serde_json::Value` and navigate via index / get(). Type-safe pattern matching converts back to Rust types.
Python Mask Sensitive Strings (PII)
Mask the middle of a string while keeping a few chars at each end. Useful for displaying credit cards, emails, or API keys in UI / logs without leaking the whole value.
PHP PDO Connection with Sensible Defaults
Open a PDO connection with all the options you almost always want: real prepared statements, exceptions on error, associative-array fetch mode, UTF-8 charset.
PHP Sort by Multiple Keys
Stable multi-column sort for arrays of associative rows. Each column can be sorted ASC or DESC independently. Wraps usort with a chained comparator.
SQL JSONB Columns (PostgreSQL)
`jsonb` stores binary-optimized JSON. Index sub-fields with GIN for fast containment queries. Most-used operators: `->` (get field), `->>` (get as text), `@>` (contains), `?` (key exists).
Java HttpClient — Synchronous GET (Java 11+)
`java.net.http.HttpClient` ships in the JDK — no Apache HttpClient or OkHttp needed for most cases. Reuse one client across the app; configure timeouts and follow-redirects up front.
Java Sorting with Comparator
`Comparator.comparing`, `thenComparing`, and `reversed()` chain into expressive multi-field sorts. Way cleaner than the old Comparable spaghetti.
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.
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.
Python Stream-Download Large File with Progress
Download a file in chunks so memory stays flat regardless of file size, with a tqdm progress bar showing speed + ETA. Skips re-download if the file is already complete.