FIND YOUR NEXT FEW LINES

Results for “or”

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

2638 snippets foundClear filters
PythonDates & time zones

Convert an aware datetime to another offset

Python: Use astimezone for conversion; replacing tzinfo alone does not convert an instant.

Python✓ Tested
C++Text validation & parsing

Convert ASCII text to lowercase safely

C++: Cast each byte to unsigned char before using the cctype function.

C++✓ Tested
CStrings

Convert ASCII text to uppercase

Convert characters with toupper while avoiding signed-char undefined behavior.

C✓ Tested
JavaEncoding & structured values

Convert bytes to hexadecimal and back

Java: Use HexFormat for a standard-library representation of raw bytes.

Java✓ Tested
JavaScriptUTC date operations

Convert epoch milliseconds to whole seconds

JavaScript: JavaScript Date stores milliseconds while many APIs use Unix seconds.

JavaScript✓ Tested
TypeScriptUTC date operations

Convert epoch milliseconds to whole seconds

TypeScript: JavaScript Date stores milliseconds while many APIs use Unix seconds.

TypeScript✓ Tested
PythonText validation & encoding

Convert hexadecimal text to bytes

Python: Use bytes.fromhex for a readable byte representation and hex for the reverse conversion.

Python✓ Tested
PythonGetting Started

Convert known numeric text to an integer

Python: Convert a trusted literal to an integer before adding. Validate external input before converting it.

Python✓ Tested
C#Getting Started

Convert known numeric text to an integer

C#: Convert a trusted literal to an integer before adding. Validate external input before converting it.

C#✓ Tested
JavaGetting Started

Convert known numeric text to an integer

Java: Convert a trusted literal to an integer before adding. Validate external input before converting it.

Java✓ Tested
JavaScriptGetting Started

Convert known numeric text to an integer

JavaScript: Convert a trusted literal to an integer before adding. Validate external input before converting it.

JavaScript✓ Tested
TypeScriptGetting Started

Convert known numeric text to an integer

TypeScript: Convert a trusted literal to an integer before adding. Validate external input before converting it.

TypeScript✓ Tested