Skip to content

Commit a0d7395

Browse files
committed
Added snippets for js, python, css and scss
1 parent f842a51 commit a0d7395

File tree

14 files changed

+434
-37
lines changed

14 files changed

+434
-37
lines changed

public/data/css.json

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,76 @@
11
[
22
{
3-
"categoryName": "DOM Manipulation",
3+
"categoryName": "Typography",
44
"snippets": [
55
{
6-
"title": "Add a class to an element",
7-
"description": "Add a CSS class to a DOM element.",
8-
"code": "document.getElementById('myElement').classList.add('myClass');",
9-
"tags": ["dom", "class", "javascript"],
6+
"title": "Responsive Font Sizing",
7+
"description": "Adjusts font size based on viewport width.",
8+
"code": "h1 {\n font-size: calc(1.5rem + 2vw);\n}",
9+
"tags": ["css", "font", "responsive", "typography"],
1010
"author": "@technoph1le"
1111
},
1212
{
13-
"title": "Remove a class from an element",
14-
"description": "Remove a CSS class from a DOM element.",
15-
"code": "document.getElementById('myElement').classList.remove('myClass');",
16-
"tags": ["dom", "class", "javascript"],
13+
"title": "Letter Spacing",
14+
"description": "Adds space between letters for better readability.",
15+
"code": "p {\n letter-spacing: 0.05em;\n}",
16+
"tags": ["css", "typography", "spacing"],
17+
"author": "@technoph1le"
18+
}
19+
]
20+
},
21+
{
22+
"categoryName": "Layouts",
23+
"snippets": [
24+
{
25+
"title": "Sticky Footer",
26+
"description": "Ensures the footer always stays at the bottom of the page.",
27+
"code": "body {\n display: flex;\n flex-direction: column;\n min-height: 100vh;\n}\n\nfooter {\n margin-top: auto;\n}",
28+
"tags": ["css", "layout", "footer", "sticky"],
29+
"author": "@technoph1le"
30+
},
31+
{
32+
"title": "Equal-Width Columns",
33+
"description": "Creates columns with equal widths using flexbox.",
34+
"code": ".columns {\n display: flex;\n justify-content: space-between;\n}\n\n.column {\n flex: 1;\n margin: 0 10px;\n}",
35+
"tags": ["css", "flexbox", "columns", "layout"],
36+
"author": "@technoph1le"
37+
}
38+
]
39+
},
40+
{
41+
"categoryName": "Buttons",
42+
"snippets": [
43+
{
44+
"title": "Button Hover Effect",
45+
"description": "Creates a hover effect with a color transition.",
46+
"code": ".button {\n background-color: #007bff;\n color: white;\n padding: 10px 20px;\n border: none;\n border-radius: 5px;\n cursor: pointer;\n transition: background-color 0.3s ease;\n}\n\n.button:hover {\n background-color: #0056b3;\n}",
47+
"tags": ["css", "button", "hover", "transition"],
1748
"author": "@technoph1le"
1849
},
1950
{
20-
"title": "Something else",
21-
"description": "Remove a CSS class from a DOM element.",
22-
"code": "document.getElementById('myElement').classList.remove('myClass');",
23-
"tags": ["dom", "class", "javascript"],
51+
"title": "3D Button Effect",
52+
"description": "Adds a 3D effect to a button when clicked.",
53+
"code": ".button {\n background-color: #28a745;\n color: white;\n padding: 10px 20px;\n border: none;\n border-radius: 5px;\n box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);\n transition: transform 0.1s;\n}\n\n.button:active {\n transform: translateY(2px);\n box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);\n}",
54+
"tags": ["css", "button", "3D", "effect"],
2455
"author": "@technoph1le"
2556
}
2657
]
2758
},
2859
{
29-
"categoryName": "API Requests",
60+
"categoryName": "Effects",
3061
"snippets": [
3162
{
32-
"title": "Fetch data from API",
33-
"description": "Use the Fetch API to retrieve data.",
34-
"code": "fetch('https://api.example.com/data').then(response => response.json()).then(data => console.log(data));",
35-
"tags": ["api", "fetch", "javascript"],
63+
"title": "Blur Background",
64+
"description": "Applies a blur effect to the background of an element.",
65+
"code": ".blur-background {\n backdrop-filter: blur(10px);\n background: rgba(255, 255, 255, 0.5);\n}",
66+
"tags": ["css", "blur", "background", "effects"],
67+
"author": "@technoph1le"
68+
},
69+
{
70+
"title": "Hover Glow Effect",
71+
"description": "Adds a glowing effect on hover.",
72+
"code": ".glow {\n background-color: #f39c12;\n padding: 10px 20px;\n border-radius: 5px;\n transition: box-shadow 0.3s ease;\n}\n\n.glow:hover {\n box-shadow: 0 0 15px rgba(243, 156, 18, 0.8);\n}",
73+
"tags": ["css", "hover", "glow", "effects"],
3674
"author": "@technoph1le"
3775
}
3876
]

public/data/index.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
[
22
{
3-
"lang": "SCSS",
4-
"icon": "/icons/sass.svg"
3+
"lang": "JavaScript",
4+
"icon": "/icons/javascript.svg"
55
},
66
{
77
"lang": "CSS",
88
"icon": "/icons/css.svg"
9+
},
10+
{
11+
"lang": "Python",
12+
"icon": "/icons/python.svg"
13+
},
14+
{
15+
"lang": "SCSS",
16+
"icon": "/icons/sass.svg"
917
}
1018
]

public/data/javascript.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[
2+
{
3+
"categoryName": "Array Manipulation",
4+
"snippets": [
5+
{
6+
"title": "Remove Duplicates",
7+
"description": "Removes duplicate values from an array.",
8+
"code": "const removeDuplicates = (arr) => [...new Set(arr)];\n\n// Usage:\nconst numbers = [1, 2, 2, 3, 4, 4, 5];\nconsole.log(removeDuplicates(numbers)); // Output: [1, 2, 3, 4, 5]",
9+
"tags": ["javascript", "array", "deduplicate", "utility"],
10+
"author": "@technoph1le"
11+
},
12+
{
13+
"title": "Flatten Array",
14+
"description": "Flattens a multi-dimensional array.",
15+
"code": "const flattenArray = (arr) => arr.flat(Infinity);\n\n// Usage:\nconst nestedArray = [1, [2, [3, [4]]]];\nconsole.log(flattenArray(nestedArray)); // Output: [1, 2, 3, 4]",
16+
"tags": ["javascript", "array", "flatten", "utility"],
17+
"author": "@technoph1le"
18+
}
19+
]
20+
},
21+
{
22+
"categoryName": "String Manipulation",
23+
"snippets": [
24+
{
25+
"title": "Capitalize String",
26+
"description": "Capitalizes the first letter of a string.",
27+
"code": "const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);\n\n// Usage:\nconsole.log(capitalize('hello')); // Output: 'Hello'",
28+
"tags": ["javascript", "string", "capitalize", "utility"],
29+
"author": "@technoph1le"
30+
},
31+
{
32+
"title": "Reverse String",
33+
"description": "Reverses the characters in a string.",
34+
"code": "const reverseString = (str) => str.split('').reverse().join('');\n\n// Usage:\nconsole.log(reverseString('hello')); // Output: 'olleh'",
35+
"tags": ["javascript", "string", "reverse", "utility"],
36+
"author": "@technoph1le"
37+
}
38+
]
39+
},
40+
{
41+
"categoryName": "Date and Time",
42+
"snippets": [
43+
{
44+
"title": "Format Date",
45+
"description": "Formats a date in 'YYYY-MM-DD' format.",
46+
"code": "const formatDate = (date) => date.toISOString().split('T')[0];\n\n// Usage:\nconsole.log(formatDate(new Date())); // Output: '2024-12-10'",
47+
"tags": ["javascript", "date", "format", "utility"],
48+
"author": "@technoph1le"
49+
},
50+
{
51+
"title": "Get Time Difference",
52+
"description": "Calculates the time difference in days between two dates.",
53+
"code": "const getTimeDifference = (date1, date2) => {\n const diff = Math.abs(date2 - date1);\n return Math.ceil(diff / (1000 * 60 * 60 * 24));\n};\n\n// Usage:\nconst date1 = new Date('2024-01-01');\nconst date2 = new Date('2024-12-31');\nconsole.log(getTimeDifference(date1, date2)); // Output: 365",
54+
"tags": ["javascript", "date", "time-difference", "utility"],
55+
"author": "@technoph1le"
56+
}
57+
]
58+
},
59+
{
60+
"categoryName": "Utilities",
61+
"snippets": [
62+
{
63+
"title": "Debounce Function",
64+
"description": "Delays a function execution until after a specified time.",
65+
"code": "const debounce = (func, delay) => {\n let timeout;\n return (...args) => {\n clearTimeout(timeout);\n timeout = setTimeout(() => func(...args), delay);\n };\n};\n\n// Usage:\nwindow.addEventListener('resize', debounce(() => console.log('Resized!'), 500));",
66+
"tags": ["javascript", "utility", "debounce", "performance"],
67+
"author": "@technoph1le"
68+
},
69+
{
70+
"title": "Throttle Function",
71+
"description": "Limits a function execution to once every specified time interval.",
72+
"code": "const throttle = (func, limit) => {\n let lastFunc;\n let lastRan;\n return (...args) => {\n const context = this;\n if (!lastRan) {\n func.apply(context, args);\n lastRan = Date.now();\n } else {\n clearTimeout(lastFunc);\n lastFunc = setTimeout(() => {\n if (Date.now() - lastRan >= limit) {\n func.apply(context, args);\n lastRan = Date.now();\n }\n }, limit - (Date.now() - lastRan));\n }\n };\n};\n\n// Usage:\ndocument.addEventListener('scroll', throttle(() => console.log('Scrolled!'), 1000));",
73+
"tags": ["javascript", "utility", "throttle", "performance"],
74+
"author": "@technoph1le"
75+
}
76+
]
77+
},
78+
{
79+
"categoryName": "DOM Manipulation",
80+
"snippets": [
81+
{
82+
"title": "Toggle Class",
83+
"description": "Toggles a class on an element.",
84+
"code": "const toggleClass = (element, className) => {\n element.classList.toggle(className);\n};\n\n// Usage:\nconst element = document.querySelector('.my-element');\ntoggleClass(element, 'active');",
85+
"tags": ["javascript", "dom", "class", "utility"],
86+
"author": "@technoph1le"
87+
},
88+
{
89+
"title": "Smooth Scroll to Element",
90+
"description": "Scrolls smoothly to a specified element.",
91+
"code": "const smoothScroll = (element) => {\n element.scrollIntoView({ behavior: 'smooth' });\n};\n\n// Usage:\nconst target = document.querySelector('#target');\nsmoothScroll(target);",
92+
"tags": ["javascript", "dom", "scroll", "ui"],
93+
"author": "@technoph1le"
94+
}
95+
]
96+
}
97+
]

public/data/python.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[
2+
{
3+
"categoryName": "String Manipulation",
4+
"snippets": [
5+
{
6+
"title": "Reverse String",
7+
"description": "Reverses the characters in a string.",
8+
"code": "def reverse_string(s):\n return s[::-1]\n\n# Usage:\nprint(reverse_string('hello')) # Output: 'olleh'",
9+
"tags": ["python", "string", "reverse", "utility"],
10+
"author": "@technoph1le"
11+
},
12+
{
13+
"title": "Check Palindrome",
14+
"description": "Checks if a string is a palindrome.",
15+
"code": "def is_palindrome(s):\n s = s.lower().replace(' ', '')\n return s == s[::-1]\n\n# Usage:\nprint(is_palindrome('A man a plan a canal Panama')) # Output: True",
16+
"tags": ["python", "string", "palindrome", "utility"],
17+
"author": "@technoph1le"
18+
}
19+
]
20+
},
21+
{
22+
"categoryName": "List Manipulation",
23+
"snippets": [
24+
{
25+
"title": "Flatten Nested List",
26+
"description": "Flattens a multi-dimensional list into a single list.",
27+
"code": "def flatten_list(lst):\n return [item for sublist in lst for item in sublist]\n\n# Usage:\nnested_list = [[1, 2], [3, 4], [5]]\nprint(flatten_list(nested_list)) # Output: [1, 2, 3, 4, 5]",
28+
"tags": ["python", "list", "flatten", "utility"],
29+
"author": "@technoph1le"
30+
},
31+
{
32+
"title": "Remove Duplicates",
33+
"description": "Removes duplicate elements from a list while maintaining order.",
34+
"code": "def remove_duplicates(lst):\n return list(dict.fromkeys(lst))\n\n# Usage:\nprint(remove_duplicates([1, 2, 2, 3, 4, 4, 5])) # Output: [1, 2, 3, 4, 5]",
35+
"tags": ["python", "list", "duplicates", "utility"],
36+
"author": "@technoph1le"
37+
}
38+
]
39+
},
40+
{
41+
"categoryName": "File Handling",
42+
"snippets": [
43+
{
44+
"title": "Read File Lines",
45+
"description": "Reads all lines from a file and returns them as a list.",
46+
"code": "def read_file_lines(filepath):\n with open(filepath, 'r') as file:\n return file.readlines()\n\n# Usage:\nlines = read_file_lines('example.txt')\nprint(lines)",
47+
"tags": ["python", "file", "read", "utility"],
48+
"author": "@technoph1le"
49+
},
50+
{
51+
"title": "Write to File",
52+
"description": "Writes content to a file.",
53+
"code": "def write_to_file(filepath, content):\n with open(filepath, 'w') as file:\n file.write(content)\n\n# Usage:\nwrite_to_file('example.txt', 'Hello, World!')",
54+
"tags": ["python", "file", "write", "utility"],
55+
"author": "@technoph1le"
56+
}
57+
]
58+
},
59+
{
60+
"categoryName": "Math and Numbers",
61+
"snippets": [
62+
{
63+
"title": "Find Factorial",
64+
"description": "Calculates the factorial of a number.",
65+
"code": "def factorial(n):\n if n == 0:\n return 1\n return n * factorial(n - 1)\n\n# Usage:\nprint(factorial(5)) # Output: 120",
66+
"tags": ["python", "math", "factorial", "utility"],
67+
"author": "@technoph1le"
68+
},
69+
{
70+
"title": "Check Prime Number",
71+
"description": "Checks if a number is a prime number.",
72+
"code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\n# Usage:\nprint(is_prime(17)) # Output: True",
73+
"tags": ["python", "math", "prime", "check"],
74+
"author": "@technoph1le"
75+
}
76+
]
77+
},
78+
{
79+
"categoryName": "Utilities",
80+
"snippets": [
81+
{
82+
"title": "Measure Execution Time",
83+
"description": "Measures the execution time of a code block.",
84+
"code": "import time\n\ndef measure_time(func, *args):\n start = time.time()\n result = func(*args)\n end = time.time()\n print(f'Execution time: {end - start:.6f} seconds')\n return result\n\n# Usage:\ndef slow_function():\n time.sleep(2)\n\nmeasure_time(slow_function)",
85+
"tags": ["python", "time", "execution", "utility"],
86+
"author": "@technoph1le"
87+
},
88+
{
89+
"title": "Generate Random String",
90+
"description": "Generates a random alphanumeric string.",
91+
"code": "import random\nimport string\n\ndef random_string(length):\n letters_and_digits = string.ascii_letters + string.digits\n return ''.join(random.choice(letters_and_digits) for _ in range(length))\n\n# Usage:\nprint(random_string(10)) # Output: Random 10-character string",
92+
"tags": ["python", "random", "string", "utility"],
93+
"author": "@technoph1le"
94+
}
95+
]
96+
}
97+
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy