FIND YOUR NEXT FEW LINES

Results for “when”

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

230 snippets foundClear filters
Linux CommandsTransforming text

Convert tab stops to spaces

Linux Commands: Use expand with a fixed tab width when preparing plain-text alignment.

Linux Commands✓ Tested
SQL ServerSelect & page

Convert text without raising a conversion error

Return NULL when a numeric conversion fails.

TRY_CONVERT✓ Tested
Arduino / CText & bounded buffers

Copy a string with a guaranteed terminator

Arduino / C: Reserve one character for the terminator when copying a bounded string.

Arduino / C✓ Tested
PythonMappings & sets

Copy nested mutable data independently

Python: Use deepcopy when changes to nested lists must not affect the original object.

Python✓ Tested
CStrings

Copy text into a fixed buffer

Use snprintf and check for truncation when copying a C string.

C✓ Tested
GitRestoring & revising local work

Correct the latest unpublished commit message

Git: Amend replaces the current commit while preserving its tree when no new changes are staged.

Git✓ Tested
Arduino / CDigital input & output

Count a falling edge with an interrupt

Increment a counter when an external input changes.

attachInterrupt✓ Tested
Arduino / CDigital signals & interrupts

Count a rising edge with an interrupt

Arduino / C: RISING triggers when the input changes from low to high.

Arduino / C✓ Tested
SQLExpressions & aggregates

Count rows per category

Aggregate rows sharing the same category.

GROUP BY✓ Tested
JavaText validation & formatting

Count Unicode code points

Java: Use codePointCount when supplementary characters should count as one rather than two UTF-16 units.

Java✓ Tested
Linux CommandsFiles & folders

Create a directory tree

Create a directory and its missing parent directories. The -p option also succeeds when the directories already exist.

directory✓ Tested
Docker / ComposeDockerfile patterns

Create a runtime file during the build

Docker / Compose: RUN executes during the build while CMD executes when a container starts.

Docker / Compose✓ Tested