All snippets
307 snippets
camelCase
VerifiedConverts any string (spaces, kebab, snake, Pascal) to camelCase.
Capitalize
VerifiedUppercases the first character of a string.
Chunk Array
VerifiedSplits an array into groups of a given size, e.g. for batching API requests or building grids.
Clamp
VerifiedRestricts a number to an inclusive minimum and maximum.
Debounce
VerifiedDelays a function until calls stop for N ms. Includes cancel() and flush().
Deep Clone
VerifiedDeep-clones objects, arrays, Dates, Maps and Sets, including circular references.
Deep Merge
VerifiedDeeply merges objects into a new object without mutation and without prototype pollution.
Escape HTML
VerifiedEscapes &, <, >, " and ' so untrusted text can be safely inserted into HTML.
Format Bytes
VerifiedFormats a byte count as a human-readable size (KB, MB, GB…).
Format Currency
VerifiedFormats a number as localized currency using Intl.NumberFormat.
Get Initials
VerifiedExtracts up to N uppercase initials from a name, e.g. for avatar fallbacks.
Get Path
VerifiedSafely reads a nested value by a dot/bracket path with a fallback.
Group By
VerifiedGroups an array of items into an object keyed by a property or computed value.
Hex to RGB
VerifiedParses 3, 4, 6 or 8-digit hex colors into RGB(A), returning null for invalid input.
kebab-case
VerifiedConverts any string (spaces, snake, camel, Pascal) to kebab-case.
Memoize
VerifiedCaches a function's results by its arguments, with an optional custom cache key.
Omit
VerifiedReturns a new object without the given keys, fully typed.
Once
VerifiedCreates a function that runs only once and returns the first result on later calls.
PascalCase
VerifiedConverts any string (spaces, kebab, snake, camel) to PascalCase.
Pick
VerifiedReturns a new object with only the given keys, fully typed.
Relative Time
VerifiedFormats a date relative to now ("3 hours ago", "in 2 days"), localized via Intl.
Retry with Backoff
VerifiedRetries an async function with exponential backoff and jitter, with an optional stop condition and AbortSignal.
RGB to Hex
VerifiedConverts RGB(A) channels to a hex color string, clamping out-of-range values.
Safe JSON Parse
VerifiedParses JSON without throwing and returns a typed { ok, value | error } result.
Shuffle
VerifiedReturns a uniformly shuffled copy of an array (Fisher–Yates) without mutating it.
Sleep
VerifiedPromise-based delay with optional AbortSignal cancellation.
Slugify
VerifiedConverts a string into a URL-friendly slug, stripping accents and symbols.
snake_case
VerifiedConverts any string (spaces, kebab, camel, Pascal) to snake_case.
Throttle
VerifiedRuns a function at most once per N ms, with a trailing call so the last update is never lost.
Title Case
VerifiedConverts a sentence to Title Case, keeping minor words like "of" and "the" lowercase.
Truncate
VerifiedShortens text to a maximum length with a suffix, optionally on a word boundary.
Typed localStorage
VerifiedTyped, SSR-safe localStorage wrapper with JSON serialization that never throws.
Unique
VerifiedRemoves duplicates from an array, optionally by a key or function, keeping order.
3D Button Effect
Adds a 3D effect to a button when clicked.
Allow Alphanumeric
A validation function to allow alphanumeric characters.
Allow Decimal
A validation function to allow only decimal numbers.
Allow Digits with A Max Length
A validation function to allow only digits with a specified maximum length.
Allow Lowercase
A validation function to allow only lowercase alphabetic characters.
Allow Negative Integers
A validation function to allow only negative integers.
Allow Numbers in Range
A validation function to allow only numbers within a specified range.
Allow Only Alphabets
A validation function to allow only alphabetic characters.
Allow Only Digits
A validation function to allow only digits.
Allow Positive Integers
A validation function to allow only positive integers.
Allow signed Decimals
A validation function to allow only signed decimal numbers.
Allow Signed Integers
A validation function to allow only signed integers.
Allow Specific Characters
A validation function to allow specific characters.
Allow Uppercase
A validation function to allow uppercase letters.
Ascii To String
Converts a list of ascii numbers into a string
Aspect Ratio
Ensures that elements maintain a specific aspect ratio.
At Least One Key
Ensures that at least one property of an object is required.
Binary Search
Searches for an element in a sorted array using the Binary Search algorithm.
Binary Search
Searches for an element in a sorted array using binary search.
Binary to Unsigned Integer Conversion
Converts a binary number represented as a string to its decimal equivalent.
Bit Counting
Counts the set bits in the binary representation of an integer
Blink Animation
Adds an infinite blinking animation to an element
Blur Background
Applies a blur effect to the background of an element.
Border Radius Helper
Applies a customizable border-radius.
Box Shadow Helper
Generates a box shadow with customizable values.
Bubble Sort
Sorts an array of integers using the Bubble Sort algorithm.
Button Hover Effect
Creates a hover effect with a color transition.
Calculate Compound Interest
Calculates compound interest for a given principal amount, rate, and time period.
Calculate Date Difference in Milliseconds
Calculates the difference between two dates in milliseconds.
Calculate Factorial
Computes the factorial of a given integer.
CamelCase to snake_case
Converts a Camel Case string to Snake case.
Capitalize first letter
Makes the first letter of a string uppercase.
Capitalize Words
Capitalizes the first letter of each word in a string.
Change Element Style
Changes the inline style of an element.
Check Anagram
Checks if two strings are anagrams, meaning they contain the same characters ignoring order, spaces and case sensitivity
Check if Date is a Weekend
Checks whether a given date falls on a weekend.
Check if Item Exists in localStorage
Checks if a specific item exists in localStorage.
Check if Object is Empty
Checks whether an object has no own enumerable properties.
Check if String is a Palindrome
Checks whether a given string is a palindrome.
Check Leap Year
Determines if a given year is a leap year.
Check Palindrome
Checks if a string reads the same backward as forward, ignoring whitespaces and case sensitivity
Check Perfect Number
Checks if a number is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself).
Check Perfect Square
Checks if a number is a perfect square.
Check Power of Two
Checks if a given number is a power of two using bitwise operations.
Check Prime Number
Check if an integer is a prime number
Checksum
Calculates the checksum of an int
Chunk Array
Splits an array into chunks of a specified size.
Clear ith bit
Clear the ith bit of a number and returns the resulting number
Clearfix
Provides a clearfix utility for floating elements.
Combinations
Calculates the number of combinations (denoted as C(n,r) or "n choose r"), which determines how many ways you can select r items from n items without considering the order.
Compare Arrays
Deeply compares two arrays to check if they are equal to each other (supports nested arrays and objects).
Compare Two Objects Shallowly
Compares two objects shallowly and returns whether they are equal.
Compose Functions
Composes multiple functions into a single function, where the output of one function becomes the input of the next.
Compound Interest
Calculates the compound interest for a given principal, rate, time, and number of times interest applied per time period.
Context Menu
Opens a menu when you right click a widget.
Convert Binary to Decimal
Converts a binary string to its decimal equivalent.
Convert Bytes to Human-Readable Format
Converts a size in bytes to a human-readable format.
Convert Number to Roman Numerals
Converts a number to Roman numeral representation.
Convert Object to Query String
Converts an object to a query string for use in URLs.
Convert Snake Case to Camel Case
Converts a snake_case string to camelCase.
Convert String to Unicode
Converts a string into its Unicode representation.
Convert Tabs to Spaces
Converts all tab characters in a string to spaces.
Convert to Scientific Notation
Converts a number to scientific notation.
Convert to Unix Timestamp
Converts a date to a Unix timestamp in seconds.
Count Character Frequency
Counts the frequency of each character in a string
Count Character Occurrences
Counts the occurrences of the specified characters in a given string
Count Properties in Object
Counts the number of own properties in an object.
Count Set Bits
Counts the number of set bits in an int
Count Vowels
Counts the number of vowels in a string.
Count Word Occurrences in String
Counts the occurrences of each word in a given string.
Count Words
Counts the number of words in a string
Count Words in a String
Counts the number of words in a string.
Create Custom Exception Type
Create a Custom Exception Type that can be called with raise.
Create SQLite Database Table
Creates a table in an SQLite database with a dynamic schema.
Cross Product
Computes the cross product of two 3D vectors, which results in a vector perpendicular to both.
CSS Reset
Resets some default browser styles, ensuring consistency across browsers.
Curry Function
Transforms a function into its curried form.
Custom Error Class
Defines and raises a custom error class in Ruby.
Custom Regular Expression
A validation function to match a regular expression pattern.
Dark Theme
SCSS mixin to change styles for dark themes.
Data with Prefix
Adds a prefix and postfix to data, with a fallback value.
Date Time Formatting American
Formats a timestamp to a human-readable date-time string in the format "MM/dd/yyyy hh:mm:ss a"
Date Time Formatting European
Formats a timestamp to a human-readable date-time string in the format "dd.MM.yyyy HH:mm:ss"
Day of the Week String
Gets the string of the day of the week for a given date.
Decode JWT
Decodes a JWT.
Deep Partial Type
Converts all properties of a type, including nested objects, into optional.
Deep Readonly Type
Converts all properties of a type, including nested objects, into readonly.
Deep Required Type
Converts all properties of a type, including nested objects, into required.
Display a Pillow Image
Use Pillow to show an image in a Tkinter window.
Dot Product
Computes the dot product of two vectors, which is the sum of the products of corresponding elements.
Duration Formatting Hours Minutes Seconds
Converts a given time duration to a human-readable string in the format "hh:mm(:ss)"
Duration Formatting Minutes Seconds
Converts a given time duration to a human-readable string in the format "mm:ss"
Either Monad for Error Handling
Using the Either monad to handle errors in a computation.
Email Address
Match any email address
Equal-Width Columns
Creates columns with equal widths using flexbox.
Error function
Computes the error function (erf(x)) for a given input x, which is a mathematical function used frequently in probability, statistics, and partial differential equations.
Exclusive Types
Allows to have a type which conforms to either/or.
Extract Text Between Delimiters
Extracts a text between two given delimiters from a string
Factorial
Computes the factorial of a given number
Factorial Function
Calculates the factorial of a number.
Fade In Animation
Animates the fade-in effect.
Fibonacci
Calculates the nth fibonacci number
Fibonacci Number
Calculates the nth Fibonacci number using recursion.
Filter
Filters a vector using a predicate function.
Filter
Filter a string with a predicate function
Filter JSON Data
Filters a JSON object based on a condition and returns the filtered data.
Filter Object
Filter out entries in an object where the value is falsy, including empty strings, empty objects, null, and undefined.
Find all primes up to integer (Sieve of Sundaram)
Finds all the prime numbers up to a specific integer.
Find All Substrings
Finds all substrings of a given string.
Find Duplicates in a List
Identifies duplicate elements in a list.
Find files
Find all the files in a directory using a predicate function.
Find Files in Directory by Type
Finds all files in a directory with a specific extension.
Find files recursively
Find all the files in a directory and subdirectories using a predicate function.
Find Intersection of Two Lists
Finds the common elements between two lists.
Find LCM (Least Common Multiple)
Calculates the least common multiple (LCM) of two numbers.
Find Longest Word
Returns the longest word in a string
Find Maximum Difference in List
Finds the maximum difference between any two elements in a list.
Find Non-Repeating Number
Finds the number that appears only once in an array where every other number appears twice.
Find Unique Characters
Returns a set of unique characters from a string, with options to include spaces and control case sensitivity
Flatten Nested JSON
Flattens a nested JSON object into a flat dictionary.
Flatten Nested List
Flattens a multi-dimensional list into a single list.
Flatten Nested Object
Flattens a nested object into a single-level object with dot notation for keys.
Flatten Unevenly Nested Lists
Converts unevenly nested lists of any depth into a single flat list.
Flex Center
A mixin to center content using flexbox.
Font Import Helper
Simplifies importing custom fonts in Sass.
Format Date
Formats a date in 'YYYY-MM-DD' format.
Format Number with Commas
Formats a number with commas for better readability (e.g., 1000 -> 1,000).
Freeze Object
Freezes an object to make it immutable.
Generate Date Range List
Generates a list of dates between two given dates.
Generate GUID
Generates a new GUID
Generate Random String
Generates a random alphanumeric string.
Generate UUID
Generates a UUID (v4) string.
Get Contrast Color
Returns either black or white text color based on the brightness of the provided hex color.
Get Current Date and Time as String
Fetches the current date and time as a formatted string.
Get Day of the Year
Calculates the day of the year (1-365 or 1-366 for leap years) for a given date.
Get Days in Month
Calculates the number of days in a specific month of a given year.
Get Desktop Enviroment
Get the Desktop Enviroment that the user is currently using.
Get File Extension
Gets the extension of a file.
Get ith bit
Get the i-th bit of a number
Get Number of Days in a Month
Determines the number of days in a specific month and year.
Get Time Difference
Calculates the time difference in days between two dates.
Greatest Common Divisor
Calculates the greatest common divisor (gcd) of two numbers
Grid Container
Creates a responsive grid container with customizable column counts.
Grid layout
Equal sized items in a responsive grid
Grid Layout with Navigation
Full-height grid layout with header navigation using nesting syntax.
Hexadecimal Color
Matches hex color codes
Hover Glow Effect
Adds a glowing effect on hover.
Hover to Reveal Color
A card with an image that transitions from grayscale to full color on hover.
HSL to RGB Color
Converts HSL color values to RGB color values.
Insert Data into Sqlite Table
Inserts a row into a specified SQLite table using a dictionary of fields and values.
Insertion Sort
Sorts an array of integers using the Insertion Sort algorithm.
Invert Object Keys and Values
Creates a new object by swapping keys and values of the given object.
IPv4
Matches IPv4 address
Is Odd
Check if a number is odd
Is Power Of Two
Checks if a number is a power of two
Keys of Type
Extracts keys from an object type that match a specified value type.
Keys to Optional
Makes only the specified keys of an object type optional.
Kill Previous Instances
Kill all previous instances of a script
Least Common Multiple
Calculates the least common multiple (lcm) of two numbers
Letter Spacing
Adds space between letters for better readability.
Line Clamp Mixin
A Sass mixin to clamp text to a specific number of lines.
Linear Mapping
remaps a value from one range to another
Linear Search
Searches for an element in an array using the Linear Search algorithm.
List Directories
Lists all the directories in a path.
List Files in Directory
Lists all files in a specified directory.
MacOS Button
A macOS-like button style, with hover and shading effects.
Mask Sensitive Information
Masks parts of a sensitive string, like a credit card or email address.
Mask Text
Masks portions of a string, leaving specific parts at the beginning and end visible while replacing the rest with a specified character
Matrix Multiplication
Multiplies two matrices, where the number of columns in the first matrix equals the number of rows in the second.
Matrix Transpose
Transposes a 2D matrix.
Maybe Monad
Using the Maybe monad to handle computations that might fail.
Measure Execution Time
Measures the execution time of a code block.
Merge Multiple JSON Files
Merges multiple JSON files into one and writes the merged data into a new file.
Merge Sort
Sorts an array of integers using the Merge Sort algorithm.
Modular Inverse
Computes the modular multiplicative inverse of a number a under modulo m, which is the integer x such that (a*x) mod m=1.
Normalize Whitespace
Replaces consecutive whitespaces with a single space
Nullable Keys
Extracts keys from an object type that allow null or undefined values.
Number Formatter
Formats a number with suffixes (K, M, B, etc.).
Number to Words Converter
Converts a number to its word representation in English.
Omit Keys of Type
Removes keys of a specified type from an object type.
Pad String on Both Sides
Pads a string on both sides with a specified character until it reaches the desired length.
Palindrome
Check if a string is a palindrome or not.
Partition Array
Splits an array into two arrays based on a callback function.
Partition List
Partitions a list into sublists of a given size.
Password Generator
Generates a random string with specified length and character set, including options for letters, numbers, and special characters
Primary Button
Generates a styled primary button.
Prime Check
Checks if a number is a prime
Prime Number
Checks if a number is a prime number or not.
Pulse Animation
Adds a smooth pulsing animation with opacity and scale effects
PX to REM Helper
This function will convert px values to rem values.
Query Data from Sqlite Table
Fetches data from a specified SQLite table, with options for selecting specific columns and applying a WHERE clause.
Quick Sort
Sorts an array of integers using the Quick Sort algorithm.
Random string
Generates a random string of characters of a certain length
Rate Limit Function
Limits how often a function can be executed within a given time window.
Read File in Chunks
Reads a file in chunks grouped by lines.
Read File Lines
Reads all lines from a file and returns them as a vector of strings.
Read JSON File
Reads a JSON file and parses its content.
Remove All Whitespace
Removes all whitespace from a string.
Remove Characters
Removes specific characters from a string.
Remove Duplicate Characters
Removes duplicate characters from a string while maintaining the order.
Remove Element
Removes a specified element from the DOM.
Remove Falsy Values
Removes falsy values from an array.
Remove n Occurences
Removes duplicates from an vector of ints
Remove Punctuation
Removes all punctuation from a given string.
Remove Special Characters
Removes any character which is not alphabetic (A-Z, a-z) or numeric (0-9)
Remove Vowels from a String
Removes all vowels from a given string.
Remove Whitespace
Removes all whitespace from a string.
Repeat Function Invocation
Invokes a function a specified number of times.
Required Keys
Extracts required keys from an object.
Responsive Breakpoints
Generates media queries for responsive design.
Responsive Design
The different responsive breakpoints.
Responsive Font Sizing
Adjusts font size based on viewport width.
Restrict Length
A validation function to limit the length.
Retrieve Item from localStorage
Retrieves a value from localStorage by key and parses it.
Retry Function Execution on Exception
Retries a function execution a specified number of times if it raises an exception.
Reverse Bits
Reverses the bits of a given unsigned integer.
Reverse String
Reverses the characters in a string.
Reverse Word Contents
Reverses the characters of each word in a string while preserving word order
Reverse Word Order
Reverses the order of words in a sentence while preserving the content of each word
RGB Border Color Animation
changes border of an Element to rgb onhover (Can be changed)'
RGB to HSL Color
Converts RGB color values to HSL color values.
Selection Sort
Sorts an array of integers using the Selection Sort algorithm.
Set ith bit
Set the i-th bit of a number and returns the resulting number
Shake Animation
Adds a shake animation ( commonly used to mark invalid fields )
Slide In From Left
Animates content sliding in from the left.
Slide-in Animation
Adds a slide-in from the right side of the screen
Snake_Case to CamelCase
Converts a Snake Case string to Camel Case.
Solve Quadratic Equation
Solves a quadratic equation ax^2 + bx + c = 0 and returns the roots.
spaces-to-tabs
Converts spaces into tabs
Spacing
This SCSS snippet dynamically generates utility classes for managing spacing in a consistent and efficient manner. The classes are built using a loop, ensuring scalability and flexibility. use .mt-* for margin-top, and .pb-* for padding bottom
Split Camel Case
Splits a camel case string into separate words.
Split String
Splits a string by a delimiter
Start of the Day
Returns the start of the day (midnight) for a given date.
State Monad
Managing mutable state using the State monad.
Sticky Footer
Ensures the footer always stays at the bottom of the page.
Sticky Header-Footer Layout
Full-height layout with sticky header and footer, using modern viewport units and flexbox.
String To Ascii
Converts a string into ascii numbers
String To camelCase
Converts a string into camelCase
String To PascalCase
Converts a string into PascalCase
String To Titlecase
Converts a string into Title Case, where the first letter of each word is capitalized and the remaining letters are lowercase
String To Unicode
Converts characters of a string into their unicode representation
Strong Password
Match password with at least 12 characters, one uppercased letter, one number, and one special character.
Sum of Digits
Calculates the sum of the digits of an integer.
Swap items at index
Swaps two items at determined indexes
Swap numbers
Swaps two numbers without using third variable
Swap Numbers
Swap two numbers without a temporary variable
System Resource Monitor
Monitors system resources (CPU, RAM, disk, users)
tabs-to-spaces
Converts tabs into spaces
Text Gradient
Adds a gradient color effect to text.
Text Overflow Ellipsis
Ensures long text is truncated with an ellipsis.
Toggle ith bit
Toggle the i-th bit of a number and returns the resulting number
Transform
Transforms a vector using a function.
Transform
Transform a string with a function
Transform Camel Case to Snake Case
Converts a Camel or Pascal Case string to Snake case.
Transform from Snake Case to Camel Case
Converts a Snake Case string to Camel Case.
Transform from Snake Case to Pascal Case
Converts a Snake Case string to Pascal Case.
Typewriter Animation
Adds a typewriter animation + blinking cursor
Unicode To String
Converts a unicode String into its normal representation
Unintentional Duplication
Matches duplicated word in a text.
Union to Intersection
Converts a union type into an intersection type.
Unique By Key
Filters an array of objects to only include unique objects by a specified key.
Update JSON File
Updates an existing JSON file with new data or modifies the existing values.
Update Records in Sqlite Table
Updates records in a specified SQLite table, allowing dynamic column updates and an optional WHERE clause.
Validate File Path
A validation function to ensure the file path exists.
Validate GUID
Checks if a string is a valid GUID.
Validate JWT
Validates a JWT.
Vector Print
Overloads the << operator to print the contents of a vector just like in python.
Vector to Queue
Convert vector into queue quickly
Whitespace Trimmer
Matches leading and/or trailing whitespace.
Write JSON File
Writes a dictionary to a JSON file.
Writer Monad
Using the Writer monad to accumulate logs or other outputs alongside a computation.
XOR of Range
Finds XOR of all numbers from 1 to n using properties of XOR.
Zip Arrays
Combines two arrays by pairing corresponding elements from each array.
Zip Two Lists
Zips two lists into a list of paired elements, combining corresponding elements from both lists.