Results for “one-off”
Small, practical examples. Search by task or narrow things down below.
Update several classifications in one statement
Postgres: A CASE expression computes the new value for each row covered by the update predicate.
Postgres✓ Tested
Update several classifications in one statement
SQLite: A CASE expression computes the new value for each row covered by the update predicate.
SQLite✓ Tested
Use an alternate value only when a variable is nonempty
Bash Scripts: The colon-plus expansion returns its word only when the parameter has a nonempty value.
Bash Scripts✓ Tested
Wrap a collection in one shared parent
jQuery: wrapAll places all selected elements inside one wrapper.
jQuery✓ Tested
Write several messages through one file descriptor
Bash Scripts: Open a destination once and close the descriptor after writing.
Bash Scripts✓ Tested
Advance a date by a number of days
Python: Use timedelta so month and year boundaries are handled automatically.
Python✓ Tested
Check the Gregorian leap-year rule
Java: Use Year.isLeap rather than checking divisibility by four alone.
Java✓ Tested
Connect a reusable label using useId
Connect a reusable label using useId with a small React component and explicit browser behavior.
React✓ Tested
Convert a duration to hours and minutes
Python: Use divmod to split nonnegative whole seconds into display components.
Python✓ Tested
Convert a Unix timestamp to aware UTC
Python: Supply timezone.utc so the result does not depend on the machine time zone.
Python✓ Tested
Convert epoch seconds into an instant
Java: Instant represents a UTC timeline point independent of the default timezone.
Java✓ Tested
Copy nested structured data independently
JavaScript: structuredClone creates an independent copy of supported structured values.
JavaScript✓ Tested