|
1 | 1 | [
|
| 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 | + }, |
2 | 76 | {
|
3 | 77 | "language": "cpp",
|
4 | 78 | "categoryName": "Basics",
|
|
748 | 822 | "console.log(countWords('Hello world! This is a test.')); // Output: 6"
|
749 | 823 | ],
|
750 | 824 | "tags": [
|
| 825 | + "javascript", |
751 | 826 | "string",
|
752 | 827 | "manipulation",
|
753 | 828 | "word count",
|
|
767 | 842 | "console.log(removeWhitespace('Hello world!')); // Output: 'Helloworld!'"
|
768 | 843 | ],
|
769 | 844 | "tags": [
|
| 845 | + "javascript", |
770 | 846 | "string",
|
771 | 847 | "whitespace"
|
772 | 848 | ],
|
|
1461 | 1537 | "code": [
|
1462 | 1538 | "const debounce = (func, delay) => {",
|
1463 | 1539 | " let timeout;",
|
| 1540 | + "", |
1464 | 1541 | " return (...args) => {",
|
1465 | 1542 | " clearTimeout(timeout);",
|
1466 | 1543 | " timeout = setTimeout(() => func(...args), delay);",
|
|
1536 | 1613 | "console.log(getContrastColor('#f4f')); // Output: #000000 (black)"
|
1537 | 1614 | ],
|
1538 | 1615 | "tags": [
|
| 1616 | + "javascript", |
1539 | 1617 | "color",
|
1540 | 1618 | "hex",
|
1541 | 1619 | "contrast",
|
1542 | 1620 | "brightness",
|
1543 | 1621 | "utility"
|
1544 | 1622 | ],
|
1545 | 1623 | "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" |
1546 | 1648 | }
|
1547 | 1649 | ]
|
1548 | 1650 | },
|
|
0 commit comments