Results for “Type & reading flow”
Small, practical examples. Search by task or narrow things down below.
Parse a JSON string
Convert a JSON string into a Python dictionary and read values by key.
json✓ Tested
Parse a short option with getopts
Read a named option and handle invalid flags explicitly.
getopts✓ Tested
Parse and format a date
Convert a date string into a datetime object, then format it in a different, human-readable order.
date✓ Tested
Parse JSON text
Read a JavaScript object from JSON text.
JavaScript✓ Tested
Parse quoted CSV from an in-memory string
Python: Use StringIO with csv.reader so quoted commas are handled correctly.
Python✓ Tested
Pass a function as a callback
C: A typed function pointer permits behavior to be supplied to another function.
C✓ Tested
Preconfigure some function arguments
Python: Use partial to produce a callable with selected arguments already bound.
Python✓ Tested
Preserve equal-key order while sorting records
C++: stable_sort retains encounter order for records whose selected sort keys compare equal.
C++✓ Tested
Prevent an item from shrinking
CSS: Flex-shrink zero preserves a required size even when the container overflows.
CSS✓ Tested
Print a number with two decimal places
C++: Format a small decimal value consistently for display.
C++✓ Tested
Process a file as a lazy line sequence
C#: ReadLines avoids allocating one string containing the entire file.
C#✓ Tested
Process a first-in first-out queue
C++: Queue exposes its front item separately from the operation that removes it.
C++✓ Tested