FIND YOUR NEXT FEW LINES

Results for “Small algorithms & bit operations”

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

443 snippets foundClear filters
PythonFile operations & archives

Read compressed text directly

Python: Open gzip data in text mode with an explicit encoding.

Python✓ Tested
JavaScriptUTC date operations

Read date components in UTC

JavaScript: UTC accessors avoid differences caused by the machine’s local timezone.

JavaScript✓ Tested
TypeScriptUTC date operations

Read date components in UTC

TypeScript: UTC accessors avoid differences caused by the machine’s local timezone.

TypeScript✓ Tested
C++Filesystem operations

Read the byte size of a regular file

C++: file_size reads filesystem metadata without loading file contents.

C++✓ Tested
PowerShellArray operations

Read the last array element

PowerShell: A negative array index counts backward from the end.

PowerShell✓ Tested
Bash ScriptsArray operations

Remove an indexed element and compact the array

Bash Scripts: Unsetting an element leaves a gap; reassigning the values creates consecutive indices.

Bash Scripts✓ Tested
JavaQueues & collection operations

Remove collection items that satisfy a condition

Java: Use removeIf on a mutable collection to avoid changing it manually inside a for-each loop.

Java✓ Tested
PowerShellFile operations & integrity

Rename a file in its current directory

PowerShell: Rename-Item changes the name without moving the item to another directory.

PowerShell✓ Tested
PythonFile operations & archives

Rename a file within a directory

Python: Use Path.rename and inspect the resulting path.

Python✓ Tested
C++Filesystem operations

Rename a known file through filesystem

C++: filesystem::rename reports an error by exception when the operation fails.

C++✓ Tested
C#File operations & paths

Replace a path extension

C#: Path.ChangeExtension transforms a path string without moving or creating a file.

C#✓ Tested
PowerShellArray operations

Reverse a copy while preserving the source

PowerShell: Clone the array before using Array.Reverse because Reverse mutates its argument.

PowerShell✓ Tested