Skip to content

Commit 39ab2df

Browse files
committed
Update consolidated snippets
1 parent 9d33fca commit 39ab2df

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

public/consolidated/all_snippets.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,78 @@
11
[
2+
{
3+
"language": "c",
4+
"categoryName": "Basics",
5+
"snippets": [
6+
{
7+
"title": "Hello, World!",
8+
"description": "Prints Hello, World! to the terminal.",
9+
"code": [
10+
"#include <stdio.h> // Includes the input/output library",
11+
"",
12+
"int main() { // Defines the main function",
13+
" printf(\"Hello, World!\\n\") // Outputs Hello, World! and a newline",
14+
"",
15+
" return 0; // indicate the program executed successfully",
16+
"}"
17+
],
18+
"tags": [
19+
"c",
20+
"printing",
21+
"hello-world",
22+
"utility"
23+
],
24+
"author": "0xHouss"
25+
}
26+
]
27+
},
28+
{
29+
"language": "c",
30+
"categoryName": "Mathematical Functions",
31+
"snippets": [
32+
{
33+
"title": "Factorial Function",
34+
"description": "Calculates the factorial of a number.",
35+
"code": [
36+
"int factorial(int x) {",
37+
" int y = 1;",
38+
"",
39+
" for (int i = 2; i <= x; i++)",
40+
" y *= i;",
41+
"",
42+
" return y;",
43+
"}"
44+
],
45+
"tags": [
46+
"c",
47+
"math",
48+
"factorial",
49+
"utility"
50+
],
51+
"author": "0xHouss"
52+
},
53+
{
54+
"title": "Power Function",
55+
"description": "Calculates the power of a number.",
56+
"code": [
57+
"int power(int x, int n) {",
58+
" int y = 1;",
59+
"",
60+
" for (int i = 0; i < n; i++)",
61+
" y *= x;",
62+
"",
63+
" return y;",
64+
"}"
65+
],
66+
"tags": [
67+
"c",
68+
"math",
69+
"power",
70+
"utility"
71+
],
72+
"author": "0xHouss"
73+
}
74+
]
75+
},
276
{
377
"language": "cpp",
478
"categoryName": "Basics",
@@ -748,6 +822,7 @@
748822
"console.log(countWords('Hello world! This is a test.')); // Output: 6"
749823
],
750824
"tags": [
825+
"javascript",
751826
"string",
752827
"manipulation",
753828
"word count",
@@ -767,6 +842,7 @@
767842
"console.log(removeWhitespace('Hello world!')); // Output: 'Helloworld!'"
768843
],
769844
"tags": [
845+
"javascript",
770846
"string",
771847
"whitespace"
772848
],
@@ -1461,6 +1537,7 @@
14611537
"code": [
14621538
"const debounce = (func, delay) => {",
14631539
" let timeout;",
1540+
"",
14641541
" return (...args) => {",
14651542
" clearTimeout(timeout);",
14661543
" timeout = setTimeout(() => func(...args), delay);",
@@ -1536,13 +1613,38 @@
15361613
"console.log(getContrastColor('#f4f')); // Output: #000000 (black)"
15371614
],
15381615
"tags": [
1616+
"javascript",
15391617
"color",
15401618
"hex",
15411619
"contrast",
15421620
"brightness",
15431621
"utility"
15441622
],
15451623
"author": "yaya12085"
1624+
},
1625+
{
1626+
"title": "Sleep Function",
1627+
"description": "Waits for a specified amount of milliseconds before resolving.",
1628+
"code": [
1629+
"const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));",
1630+
"",
1631+
"// Usage:",
1632+
"async function main() {",
1633+
" console.log('Hello');",
1634+
" await sleep(2000); // Waits for 2 seconds",
1635+
" console.log('World!');",
1636+
"}",
1637+
"",
1638+
"main();"
1639+
],
1640+
"tags": [
1641+
"javascript",
1642+
"sleep",
1643+
"delay",
1644+
"utility",
1645+
"promises"
1646+
],
1647+
"author": "0xHouss"
15461648
}
15471649
]
15481650
},

0 commit comments

Comments
 (0)