FIND YOUR NEXT FEW LINES

Results for “Stashing selected work”

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

608 snippets foundClear filters
PythonFunctions & error handling

Preconfigure some function arguments

Python: Use partial to produce a callable with selected arguments already bound.

Python✓ Tested
Bash ScriptsArray operations

Prepend items while preserving existing array values

Bash Scripts: Construct a new array with the new values before the quoted original expansion.

Bash Scripts✓ Tested
Bash ScriptsProcesses & environment

Preserve a failure status while an EXIT trap runs

Bash Scripts: Capture the status immediately on entry to the trap before running cleanup commands.

Bash Scripts✓ Tested
GoJSON & encoding

Preserve a large JSON integer

Preserve a large JSON integer using a complete Go program with explicit sample inputs.

Go✓ Tested
C++Ordering & set operations

Preserve equal-key order while sorting records

C++: stable_sort retains encounter order for records whose selected sort keys compare equal.

C++✓ Tested
Bash ScriptsDiagnostics & defensive scripting

Prevent a variable value from expanding as a filename pattern

Bash Scripts: Quote a variable to pass its literal contents even when matching filenames exist.

Bash Scripts✓ Tested
RustGetting Started

Print a collection for inspection

Print a collection for inspection in a complete Rust program using the standard library.

Rust✓ Tested
Bash ScriptsText parsing & arithmetic

Print text containing percent characters literally

Bash Scripts: Never use untrusted text as the printf format string.

Bash Scripts✓ Tested
RustVectors & slices

Process a slice in bounded chunks

Process a slice in bounded chunks in a complete Rust program using the standard library.

Rust✓ Tested
RustErrors & optional values

Propagate a parsing error with question mark

Propagate a parsing error with question mark in a complete Rust program using the standard library.

Rust✓ Tested
GoConcurrency & cancellation

Protect a shared counter

Protect a shared counter using a complete Go program with explicit sample inputs.

Go✓ Tested
RustThreads & shared ownership

Protect shared mutable state with a mutex

Protect shared mutable state with a mutex in a complete Rust program using the standard library.

Rust✓ Tested