FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

3000 snippets foundClear filters
Docker / ComposeDockerfile patterns

Keep exec-form arguments literal

Docker / Compose: JSON exec form does not expand shell environment variables.

Docker / Compose✓ Tested
Arduino / CGetting Started

Keep fixed text in flash memory

Arduino / C: Keep fixed text in flash memory on an Uno with the Serial Monitor set to 9600 baud.

Arduino / C✓ Tested
CStructures & function interfaces

Keep function state between calls

C: A static local variable retains its stored value for the lifetime of the process.

C✓ Tested
PowerShellFunctions & parameter validation

Keep function-local assignments separate from caller state

PowerShell: Ordinary function assignments create local variables rather than replacing the caller’s variable.

PowerShell✓ Tested
Bash ScriptsProcesses & environment

Keep loop state by avoiding a pipeline subshell

Bash Scripts: Redirect input into a while loop so updates to a counter remain in the current shell.

Bash Scripts✓ Tested
ReactForms & validation

Keep numeric input text until conversion

Keep numeric input text until conversion with a small React component and explicit browser behavior.

React✓ Tested
ReactAsync work & status

Keep only the latest requested result

Keep only the latest requested result with a small React component and explicit browser behavior.

React✓ Tested
PythonMappings & sets

Keep only the most recent items

Python: Use a bounded deque to discard the oldest item as new values arrive.

Python✓ Tested
RustVectors & slices

Keep only values satisfying a condition

Keep only values satisfying a condition in a complete Rust program using the standard library.

Rust✓ Tested
SQLRelationships & missing data

Keep parent rows while filtering joined children

SQL: Put a child filter in ON when unmatched parents must remain in the result.

SQL✓ Tested
SQL ServerRelationships & missing data

Keep parent rows while filtering joined children

SQL Server: Put a child filter in ON when unmatched parents must remain in the result.

SQL Server✓ Tested
PostgresRelationships & missing data

Keep parent rows while filtering joined children

Postgres: Put a child filter in ON when unmatched parents must remain in the result.

Postgres✓ Tested