Results for “when”
Small, practical examples. Search by task or narrow things down below.
Restore an environment value after temporary use
PowerShell: Use finally so temporary process configuration does not leak to subsequent work; remove the entry when it was originally absent.
PowerShell✓ Tested
Return a small immutable named record
Python: Use NamedTuple when callers need both tuple behavior and named fields.
Python✓ Tested
Run a one-off container
Run a command and remove its stopped container automatically.
run✓ Tested
Run cleanup through a scoped destructor
C++: A stack object’s destructor runs when its scope exits, including normal exception unwinding.
C++✓ Tested
Run with a read-only root filesystem
Add a temporary writable location while protecting the image filesystem.
read-only✓ Tested
Search for a literal string
Linux Commands: Use grep -F when the pattern contains regex metacharacters that should be literal.
Linux Commands✓ Tested
Select an inclusive range
Find rows with values between two endpoints.
BETWEEN✓ Tested
Select fields with the Pick utility type
Expose a smaller view of a larger object type.
Pick✓ Tested
Select specific columns
Read only the fields a result needs.
SELECT✓ Tested
Select the largest values without sorting everything
Python: Use heapq.nlargest when only a small prefix of the ranking is required.
Python✓ Tested
Set a JSON property
Create an updated JSON document from existing text.
json_set✓ Tested
Set and inspect a memory limit
Apply a per-container limit when creating a container.
memory✓ Tested