FIND YOUR NEXT FEW LINES

The snippet library.

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

3000 snippets foundClear filters
RustIterators & transformations

Accumulate a result with fold

Accumulate a result with fold in a complete Rust program using the standard library.

Rust✓ Tested
PowerShellFunctions & parameter validation

Accumulate pipeline input across begin process and end

PowerShell: Keep initialization and final output separate from per-item work.

PowerShell✓ Tested
CSSResponsive conditions & sizing

Adapt a component to its own container width

CSS: Container queries respond to a selected ancestor rather than the full viewport.

CSS✓ Tested
CSSResponsive conditions & sizing

Adapt a layout to viewport orientation

CSS: The orientation query compares viewport dimensions rather than detecting a physical device type.

CSS✓ Tested
HTMLGetting Started

Add a button with an explicit type

HTML: Learn how to add a button with an explicit type in a complete browser example.

HTML✓ Tested
PowerShellHashtables & object records

Add a calculated property during selection

PowerShell: A calculated property can derive a value while retaining selected original properties.

PowerShell✓ Tested
CSSResponsive conditions & sizing

Add a clear boundary in forced-colors mode

CSS: Use a system color for a border when the user’s forced-color mode is active.

CSS✓ Tested
jQueryGetting Started

Add a CSS class

jQuery: Learn how to add a CSS class in a complete browser example.

jQuery✓ Tested
C#Collections & data structures

Add a dictionary entry only if absent

C#: TryAdd reports a duplicate key without replacing its existing value.

C#✓ Tested
Docker / ComposeCompose service options

Add a fixed hostname mapping

Docker / Compose: extra_hosts adds an entry to the container’s hosts file.

Docker / Compose✓ Tested
GitRestoring & revising local work

Add a forgotten file to the latest unpublished commit

Git: Stage the missing file before amending without changing the message.

Git✓ Tested
HTMLForms

Add a multiline text field

Set a maximum length and visible rows on a labeled HTML textarea.

HTML✓ Tested