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
Bash Tar Archive with Timestamp
Pack up a directory with a date-stamped filename for easy backups. -z for gzip, -j for bzip2, -J for xz (smallest, slowest).
Bash Download with Progress Bar
Show a progress bar for long downloads. wget gives a great built-in bar; curl needs an explicit flag.
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.
Kotlin let — Transform or Null-Safe Scope
`x.let { it.foo }` runs the block with `x` as `it` and returns the block's last expression. Combined with `?.`, it's the canonical "do this only if non-null" pattern.
Go slices package — Modern Helpers
`slices` (Go 1.21+) ships the iteration helpers everyone wrote by hand for years: Contains, Index, Sort, SortFunc, BinarySearch, Clone, Reverse, Equal, Max/Min.
Go database/sql — Open + Query
`database/sql` is driver-agnostic — pick a driver (`pgx/stdlib`, `go-sql-driver/mysql`, `mattn/sqlite3`). Always `defer db.Close()` only on app exit; the pool is meant to be long-lived.
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.
Rust windows / chunks — Sliding & Fixed
`windows(n)` yields every overlapping sub-slice of length n; `chunks(n)` yields non-overlapping chunks. Both work on slices for free, no extra crates.
Bash Create User With Sensible Defaults
Provision a new user account with a home directory, default shell, and sudo membership. Idempotent — re-running on an existing user is a no-op.
Bash Check Systemd Service Is Running
`systemctl is-active` is the right tool — exit code 0 if running, non-zero otherwise. Combine with restart-on-fail for poor-man's supervision.
Bash Get Public IP Address
Several free services return your public IP as plain text. Useful when scripts running behind NAT need to know what address the outside world sees.
Bash Sum a Column with awk
Awk's default field splitter is whitespace; pass a single character with -F. Perfect for summing the Nth column of a log file or CSV.
PHP Generate Identicon Avatar
Render a deterministic 5x5 symmetric "identicon" placeholder avatar from any seed (usually a user's email or username). No external service — pure GD.
Java Jackson — Basic ObjectMapper
`com.fasterxml.jackson.databind.ObjectMapper` is the JSON standard for Java. Construct once (it's expensive + thread-safe) and reuse for every serialization in your app.
HTML Modern Meta Tags (viewport, theme-color, etc.)
The non-obvious meta tags that improve mobile rendering, status-bar coloring, and dark-mode behavior in 2025 browsers. Copy this block whole.
TypeScript clamp / lerp / mapRange
Three numeric utilities you reach for constantly in animation, UI math, and audio code. Generic enough to use anywhere, no Math.* dance required.
PHP Validate Credit Card (Luhn check)
Apply the Luhn checksum algorithm to a credit card number. Strips spaces/dashes first. This validates the format — not whether the card actually exists or has funds.
PHP Simple cURL GET with Timeout
A no-dependency HTTP GET helper with sensible defaults: short timeout, follow redirects, return body as string, throw on transport error. Pass extra headers as a simple associative array.