FIND YOUR NEXT FEW LINES

The snippet library.

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

3000 snippets foundClear filters
SQLiteConstraints & defaults

Reject duplicate business identifiers

SQLite: A UNIQUE constraint protects a business key independently of the primary key.

SQLite✓ Tested
C++Numeric parsing & calculations

Reject infinite and NaN numeric values

C++: std::isfinite excludes special floating-point values.

C++✓ Tested
C#Dates & precise numbers

Reject infinity and NaN

C#: Double.IsFinite distinguishes usable finite numeric inputs from special values.

C#✓ Tested
Arduino / CArrays & embedded state

Reject insertion when a fixed queue is full

Arduino / C: Track a count separately from circular read and write positions.

Arduino / C✓ Tested
PythonNumbers & calculations

Reject NaN and infinite numeric inputs

Python: Use isfinite before computations that require an ordinary finite float.

Python✓ Tested
PowerShellDates & numeric validation

Reject NaN and infinite values

PowerShell: Double.IsFinite excludes numeric values unsuitable for ordinary bounded calculations.

PowerShell✓ Tested
CNumeric parsing & arithmetic

Reject NaN and infinite values

C: isfinite detects whether a floating-point value is an ordinary finite number.

C✓ Tested
GoErrors & validation

Reject non-finite numeric input

Reject non-finite numeric input using a complete Go program with explicit sample inputs.

Go✓ Tested
JavaPrecise numeric calculations

Reject nonfinite floating-point values

Java: Double.isFinite excludes both infinity and NaN.

Java✓ Tested
Arduino / CSensor calculations

Reject one outlier with a median-of-three filter

Arduino / C: Sorting three values leaves the median in the middle.

Arduino / C✓ Tested
GoJSON & encoding

Reject unknown JSON object fields

Reject unknown JSON object fields using a complete Go program with explicit sample inputs.

Go✓ Tested
ReactRefs & DOM interaction

Remember the previously committed value

Remember the previously committed value with a small React component and explicit browser behavior.

React✓ Tested