The snippet library.
Small, practical examples. Search by task or narrow things down below.
Give an optional property a default
Handle missing object fields with nullish coalescing.
optional✓ Tested
Give implicit grid rows a minimum height
CSS: Minmax allows an implicit row to grow when its content requires more room.
CSS✓ Tested
Give related form fields a shared title
HTML: Learn how to give related form fields a shared title in a complete browser example.
HTML✓ Tested
Group by more than one field
SQL: Each distinct combination of grouping fields produces its own row.
SQL✓ Tested
Group by more than one field
SQL Server: Each distinct combination of grouping fields produces its own row.
SQL Server✓ Tested
Group by more than one field
Postgres: Each distinct combination of grouping fields produces its own row.
Postgres✓ Tested
Group by more than one field
SQLite: Each distinct combination of grouping fields produces its own row.
SQLite✓ Tested
Group fields in a struct
Group fields in a struct using a complete Go program with explicit sample inputs.
Go✓ Tested
Group matching values while preserving their order
C++: stable_partition keeps the relative order within both predicate groups.
C++✓ Tested
Group mutually exclusive choices
Use the same name for HTML radio buttons and a fieldset legend.
HTML✓ Tested
Group records by a field
Python: Accumulate related values with defaultdict without checking whether each group exists.
Python✓ Tested
Group records into map entries
JavaScript: Initialize an array for a missing Map key before appending its values.
JavaScript✓ Tested