Gists
Share and discover code snippets418 gists
Sort array of objects
Sorts an array of objects by a specified property using JavaScript's native sort method with a comparator function.
Flexbox Centering Hack
A single line of CSS centers any child element perfectly within its parent using Flexbox.
Read file line by line
This Python snippet reads a file line by line, processing each line efficiently without loading the entire file into memory.
map and filter
Transforms an array by applying a function to each element and then filtering based on a condition, all in one step.
Rename files in batch
This snippet renames multiple files at once using a bash loop with pattern matching.
File size check
This bash snippet checks if a file exceeds a specified size limit before proceeding with an operation.
Image Lazy Loading
This HTML snippet enables images to load only when they enter the viewport, improving page performance.
concat int slices
This function takes two integer slices and returns a new slice containing all elements from the first followed by all elements from the second.
rsearch — Multi-Source Search Aggregator API Documentation
Full documentation for the rsearch.app.molodetz.nl multi-source search aggregator. Covers web UI, JSON API, AI mode, chat, image description, caching, health endpoint, and error handling. Published 20...
Get unique values array
This snippet removes duplicates from an array, returning a new array containing only unique values.
Binary search algorithm
This Python snippet uses binary search to quickly locate a target value in a sorted list by repeatedly dividing the search range in half.
RAII file wrapper
A C++ RAII file wrapper automatically opens a file in its constructor and closes it in its destructor, preventing resource leaks.
Question mark operator
The question mark operator in Rust unwraps a `Result` or `Option`, returning the success value or propagating the error/`None` from the current function.
RAII lock guard
A C++ RAII lock guard automatically acquires a mutex upon construction and releases it upon destruction, ensuring exception safe lock management.
Array map with index
Transforms each element of an array using both its value and index, returning a new array with the results.
HTML5 Boilerplate Template
Get your HTML projects off to a solid start with this template that includes best practices for cross-browser compatibility, accessibility, and performance.
idiomatic error handling
This snippet demonstrates Go's convention of returning errors as values and checking them with if statements, keeping error handling explicit and predictable.
Find duplicate records
This SQL snippet identifies duplicate records by grouping rows based on key columns and filtering for counts greater than one.
quick sort function
This TypeScript function sorts an array in place using the quicksort algorithm with a recursive divide-and-conquer approach.
flatten nested lists
This snippet flattens nested lists of any depth into a single flat list, perfect for simplifying complex data structures.
Simple PDO query
This snippet demonstrates a simple PDO query using prepared statements to safely retrieve data from a database.