FIND YOUR NEXT FEW LINES

Results for “code”

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

3000 snippets foundClear filters
Arduino / CArrays & embedded state

Use named states for a controller

Arduino / C: An enum makes state transitions easier to read than unexplained numbers.

Arduino / C✓ Tested
ReactForms & validation

Use native required-field validation

Use native required-field validation with a small React component and explicit browser behavior.

React✓ Tested
ReactContext & shared state

Use React 19’s provider shorthand

Use React 19’s provider shorthand with a small React component and explicit browser behavior.

React✓ Tested
HTMLGetting Started

Use semantic page landmarks

HTML: Learn how to use semantic page landmarks in a complete browser example.

HTML✓ Tested
JavaScriptPromises & iteration protocols

Use the first fulfilled promise result

JavaScript: Promise.any ignores individual rejections until one input fulfills.

JavaScript✓ Tested
TypeScriptPromises & iteration protocols

Use the first fulfilled promise result

TypeScript: Promise.any ignores individual rejections until one input fulfills.

TypeScript✓ Tested
CNumeric parsing & arithmetic

Validate a complete floating-point input

C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.

C✓ Tested
JavaText validation & formatting

Validate a complete identifier

Java: String.matches requires the regular expression to match the entire input.

Java✓ Tested
C++Text validation & parsing

Validate a complete identifier

C++: regex_match requires the pattern to match the complete input sequence.

C++✓ Tested
C#Text validation & encoding

Validate a complete identifier with a regex

C#: Use absolute anchors and a timeout so the regex checks the complete input with a bounded execution time.

C#✓ Tested
Arduino / CSerial protocols

Validate a complete numeric serial command

Arduino / C: Check for digits, an end pointer, and an application-specific range.

Arduino / C✓ Tested
jQueryEvent control

Validate a field when focus leaves it

jQuery: focusout bubbles and can support delegated form validation.

jQuery✓ Tested