FIND YOUR NEXT FEW LINES

Results for “ref”

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

130 snippets foundClear filters
Bash ScriptsDiagnostics & defensive scripting

Refuse to overwrite an existing file with redirection

Bash Scripts: Noclobber makes a plain greater-than redirection fail when the target already exists.

Bash Scripts✓ Tested
AngularLifecycle & observable data

Register cleanup through DestroyRef

Register cleanup through DestroyRef with a standalone Angular component and explicit browser behavior.

Angular✓ Tested
PythonText validation & encoding

Remove a known prefix safely

Python: Use removeprefix instead of lstrip when removing a literal prefix rather than a set of characters.

Python✓ Tested
Bash ScriptsParameter expansion

Remove a known prefix with a shell pattern

Bash Scripts: The hash expansion removes the shortest matching prefix without changing the original variable.

Bash Scripts✓ Tested
RustStrings & Unicode

Remove a prefix only when it matches

Remove a prefix only when it matches in a complete Rust program using the standard library.

Rust✓ Tested
GoStrings & text

Remove an optional prefix

Remove an optional prefix using a complete Go program with explicit sample inputs.

Go✓ Tested
Docker / ComposeImage management

Remove one tag while retaining another reference

Docker / Compose: Removing a tag does not delete an image still referenced by another tag.

Docker / Compose✓ Tested
GitRemotes & additional checkouts

Remove stale remote-tracking references

Git: Fetch with prune removes tracking references for branches no longer present on the remote.

Git✓ Tested
CSSInteraction & themes

Respect dark color preference

Apply different CSS colors when the browser requests a dark theme.

CSS✓ Tested
Bash ScriptsFunction scope & composition

Return an array through a nameref

Bash Scripts: Assign through a nameref to preserve array element boundaries.

Bash Scripts✓ Tested
ReactRefs & DOM interaction

Scroll a referenced element into view

Scroll a referenced element into view with a small React component and explicit browser behavior.

React✓ Tested
C++Ordering & set operations

Sort only the smallest requested prefix

C++: partial_sort orders the selected prefix without guaranteeing the order of the remainder.

C++✓ Tested