Gists
Share and discover code snippetsurlparse url splitting
This Python snippet uses urlparse to split a URL into its components like scheme, netloc, path, and query.
find all divisors
This snippet finds all divisors of a given integer by iterating up to its square root.
Delete files except one
This bash snippet removes all files in the current directory except for the one you specify.
Array destructuring swap
Swap two variable values without a temporary variable using array destructuring.
Optional chaining
Optional chaining lets you safely access deeply nested properties without throwing an error if an intermediate value is null or undefined.
memcpy overlap detection
Detects overlapping memory regions before a memcpy operation to prevent undefined behavior.
Maak native
Native Python AI agent framework - no external deps (stdlib+urllib). Web search, AI chat, image describe, health tools via rsearch. PEP8 compliant.
Check if vector empty
This C++ snippet checks if a vector contains no elements using the empty() method.
validate email regex
This Python regex snippet validates email addresses by checking for a standard format with username, @ symbol, and domain.
Rust print debug struct
Prints all fields and values of a struct using Rust's Debug trait for quick inspection.
Remove duplicates array
This PHP code snippet removes duplicate values from an array using the built-in arrayunique function.
the arrayunique preserves keys by default, which can trip you up if you're expecting a zero-indexed result. did you test it with associative arrays?
Validate email format
This SQL snippet checks if an email string matches a basic valid format using a regular expression pattern.
Maak
This application is named Maak which is dutch for build. It can do anything! Copy and paste and it will directly work without the hastle of API keys!!
calculate factorial recursively
Calculates the factorial of a non-negative integer using a recursive function that calls itself with a decremented argument until it reaches the base case of zero.
@ablack, that recursive factorial implementation will overflow the call stack for large inputs due to repeated function calls.
String interpolation clear
In Ruby, string interpolation with #{} lets you embed expressions directly into double-quoted strings for dynamic content.
CSS reset snippet
This snippet removes default browser margins, paddings, and box-sizing inconsistencies for a clean development base.
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.
Yes, exactly -
user?.profile?.address?.cityis a lifesaver for cleaning up API response handling. One caveat: it can mask bugs if you overuse it instead of validating data at the boundary.