Skip to content

Commit efac77c

Browse files
committed
Update consolidated snippets
1 parent f8b4c64 commit efac77c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

public/consolidated/all_snippets.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[
2+
{"language": "scss", {"categoryName":"Typography","snippets":[{"title":"Line Clamp Mixin","description":"A Sass mixin to clamp text to a specific number of lines.","code":["@mixin line-clamp($number) {"," display: -webkit-box;"," -webkit-box-orient: vertical;"," -webkit-line-clamp: $number;"," overflow: hidden;","},"],"tags":["sass","mixin","typography","css"],"author":"technoph1le"},{"title":"Text Overflow Ellipsis","description":"Ensures long text is truncated with an ellipsis.","code":["@mixin text-ellipsis {"," overflow: hidden;"," white-space: nowrap;"," text-overflow: ellipsis;","}"],"tags":["sass","mixin","text","css"],"author":"technoph1le"},{"title":"Font Import Helper","description":"Simplifies importing custom fonts in Sass.","code":["@mixin import-font($family, $weight: 400, $style: normal) {"," @font-face {"," font-family: #{$family};"," font-weight: #{$weight};"," font-style: #{$style};"," src: url('/fonts/#{$family}-#{$weight}.woff2') format('woff2'),"," url('/fonts/#{$family}-#{$weight}.woff') format('woff');"," }","}"],"tags":["sass","mixin","fonts","css"],"author":"technoph1le"},{"title":"Text Gradient","description":"Adds a gradient color effect to text.","code":["@mixin text-gradient($from, $to) {"," background: linear-gradient(to right, $from, $to);"," -webkit-background-clip: text;"," -webkit-text-fill-color: transparent;","}"],"tags":["sass","mixin","gradient","text","css"],"author":"technoph1le"}]}
3+
{"language": "scss", {"categoryName":"Layouts","snippets":[{"title":"Grid Container","description":"Creates a responsive grid container with customizable column counts.","code":["@mixin grid-container($columns: 12, $gap: 1rem) {"," display: grid;"," grid-template-columns: repeat($columns, 1fr);"," gap: $gap;","},"],"tags":["scss","grid","layout","css"],"author":"technoph1le"},{"title":"Flex Center","description":"A mixin to center content using flexbox.","code":["@mixin flex-center {"," display: flex;"," justify-content: center;"," align-items: center;","}"],"tags":["scss","flex","center","css"],"author":"technoph1le"},{"title":"Aspect Ratio","description":"Ensures that elements maintain a specific aspect ratio.","code":["@mixin aspect-ratio($width, $height) {"," position: relative;"," width: 100%;"," padding-top: ($height / $width) * 100%;"," > * {"," position: absolute;"," top: 0;"," left: 0;"," width: 100%;"," height: 100%;"," }","}"],"tags":["scss","aspect-ratio","layout","css"],"author":"technoph1le"}]}
4+
{"language": "scss", {"categoryName":"Animations","snippets":[{"title":"Fade In Animation","description":"Animates the fade-in effect.","code":["@keyframes fade-in {"," from {"," opacity: 0;"," },"," to {"," opacity: 1;"," }","}","","@mixin fade-in($duration: 1s, $easing: ease-in-out) {"," animation: fade-in $duration $easing;","}"],"tags":["scss","animation","fade","css"],"author":"technoph1le"},{"title":"Slide In From Left","description":"Animates content sliding in from the left.","code":["@keyframes slide-in-left {"," from {"," transform: translateX(-100%);"," }"," to {"," transform: translateX(0);"," }","}","","@mixin slide-in-left($duration: 0.5s, $easing: ease-out) {"," animation: slide-in-left $duration $easing;","}"],"tags":["scss","animation","slide","css"],"author":"technoph1le"}]}
5+
{"language": "scss", {"categoryName":"Utilities","snippets":[{"title":"Responsive Breakpoints","description":"Generates media queries for responsive design.","code":["@mixin breakpoint($breakpoint) {"," @if $breakpoint == sm {"," @media (max-width: 576px) { @content; },"," } @else if $breakpoint == md {"," @media (max-width: 768px) { @content; }"," } @else if $breakpoint == lg {"," @media (max-width: 992px) { @content; }"," } @else if $breakpoint == xl {"," @media (max-width: 1200px) { @content; }"," }","}"],"tags":["scss","responsive","media-queries","css"],"author":"technoph1le"},{"title":"Clearfix","description":"Provides a clearfix utility for floating elements.","code":["@mixin clearfix {"," &::after {"," content: '';"," display: block;"," clear: both;"," }","}"],"tags":["scss","clearfix","utility","css"],"author":"technoph1le"}]}
6+
{"language": "scss", {"categoryName":"Borders & Shadows","snippets":[{"title":"Border Radius Helper","description":"Applies a customizable border-radius.","code":["@mixin border-radius($radius: 4px) {"," border-radius: $radius;","},"],"tags":["scss","border","radius","css"],"author":"technoph1le"},{"title":"Box Shadow Helper","description":"Generates a box shadow with customizable values.","code":["@mixin box-shadow($x: 0px, $y: 4px, $blur: 10px, $spread: 0px, $color: rgba(0, 0, 0, 0.1)) {"," box-shadow: $x $y $blur $spread $color;","}"],"tags":["scss","box-shadow","css","effects"],"author":"technoph1le"}]}
7+
{"language": "scss", {"categoryName":"Components","snippets":[{"title":"Primary Button","description":"Generates a styled primary button.","code":["@mixin primary-button($bg: #007bff, $color: #fff) {"," background-color: $bg;"," color: $color;"," padding: 0.5rem 1rem;"," border: none;"," border-radius: 4px;"," cursor: pointer;",""," &:hover {"," background-color: darken($bg, 10%);"," },","}"],"tags":["scss","button","primary","css"],"author":"technoph1le"}]}
8+
{"language": "_index", {"lang":"JavaScript","icon":"/icons/javascript.svg"},
9+
{"language": "_index", {"lang":"CSS","icon":"/icons/css.svg"},
10+
{"language": "_index", {"lang":"Python","icon":"/icons/python.svg"},
11+
{"language": "_index", {"lang":"SCSS","icon":"/icons/sass.svg"},
12+
{"language": "css", {"categoryName":"Typography","snippets":[{"title":"Responsive Font Sizing","description":"Adjusts font size based on viewport width.","code":["h1 {"," font-size: calc(1.5rem + 2vw);","},"],"tags":["css","font","responsive","typography"],"author":"technoph1le"},{"title":"Letter Spacing","description":"Adds space between letters for better readability.","code":["p {"," letter-spacing: 0.05em;","}"],"tags":["css","typography","spacing"],"author":"technoph1le"}]}
13+
{"language": "css", {"categoryName":"Layouts","snippets":[{"title":"Sticky Footer","description":"Ensures the footer always stays at the bottom of the page.","code":["body {"," display: flex;"," flex-direction: column;"," min-height: 100vh;","},","","footer {"," margin-top: auto;","}"],"tags":["css","layout","footer","sticky"],"author":"technoph1le"},{"title":"Equal-Width Columns","description":"Creates columns with equal widths using flexbox.","code":[".columns {"," display: flex;"," justify-content: space-between;","}","",".column {"," flex: 1;"," margin: 0 10px;","}"],"tags":["css","flexbox","columns","layout"],"author":"technoph1le"},{"title":"CSS Reset","description":"Resets some default browser styles, ensuring consistency across browsers.","code":["* {"," margin: 0;"," padding: 0;"," box-sizing: border-box","}"],"tags":["css","reset","browser","layout"],"author":"AmeerMoustafa"}]}
14+
{"language": "css", {"categoryName":"Buttons","snippets":[{"title":"Button Hover Effect","description":"Creates a hover effect with a color transition.","code":[".button {"," background-color: #007bff;"," color: white;"," padding: 10px 20px;"," border: none;"," border-radius: 5px;"," cursor: pointer;"," transition: background-color 0.3s ease;","},","",".button:hover {"," background-color: #0056b3;","}"],"tags":["css","button","hover","transition"],"author":"technoph1le"},{"title":"3D Button Effect","description":"Adds a 3D effect to a button when clicked.","code":[".button {"," background-color: #28a745;"," color: white;"," padding: 10px 20px;"," border: none;"," border-radius: 5px;"," box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);"," transition: transform 0.1s;","}","",".button:active {"," transform: translateY(2px);"," box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);","}"],"tags":["css","button","3D","effect"],"author":"technoph1le"}]}
15+
{"language": "css", {"categoryName":"Effects","snippets":[{"title":"Blur Background","description":"Applies a blur effect to the background of an element.","code":[".blur-background {"," backdrop-filter: blur(10px);"," background: rgba(255, 255, 255, 0.5);","},"],"tags":["css","blur","background","effects"],"author":"technoph1le"},{"title":"Hover Glow Effect","description":"Adds a glowing effect on hover.","code":[".glow {"," background-color: #f39c12;"," padding: 10px 20px;"," border-radius: 5px;"," transition: box-shadow 0.3s ease;","}","",".glow:hover {"," box-shadow: 0 0 15px rgba(243, 156, 18, 0.8);","}"],"tags":["css","hover","glow","effects"],"author":"technoph1le"}]}
16+
{"language": "javascript", {"categoryName":"Array Manipulation","snippets":[{"title":"Remove Duplicates","description":"Removes duplicate values from an array.","code":["const removeDuplicates = (arr) => [...new Set(arr)];","","// Usage:","const numbers = [1, 2, 2, 3, 4, 4, 5];","console.log(removeDuplicates(numbers)); // Output: [1, 2, 3, 4, 5]"],"tags":["javascript","array","deduplicate","utility"],"author":"technoph1le"},,{"title":"Flatten Array","description":"Flattens a multi-dimensional array.","code":["const flattenArray = (arr) => arr.flat(Infinity);","","// Usage:","const nestedArray = [1, [2, [3, [4]]]];","console.log(flattenArray(nestedArray)); // Output: [1, 2, 3, 4]"],"tags":["javascript","array","flatten","utility"],"author":"technoph1le"}]}
17+
{"language": "javascript", {"categoryName":"String Manipulation","snippets":[{"title":"Slugify String","description":"Converts a string into a URL-friendly slug format.","code":["const slugify = (string, separator = \"-\") => {"," return string"," .toString() // Cast to string (optional)"," .toLowerCase() // Convert the string to lowercase letters"," .trim() // Remove whitespace from both sides of a string (optional)"," .replace(/\\s+/g, separator) // Replace spaces with {separator},"," .replace(/[^\\w\\-]+/g, \"\") // Remove all non-word chars"," .replace(/\\_/g, separator) // Replace _ with {separator}"," .replace(/\\-\\-+/g, separator) // Replace multiple - with single {separator}"," .replace(/\\-$/g, \"\"); // Remove trailing -","};","","// Usage:","const title = \"Hello, World! This is a Test.\";","console.log(slugify(title)); // Output: 'hello-world-this-is-a-test'","console.log(slugify(title, \"_\")); // Output: 'hello_world_this_is_a_test'"],"tags":["javascript","string","slug","utility"],"author":"technoph1le"},{"title":"Capitalize String","description":"Capitalizes the first letter of a string.","code":["const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);","","// Usage:","console.log(capitalize('hello')); // Output: 'Hello'"],"tags":["javascript","string","capitalize","utility"],"author":"technoph1le"},{"title":"Reverse String","description":"Reverses the characters in a string.","code":["const reverseString = (str) => str.split('').reverse().join('');","","// Usage:","console.log(reverseString('hello')); // Output: 'olleh'"],"tags":["javascript","string","reverse","utility"],"author":"technoph1le"}]}
18+
{"language": "javascript", {"categoryName":"Date and Time","snippets":[{"title":"Format Date","description":"Formats a date in 'YYYY-MM-DD' format.","code":["const formatDate = (date) => date.toISOString().split('T')[0];","","// Usage:","console.log(formatDate(new Date())); // Output: '2024-12-10'"],"tags":["javascript","date","format","utility"],"author":"technoph1le"},,{"title":"Get Time Difference","description":"Calculates the time difference in days between two dates.","code":["const getTimeDifference = (date1, date2) => {"," const diff = Math.abs(date2 - date1);"," return Math.ceil(diff / (1000 * 60 * 60 * 24));","};","","// Usage:","const date1 = new Date('2024-01-01');","const date2 = new Date('2024-12-31');","console.log(getTimeDifference(date1, date2)); // Output: 365"],"tags":["javascript","date","time-difference","utility"],"author":"technoph1le"}]}
19+
{"language": "javascript", {"categoryName":"Function Utilities","snippets":[{"title":"Repeat Function Invocation","description":"Invokes a function a specified number of times.","code":["const times = (func, n) => {"," Array.from(Array(n)).forEach(() => {"," func();"," },);","};","","// Usage:","const randomFunction = () => console.log('Function called!');","times(randomFunction, 3); // Logs 'Function called!' three times"],"tags":["javascript","function","repeat","utility"],"author":"technoph1le"},{"title":"Debounce Function","description":"Delays a function execution until after a specified time.","code":["const debounce = (func, delay) => {"," let timeout;"," return (...args) => {"," clearTimeout(timeout);"," timeout = setTimeout(() => func(...args), delay);"," };","};","","// Usage:","window.addEventListener('resize', debounce(() => console.log('Resized!'), 500));"],"tags":["javascript","utility","debounce","performance"],"author":"technoph1le"},{"title":"Throttle Function","description":"Limits a function execution to once every specified time interval.","code":["const throttle = (func, limit) => {"," let lastFunc;"," let lastRan;"," return (...args) => {"," const context = this;"," if (!lastRan) {"," func.apply(context, args);"," lastRan = Date.now();"," } else {"," clearTimeout(lastFunc);"," lastFunc = setTimeout(() => {"," if (Date.now() - lastRan >= limit) {"," func.apply(context, args);"," lastRan = Date.now();"," }"," }, limit - (Date.now() - lastRan));"," }"," };","};","","// Usage:","document.addEventListener('scroll', throttle(() => console.log('Scrolled!'), 1000));"],"tags":["javascript","utility","throttle","performance"],"author":"technoph1le"}]}
20+
{"language": "javascript", {"categoryName":"DOM Manipulation","snippets":[{"title":"Toggle Class","description":"Toggles a class on an element.","code":["const toggleClass = (element, className) => {"," element.classList.toggle(className);","},;","","// Usage:","const element = document.querySelector('.my-element');","toggleClass(element, 'active');"],"tags":["javascript","dom","class","utility"],"author":"technoph1le"},{"title":"Smooth Scroll to Element","description":"Scrolls smoothly to a specified element.","code":["const smoothScroll = (element) => {"," element.scrollIntoView({ behavior: 'smooth' });","};","","// Usage:","const target = document.querySelector('#target');","smoothScroll(target);"],"tags":["javascript","dom","scroll","ui"],"author":"technoph1le"}]}
21+
{"language": "javascript", {"categoryName":"Local Storage","snippets":[{"title":"Add Item to localStorage","description":"Stores a value in localStorage under the given key.","code":["const addToLocalStorage = (key, value) => {"," localStorage.setItem(key, JSON.stringify(value));","},;","","// Usage:","addToLocalStorage('user', { name: 'John', age: 30 });"],"tags":["javascript","localStorage","storage","utility"],"author":"technoph1le"},{"title":"Retrieve Item from localStorage","description":"Retrieves a value from localStorage by key and parses it.","code":["const getFromLocalStorage = (key) => {"," const item = localStorage.getItem(key);"," return item ? JSON.parse(item) : null;","};","","// Usage:","const user = getFromLocalStorage('user');","console.log(user); // Output: { name: 'John', age: 30 }"],"tags":["javascript","localStorage","storage","utility"],"author":"technoph1le"},{"title":"Clear All localStorage","description":"Clears all data from localStorage.","code":["const clearLocalStorage = () => {"," localStorage.clear();","};","","// Usage:","clearLocalStorage(); // Removes all items from localStorage"],"tags":["javascript","localStorage","storage","utility"],"author":"technoph1le"}]}
22+
{"language": "python", {"categoryName":"String Manipulation","snippets":[{"title":"Reverse String","description":"Reverses the characters in a string.","code":["def reverse_string(s):"," return s[::-1]","","# Usage:","print(reverse_string('hello')) # Output: 'olleh'"],"tags":["python","string","reverse","utility"],"author":"technoph1le"},,{"title":"Check Palindrome","description":"Checks if a string is a palindrome.","code":["def is_palindrome(s):"," s = s.lower().replace(' ', '')"," return s == s[::-1]","","# Usage:","print(is_palindrome('A man a plan a canal Panama')) # Output: True"],"tags":["python","string","palindrome","utility"],"author":"technoph1le"}]}
23+
{"language": "python", {"categoryName":"List Manipulation","snippets":[{"title":"Flatten Nested List","description":"Flattens a multi-dimensional list into a single list.","code":["def flatten_list(lst):"," return [item for sublist in lst for item in sublist]","","# Usage:","nested_list = [[1, 2], [3, 4], [5]]","print(flatten_list(nested_list)) # Output: [1, 2, 3, 4, 5]"],"tags":["python","list","flatten","utility"],"author":"technoph1le"},,{"title":"Remove Duplicates","description":"Removes duplicate elements from a list while maintaining order.","code":["def remove_duplicates(lst):"," return list(dict.fromkeys(lst))","","# Usage:","print(remove_duplicates([1, 2, 2, 3, 4, 4, 5])) # Output: [1, 2, 3, 4, 5]"],"tags":["python","list","duplicates","utility"],"author":"technoph1le"}]}
24+
{"language": "python", {"categoryName":"File Handling","snippets":[{"title":"Read File Lines","description":"Reads all lines from a file and returns them as a list.","code":["def read_file_lines(filepath):"," with open(filepath, 'r') as file:"," return file.readlines()","","# Usage:","lines = read_file_lines('example.txt')","print(lines)"],"tags":["python","file","read","utility"],"author":"technoph1le"},,{"title":"Write to File","description":"Writes content to a file.","code":["def write_to_file(filepath, content):"," with open(filepath, 'w') as file:"," file.write(content)","","# Usage:","write_to_file('example.txt', 'Hello, World!')"],"tags":["python","file","write","utility"],"author":"technoph1le"},{"title":"Find Files","description":"Finds all files of the specified type within a given directory.","code":["import os","","def find_files(directory, file_type):"," file_type = file_type.lower() # Convert file_type to lowercase"," found_files = []",""," for root, _, files in os.walk(directory):"," for file in files:"," file_ext = os.path.splitext(file)[1].lower()"," if file_ext == file_type:"," full_path = os.path.join(root, file)"," found_files.append(full_path)",""," return found_files","","# Example Usage:","pdf_files = find_files('/path/to/your/directory', '.pdf')","print(pdf_files)"],"tags":["python","os","filesystem","file_search"],"author":"Jackeastern"}]}
25+
{"language": "python", {"categoryName":"Math and Numbers","snippets":[{"title":"Find Factorial","description":"Calculates the factorial of a number.","code":["def factorial(n):"," if n == 0:"," return 1"," return n * factorial(n - 1)","","# Usage:","print(factorial(5)) # Output: 120"],"tags":["python","math","factorial","utility"],"author":"technoph1le"},,{"title":"Check Prime Number","description":"Checks if a number is a prime number.","code":["def is_prime(n):"," if n <= 1:"," return False"," for i in range(2, int(n**0.5) + 1):"," if n % i == 0:"," return False"," return True","","# Usage:","print(is_prime(17)) # Output: True"],"tags":["python","math","prime","check"],"author":"technoph1le"}]}
26+
{"language": "python", {"categoryName":"Utilities","snippets":[{"title":"Measure Execution Time","description":"Measures the execution time of a code block.","code":["import time","","def measure_time(func, *args):"," start = time.time()"," result = func(*args)"," end = time.time()"," print(f'Execution time: {end - start:.6f}, seconds')"," return result","","# Usage:","def slow_function():"," time.sleep(2)","","measure_time(slow_function)"],"tags":["python","time","execution","utility"],"author":"technoph1le"},{"title":"Generate Random String","description":"Generates a random alphanumeric string.","code":["import random","import string","","def random_string(length):"," letters_and_digits = string.ascii_letters + string.digits"," return ''.join(random.choice(letters_and_digits) for _ in range(length))","","# Usage:","print(random_string(10)) # Output: Random 10-character string"],"tags":["python","random","string","utility"],"author":"technoph1le"}]}
27+
]

0 commit comments

Comments
 (0)