Results for “File operations & binary data”
Small, practical examples. Search by task or narrow things down below.
Construct a date from Unix seconds
TypeScript: Multiply seconds by 1000 before creating a Date.
TypeScript✓ Tested
Convert ASCII text to lowercase safely
C: Cast to unsigned char before calling ctype functions on a possibly signed char.
C✓ Tested
Convert bytes to Base64 and back
C#: Encode text to UTF-8 before converting it to a Base64 representation.
C#✓ Tested
Convert epoch milliseconds to whole seconds
JavaScript: JavaScript Date stores milliseconds while many APIs use Unix seconds.
JavaScript✓ Tested
Convert epoch milliseconds to whole seconds
TypeScript: JavaScript Date stores milliseconds while many APIs use Unix seconds.
TypeScript✓ Tested
Copy a directory while preserving attributes
Linux Commands: Use cp -a for a recursive local copy that preserves links and ordinary file attributes.
Linux Commands✓ Tested
Copy a directory’s contents into an image
Docker / Compose: A directory COPY includes its children at the destination.
Docker / Compose✓ Tested
Copy a stream and count its bytes
Copy a stream and count its bytes using a complete Go program with explicit sample inputs.
Go✓ Tested
Copy an array independently
Bash Scripts: A new array assignment copies element values rather than creating a shared reference.
Bash Scripts✓ Tested
Copy an artifact from an earlier build stage
Docker / Compose: A named stage can produce an artifact without copying its other files.
Docker / Compose✓ Tested
Count days between UTC-midnight dates
JavaScript: A day is exactly 86400000 milliseconds for these explicitly UTC-midnight inputs.
JavaScript✓ Tested
Count days between UTC-midnight dates
TypeScript: A day is exactly 86400000 milliseconds for these explicitly UTC-midnight inputs.
TypeScript✓ Tested