FIND YOUR NEXT FEW LINES

The snippet library.

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

3000 snippets foundClear filters
ReactForms & validation

Control a radio-button group

Control a radio-button group with a small React component and explicit browser behavior.

React✓ Tested
ReactGetting Started

Control a select element

Control a select element with a small React component and explicit browser behavior.

React✓ Tested
ReactGetting Started

Control a text input

Control a text input with a small React component and explicit browser behavior.

React✓ Tested
Arduino / CDigital input & output

Control an LED from a button

Translate an active-low button input into an LED output.

button✓ Tested
CSSType & reading flow

Control tab width in preformatted content

CSS: Tab-size defines the interval of tab stops in a preformatted block.

CSS✓ Tested
CSSVisual treatment & accessibility

Control the size of a repeated background tile

CSS: Background-size sets the rendered dimensions of each repeated background image.

CSS✓ Tested
C++Tasks & synchronization

Convert a duration to another unit explicitly

C++: duration_cast converts units and truncates fractional integer units.

C++✓ Tested
PythonDates & time zones

Convert a duration to hours and minutes

Python: Use divmod to split nonnegative whole seconds into display components.

Python✓ Tested
Bash ScriptsVariables & text

Convert a string to lowercase

Normalize a text value using Bash expansion.

lowercase✓ Tested
Arduino / CSensor calculations

Convert a supplied ADC count to volts

Arduino / C: Scale a ten-bit ADC count using an explicit reference voltage.

Arduino / C✓ Tested
C#Dates & precise numbers

Convert a timestamp to a different fixed offset

C#: ToOffset changes the displayed local time while retaining the same instant.

C#✓ Tested
PythonDates & time zones

Convert a Unix timestamp to aware UTC

Python: Supply timezone.utc so the result does not depend on the machine time zone.

Python✓ Tested