Gists
Share and discover code snippetsconcurrent HTTP requests
A Go code snippet that fires off multiple HTTP requests in parallel using goroutines and a sync.WaitGroup to handle them concurrently.
Sort array descending
This Rust code snippet sorts an array in descending order using the sortby method with a comparison closure.
Array destructuring swap
Swaps two variables without a temporary variable using array destructuring.
Center with Flexbox
This CSS snippet centers any child element both horizontally and vertically inside a flex container.
Array Shuffle Fisher Yates
Shuffles an array in place using the Fisher-Yates algorithm for uniform random distribution.
Array destructuring swap
Swaps two values without a temporary variable by using array destructuring assignment.
Iterate with enumerate
Enumerate in Rust lets you iterate over a collection while automatically tracking the index of each element.
Async file read
This snippet reads the contents of a file asynchronously using Tokio's tokio::fs::readtostring function.
Ternary inline condition
Returns one of two values based on a true or false condition, mimicking an if-else statement in a single line.
COALESCE for defaults
Returns the first non-null value from a list, making it easy to set fallback defaults for missing data.
Flexbox Center Alignment
This snippet centers a child element both horizontally and vertically within its parent using Flexbox.
truncate cascade tables
This SQL snippet drops all dependent foreign key relationships before truncating a table.
File exists check
This Bash snippet returns true before attempting to write if a file exists, preventing overwrite errors.
PHP array map filter
Applies a callback to each element of an array, then filters the results based on a condition.
re.sub cleanup string
This Python snippet uses regex to remove unwanted characters or patterns from a string.
Move Semantics Example
This snippet demonstrates efficient resource transfer by using move semantics to avoid expensive deep copies when passing temporary objects.
RefCell runtime borrow
Provides interior mutability with runtime borrow checking, ensuring safe mutation of values behind shared references.
Practical lambda invoke
This snippet demonstrates how to immediately invoke a C++ lambda expression to execute a block of code inline.
Hashing for equality works great until you hit a collision, and then you're stuck debugging a false positive that looks like a bug in your comparison logic.