Skip to content

Migrating the snippet format to a markdown approach #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,747 changes: 1,468 additions & 3,279 deletions public/consolidated/all_snippets.json

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions public/data/_index.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[
{
"lang": "JavaScript",
"icon": "/icons/javascript.svg"
},
{
"lang": "CSS",
"icon": "/icons/css.svg"
},
{
"lang": "HTML",
"icon": "/icons/html5.svg"
},
{
"lang": "Python",
"icon": "/icons/python.svg"
},
{
"lang": "SCSS",
"icon": "/icons/sass.svg"
},
{
"lang": "CPP",
"icon": "/icons/cpp.svg"
},
{
"lang": "C",
"icon": "/icons/c.svg"
},
{
"lang": "Rust",
"icon": "/icons/rust.svg"
}
]
{
"lang": "C",
"icon": "/icons/c.svg"
},
{
"lang": "CPP",
"icon": "/icons/cpp.svg"
},
{
"lang": "CSS",
"icon": "/icons/css.svg"
},
{
"lang": "HTML",
"icon": "/icons/html.svg"
},
{
"lang": "JAVASCRIPT",
"icon": "/icons/javascript.svg"
},
{
"lang": "PYTHON",
"icon": "/icons/python.svg"
},
{
"lang": "RUST",
"icon": "/icons/rust.svg"
},
{
"lang": "SCSS",
"icon": "/icons/scss.svg"
}
]
106 changes: 49 additions & 57 deletions public/data/c.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,51 @@
[
{
"categoryName": "Basics",
"snippets": [
{
"title": "Hello, World!",
"description": "Prints Hello, World! to the terminal.",
"code": [
"#include <stdio.h> // Includes the input/output library",
"",
"int main() { // Defines the main function",
" printf(\"Hello, World!\\n\") // Outputs Hello, World! and a newline",
"",
" return 0; // indicate the program executed successfully",
"}"
],
"tags": ["c", "printing", "hello-world", "utility"],
"author": "0xHouss"
}
]
},
{
"categoryName": "Mathematical Functions",
"snippets": [
{
"title": "Factorial Function",
"description": "Calculates the factorial of a number.",
"code": [
"int factorial(int x) {",
" int y = 1;",
"",
" for (int i = 2; i <= x; i++)",
" y *= i;",
"",
" return y;",
"}"
],
"tags": ["c", "math", "factorial", "utility"],
"author": "0xHouss"
},
{
"title": "Power Function",
"description": "Calculates the power of a number.",
"code": [
"int power(int x, int n) {",
" int y = 1;",
"",
" for (int i = 0; i < n; i++)",
" y *= x;",
"",
" return y;",
"}"
],
"tags": ["c", "math", "power", "utility"],
"author": "0xHouss"
}
]
}
{
"categoryName": "Basics",
"snippets": [
{
"title": "Hello, World!",
"description": "Prints Hello, World! to the terminal.",
"author": "0xHouss",
"tags": [
"c",
"printing",
"hello-world",
"utility"
],
"contributors": [],
"code": "#include <stdio.h> // Includes the input/output library\n\nint main() { // Defines the main function\n printf(\"Hello, World!\\n\") // Outputs Hello, World! and a newline\n\n return 0; // indicate the program executed successfully\n}\n"
}
]
},
{
"categoryName": "Mathematical Functions",
"snippets": [
{
"title": "Factorial Function",
"description": "Calculates the factorial of a number.",
"author": "0xHouss",
"tags": [
"c",
"math",
"factorial",
"utility"
],
"contributors": [],
"code": "int factorial(int x) {\n int y = 1;\n\n for (int i = 2; i <= x; i++)\n y *= i;\n\n return y;\n}\n"
},
{
"title": "Power Function",
"description": "Calculates the power of a number.",
"author": "0xHouss",
"tags": [
"c",
"math",
"power",
"utility"
],
"contributors": [],
"code": "int power(int x, int n) {\n int y = 1;\n\n for (int i = 0; i < n; i++)\n y *= x;\n\n return y;\n}\n"
}
]
}
]
113 changes: 50 additions & 63 deletions public/data/cpp.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,51 @@
[
{
"categoryName": "Basics",
"snippets": [
{
"title": "Hello, World!",
"description": "Prints Hello, World! to the terminal.",
"code": [
"#include <iostream> // Includes the input/output stream library",
"",
"int main() { // Defines the main function",
" std::cout << \"Hello, World!\" << std::endl; // Outputs Hello, World! and a newline",
" return 0; // indicate the program executed successfully",
"}"
],
"tags": ["cpp", "printing", "hello-world", "utility"],
"author": "James-Beans"
}
]
},
{
"categoryName": "String Manipulation",
"snippets": [
{
"title": "Reverse String",
"description": "Reverses the characters in a string.",
"code": [
"#include <string>",
"#include <algorithm>",
"",
"std::string reverseString(const std::string& input) {",
" std::string reversed = input;",
" std::reverse(reversed.begin(), reversed.end());",
" return reversed;",
"}"
],
"tags": ["cpp", "array", "reverse", "utility"],
"author": "Vaibhav-kesarwani"
},
{
"title": "Split String",
"description": "Splits a string by a delimiter",
"code": [
"#include <string>",
"#include <vector>",
"",
"std::vector<std::string> split_string(std::string str, std::string delim) {",
" std::vector<std::string> splits;",
" int i = 0, j;",
" int inc = delim.length();",
" while (j != std::string::npos) {",
" j = str.find(delim, i);",
" splits.push_back(str.substr(i, j - i));",
" i = j + inc;",
" }",
" return splits;",
"}"
],
"tags": ["cpp", "string", "split", "utility"],
"author": "saminjay"
}
]
}
]
{
"categoryName": "Basics",
"snippets": [
{
"title": "Hello, World!",
"description": "Prints Hello, World! to the terminal.",
"author": "James-Beans",
"tags": [
"cpp",
"printing",
"hello-world",
"utility"
],
"contributors": [],
"code": "#include <iostream> // Includes the input/output stream library\n\nint main() { // Defines the main function\n std::cout << \"Hello, World!\" << std::endl; // Outputs Hello, World! and a newline\n return 0; // indicate the program executed successfully\n}\n"
}
]
},
{
"categoryName": "String Manipulation",
"snippets": [
{
"title": "Reverse String",
"description": "Reverses the characters in a string.",
"author": "Vaibhav-kesarwani",
"tags": [
"cpp",
"array",
"reverse",
"utility"
],
"contributors": [],
"code": "#include <string>\n#include <algorithm>\n\nstd::string reverseString(const std::string& input) {\n std::string reversed = input;\n std::reverse(reversed.begin(), reversed.end());\n return reversed;\n}\n"
},
{
"title": "Split String",
"description": "Splits a string by a delimiter",
"author": "saminjay",
"tags": [
"cpp",
"string",
"split",
"utility"
],
"contributors": [],
"code": "#include <string>\n#include <vector>\n\nstd::vector<std::string> split_string(std::string str, std::string delim) {\n std::vector<std::string> splits;\n int i = 0, j;\n int inc = delim.length();\n while (j != std::string::npos) {\n j = str.find(delim, i);\n splits.push_back(str.substr(i, j - i));\n i = j + inc;\n }\n return splits;\n}\n"
}
]
}
]
Loading