Wrap any pure function with @cache (Python 3.9+) and get an unbounded memoization layer for free. Use @lru_cache(maxsize=N) when you need a bounded cache.
`<progress>` shows how much of a task is done (downloads, multi-step forms). `<meter>` shows a value within a known range (disk usage, password strength). Both render as native UI in every browser.
`os.Getenv` returns "" when unset — easy to miss. Wrap it with a typed helper that supplies defaults and parses numerics. Saves boilerplate at every config-read site.
Use processes (not threads) for CPU-bound work to sidestep the GIL. Functions must be picklable — define them at module level, not as locals or lambdas.
Go Struct Embedding (Composition over Inheritance)
Go has no inheritance. Embed a type to "promote" its fields and methods as if they were on the outer type. Same effect as inheritance for most purposes, but explicit.
Concatenate path segments and produce a normalized canonical path that resists "../" escape attempts. Throws if the result would land outside the given base directory.
Python textwrap dedent + fill (Multi-line Strings)
`textwrap.dedent` strips common leading whitespace from a triple-quoted string — finally, you can indent multiline strings inside functions without breaking the formatting. `fill` wraps to a max width.
Generate and verify a 6-digit time-based one-time password (RFC 6238) compatible with Google Authenticator / Authy. Uses a base32-encoded secret and 30-second time steps.
Two-way conversion between #RRGGBB hex strings and [R, G, B] arrays. Handy when working with theme colors that come from both sources (CSS strings vs. RGB sliders).
`String` is an owned, growable heap allocation; `&str` is a borrowed view into a UTF-8 buffer. Function params should usually take `&str`; return types use `String` when ownership is needed.
Idiomatic helpers for reading + writing JSON to disk, with atomic writes and pretty-printed output. Catches the common "edit and save → corrupt file on crash" failure mode.
`encoding/csv` parses RFC 4180 CSVs. Read row-by-row with `Read()` or all at once with `ReadAll()`. Same for writing — flush with `Writer.Flush()` before closing.