FIND YOUR NEXT FEW LINES

Results for “all”

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

1115 snippets foundClear filters
PythonDates & time zones

Advance a date by a number of days

Python: Use timedelta so month and year boundaries are handled automatically.

Python✓ Tested
ReactAccessibility & events

Announce a status update politely

Announce a status update politely with a small React component and explicit browser behavior.

React✓ Tested
CStrings & byte buffers

Append text only when the destination has enough capacity

C: Check the combined lengths including the terminator before using strcat.

C✓ Tested
C++Files & paths

Append text to a file

Open a C++ stream in append mode and verify the write.

C++✓ Tested
CFiles

Append text to a file

Use append mode in C without replacing the existing file.

C✓ Tested
ReactGetting Started

Append to an array without mutating state

Append to an array without mutating state with a small React component and explicit browser behavior.

React✓ Tested
SQLConstraints & defaults

Apply a default when an insert omits a column

SQL: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.

SQL✓ Tested
SQL ServerConstraints & defaults

Apply a default when an insert omits a column

SQL Server: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.

SQL Server✓ Tested
PostgresConstraints & defaults

Apply a default when an insert omits a column

Postgres: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.

Postgres✓ Tested
SQLiteConstraints & defaults

Apply a default when an insert omits a column

SQLite: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.

SQLite✓ Tested
C++Ownership & optional values

Apply an operation to a variant’s active value

C++: A generic visitor lets the compiler check behavior for every possible alternative.

C++✓ Tested
ReactGetting Started

Assign a CSS class in JSX

Assign a CSS class in JSX with a small React component and explicit browser behavior.

React✓ Tested