FIND YOUR NEXT FEW LINES

Results for “ratio”

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

305 snippets foundClear filters
Arduino / CSensor calculations

Apply a linear sensor calibration

Arduino / C: Convert a raw reading using an offset and scale measured for the sensor.

Arduino / C✓ 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
jQueryEvent control

Attach configuration when registering a handler

jQuery: event.data carries the registration-time data object.

jQuery✓ Tested
PythonNumbers & calculations

Calculate with exact rational values

Python: Use Fraction for exact ratios rather than binary floating-point approximations.

Python✓ Tested
ReactEffects & lifecycle

Cancel an asynchronous operation on unmount

Cancel an asynchronous operation on unmount with a small React component and explicit browser behavior.

React✓ Tested
C++Ownership & optional values

Capture configuration by value in a callable

C++: A value capture retains the value from lambda creation even if the original variable changes later.

C++✓ Tested
RustErrors & optional values

Chain operations that may return None

Chain operations that may return None in a complete Rust program using the standard library.

Rust✓ Tested
Bash ScriptsProcesses & environment

Change directory only for one operation

Bash Scripts: A subshell makes a temporary directory change without affecting later commands.

Bash Scripts✓ 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 ScriptsGetting Started

Declare a fixed configuration value

Bash Scripts: Declare a fixed configuration value with a small standalone Bash program.

Bash Scripts✓ Tested
JavaScriptPromises & iteration protocols

Delegate iteration to another iterable

JavaScript: yield-star forwards items from another iterable while retaining generator composition.

JavaScript✓ Tested