Skip to content

Commit 7d1d241

Browse files
committed
move code prop to undo consolidation changes
1 parent 607d314 commit 7d1d241

13 files changed

+387
-393
lines changed

public/consolidated/c.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"title": "Hello, World!",
77
"description": "Prints Hello, World! to the terminal.",
88
"author": "0xHouss",
9-
"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",
109
"tags": [
1110
"printing",
1211
"hello-world"
1312
],
14-
"contributors": []
13+
"contributors": [],
14+
"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"
1515
}
1616
]
1717
},
@@ -22,12 +22,12 @@
2222
"title": "Factorial Function",
2323
"description": "Calculates the factorial of a number.",
2424
"author": "0xHouss",
25-
"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\n// Usage:\nfactorial(4); // Returns: 24\n",
2625
"tags": [
2726
"math",
2827
"factorial"
2928
],
30-
"contributors": []
29+
"contributors": [],
30+
"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\n// Usage:\nfactorial(4); // Returns: 24\n"
3131
}
3232
]
3333
}

public/consolidated/cpp.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"title": "Hello, World!",
77
"description": "Prints Hello, World! to the terminal.",
88
"author": "James-Beans",
9-
"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",
109
"tags": [
1110
"printing",
1211
"hello-world"
1312
],
14-
"contributors": []
13+
"contributors": [],
14+
"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"
1515
}
1616
]
1717
},
@@ -22,13 +22,13 @@
2222
"title": "Vector to Queue",
2323
"description": "Convert vector into queue quickly",
2424
"author": "mrityunjay2003",
25-
"code": "#include<queue>\n#include<vector>\n#include<deque>\n\nstd::queue<int> vectorToQueue(const std::vector<int>& v) {\n return std::queue<int>(std::deque<int>(v.begin(), v.end()));\n}\n\nstd::vector<int> vec = { 1, 2, 3, 4, 5 };\nvectorToQueue(&vec); // Returns: std::queue<int> { 1, 2, 3, 4, 5 }\n",
2625
"tags": [
2726
"data structures",
2827
"queue",
2928
"vector"
3029
],
31-
"contributors": []
30+
"contributors": [],
31+
"code": "#include<queue>\n#include<vector>\n#include<deque>\n\nstd::queue<int> vectorToQueue(const std::vector<int>& v) {\n return std::queue<int>(std::deque<int>(v.begin(), v.end()));\n}\n\nstd::vector<int> vec = { 1, 2, 3, 4, 5 };\nvectorToQueue(&vec); // Returns: std::queue<int> { 1, 2, 3, 4, 5 }\n"
3232
}
3333
]
3434
},
@@ -39,12 +39,12 @@
3939
"title": "Check Prime Number",
4040
"description": "Check if an integer is a prime number",
4141
"author": "MihneaMoso",
42-
"code": "bool is_prime(int n) {\n if (n < 2) return false;\n if (n == 2 || n == 3) return true;\n if (n % 2 == 0) return false;\n for (int i = 3; i * i <= n; i += 2) {\n if (n % i == 0) return false;\n }\n return true;\n}\n\n// Usage:\nis_prime(29); // Returns: true\n",
4342
"tags": [
4443
"number",
4544
"prime"
4645
],
47-
"contributors": []
46+
"contributors": [],
47+
"code": "bool is_prime(int n) {\n if (n < 2) return false;\n if (n == 2 || n == 3) return true;\n if (n % 2 == 0) return false;\n for (int i = 3; i * i <= n; i += 2) {\n if (n % i == 0) return false;\n }\n return true;\n}\n\n// Usage:\nis_prime(29); // Returns: true\n"
4848
}
4949
]
5050
},
@@ -55,23 +55,23 @@
5555
"title": "Reverse String",
5656
"description": "Reverses the characters in a string.",
5757
"author": "Vaibhav-kesarwani",
58-
"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\nreverseString(\"quicksnip\"); // Returns: \"pinskciuq\"\n",
5958
"tags": [
6059
"array",
6160
"reverse"
6261
],
63-
"contributors": []
62+
"contributors": [],
63+
"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\nreverseString(\"quicksnip\"); // Returns: \"pinskciuq\"\n"
6464
},
6565
{
6666
"title": "Split String",
6767
"description": "Splits a string by a delimiter",
6868
"author": "saminjay",
69-
"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\n// Usage:\nsplit_string(\"quick_-snip\", \"_-\"); // Returns: std::vector<std::string> { \"quick\", \"snip\" }\n",
7069
"tags": [
7170
"string",
7271
"split"
7372
],
74-
"contributors": []
73+
"contributors": [],
74+
"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\n// Usage:\nsplit_string(\"quick_-snip\", \"_-\"); // Returns: std::vector<std::string> { \"quick\", \"snip\" }\n"
7575
}
7676
]
7777
}

public/consolidated/csharp.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"title": "Hello, World!",
77
"description": "Prints Hello, World! to the terminal.",
88
"author": "chaitanya-jvnm",
9-
"code": "public class Program {\n public static void Main(string[] args) {\n System.Console.WriteLine(\"Hello, World!\");\n }\n}\n",
109
"tags": [
1110
"printing",
1211
"hello-world"
1312
],
14-
"contributors": []
13+
"contributors": [],
14+
"code": "public class Program {\n public static void Main(string[] args) {\n System.Console.WriteLine(\"Hello, World!\");\n }\n}\n"
1515
}
1616
]
1717
},
@@ -22,23 +22,23 @@
2222
"title": "Generate GUID",
2323
"description": "Generates a new GUID",
2424
"author": "chaitanya-jvnm",
25-
"code": "public static string GenerateGuid() {\n return Guid.NewGuid().ToString();\n}\n\n// Usage:\nGenerateGuid(); // Returns: 1c4c38d8-64e4-431b-884a-c6eec2ab02cd (Uuid is random)\n",
2625
"tags": [
2726
"guid",
2827
"generate"
2928
],
30-
"contributors": []
29+
"contributors": [],
30+
"code": "public static string GenerateGuid() {\n return Guid.NewGuid().ToString();\n}\n\n// Usage:\nGenerateGuid(); // Returns: 1c4c38d8-64e4-431b-884a-c6eec2ab02cd (Uuid is random)\n"
3131
},
3232
{
3333
"title": "Validate GUID",
3434
"description": "Checks if a string is a valid GUID.",
3535
"author": "chaitanya-jvnm",
36-
"code": "public static bool IsGuid(string str) {\n return Guid.TryParse(str, out _);\n}\n\n// Usage:\nIsGuid(\"1c4c38d8-64e4-431b-884a-c6eec2ab02cd\"); // Returns: true\nIsGuid(\"quicksnip\"); // Returns: false\n",
3736
"tags": [
3837
"guid",
3938
"validate"
4039
],
41-
"contributors": []
40+
"contributors": [],
41+
"code": "public static bool IsGuid(string str) {\n return Guid.TryParse(str, out _);\n}\n\n// Usage:\nIsGuid(\"1c4c38d8-64e4-431b-884a-c6eec2ab02cd\"); // Returns: true\nIsGuid(\"quicksnip\"); // Returns: false\n"
4242
}
4343
]
4444
},
@@ -49,23 +49,23 @@
4949
"title": "Decode JWT",
5050
"description": "Decodes a JWT.",
5151
"author": "chaitanya-jvnm",
52-
"code": "public static string DecodeJwt(string token) {\n return new JwtSecurityTokenHandler().ReadJwtToken(token).ToString();\n}\n\n// Usage:\nstring token = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\";\nDecodeJwt(token); // Returns: \"{\\\"alg\\\":\\\"HS256\\\",\\\"typ\\\":\\\"JWT\\\"}.{\\\"sub\\\":\\\"1234567890\\\",\\\"name\\\":\\\"John Doe\\\",\\\"iat\\\":1516239022}\"\n",
5352
"tags": [
5453
"jwt",
5554
"decode"
5655
],
57-
"contributors": []
56+
"contributors": [],
57+
"code": "public static string DecodeJwt(string token) {\n return new JwtSecurityTokenHandler().ReadJwtToken(token).ToString();\n}\n\n// Usage:\nstring token = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\";\nDecodeJwt(token); // Returns: \"{\\\"alg\\\":\\\"HS256\\\",\\\"typ\\\":\\\"JWT\\\"}.{\\\"sub\\\":\\\"1234567890\\\",\\\"name\\\":\\\"John Doe\\\",\\\"iat\\\":1516239022}\"\n"
5858
},
5959
{
6060
"title": "Validate JWT",
6161
"description": "Validates a JWT.",
6262
"author": "chaitanya-jvnm",
63-
"code": "public static bool ValidateJwt(string token, string secret) {\n var tokenHandler = new JwtSecurityTokenHandler();\n var validationParameters = new TokenValidationParameters {\n ValidateIssuerSigningKey = true,\n IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret)),\n ValidateIssuer = false,\n ValidateAudience = false\n };\n try {\n tokenHandler.ValidateToken(token, validationParameters, out _);\n return true;\n }\n catch {\n return false\n }\n}\n\n// Usage:\nstring JWT = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\";\nstring correctSecret = \"your-256-bit-secret\";\nstring wrongSecret = \"this-is-not-the-right-secret\";\n\nValidateJwt(JWT, correctSecret); // Returns: true\nValidateJwt(JWT, wrongSecret); // Returns: false\n",
6463
"tags": [
6564
"jwt",
6665
"validate"
6766
],
68-
"contributors": []
67+
"contributors": [],
68+
"code": "public static bool ValidateJwt(string token, string secret) {\n var tokenHandler = new JwtSecurityTokenHandler();\n var validationParameters = new TokenValidationParameters {\n ValidateIssuerSigningKey = true,\n IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret)),\n ValidateIssuer = false,\n ValidateAudience = false\n };\n try {\n tokenHandler.ValidateToken(token, validationParameters, out _);\n return true;\n }\n catch {\n return false\n }\n}\n\n// Usage:\nstring JWT = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\";\nstring correctSecret = \"your-256-bit-secret\";\nstring wrongSecret = \"this-is-not-the-right-secret\";\n\nValidateJwt(JWT, correctSecret); // Returns: true\nValidateJwt(JWT, wrongSecret); // Returns: false\n"
6969
}
7070
]
7171
},
@@ -76,12 +76,12 @@
7676
"title": "Swap items at index",
7777
"description": "Swaps two items at determined indexes",
7878
"author": "omegaleo",
79-
"code": "public static IList<T> Swap<T>(this IList<T> list, int indexA, int indexB)\n{\n (list[indexA], list[indexB]) = (list[indexB], list[indexA]);\n return list;\n}\n\nvar list = new List<string>() {\"Test\", \"Test2\"};\n\nlist.Swap(0, 1); // Swaps \"Test\" and \"Test2\" in place\n",
8079
"tags": [
8180
"list",
8281
"swapping"
8382
],
84-
"contributors": []
83+
"contributors": [],
84+
"code": "public static IList<T> Swap<T>(this IList<T> list, int indexA, int indexB)\n{\n (list[indexA], list[indexB]) = (list[indexB], list[indexA]);\n return list;\n}\n\nvar list = new List<string>() {\"Test\", \"Test2\"};\n\nlist.Swap(0, 1); // Swaps \"Test\" and \"Test2\" in place\n"
8585
}
8686
]
8787
},
@@ -92,23 +92,23 @@
9292
"title": "Capitalize first letter",
9393
"description": "Makes the first letter of a string uppercase.",
9494
"author": "chaitanya-jvnm",
95-
"code": "public static string Capitalize(this string str) {\n return str.Substring(0, 1).ToUpper() + str.Substring(1);\n}\n\n// Usage:\n\"quicksnip\".Capitalize(); // Returns: \"Quicksnip\"\n",
9695
"tags": [
9796
"string",
9897
"capitalize"
9998
],
100-
"contributors": []
99+
"contributors": [],
100+
"code": "public static string Capitalize(this string str) {\n return str.Substring(0, 1).ToUpper() + str.Substring(1);\n}\n\n// Usage:\n\"quicksnip\".Capitalize(); // Returns: \"Quicksnip\"\n"
101101
},
102102
{
103103
"title": "Truncate String",
104104
"description": "Cut off a string once it reaches a determined amount of characters and add '...' to the end of the string",
105105
"author": "omegaleo",
106-
"code": "public static string Truncate(this string value, int maxChars)\n{\n return value.Length <= maxChars ? value : value.Substring(0, maxChars) + \"...\";\n}\n\n// Usage:\n\"Quicksnip\".Truncate(5); // Returns: \"Quick...\"\n",
107106
"tags": [
108107
"string",
109108
"truncate"
110109
],
111-
"contributors": []
110+
"contributors": [],
111+
"code": "public static string Truncate(this string value, int maxChars)\n{\n return value.Length <= maxChars ? value : value.Substring(0, maxChars) + \"...\";\n}\n\n// Usage:\n\"Quicksnip\".Truncate(5); // Returns: \"Quick...\"\n"
112112
}
113113
]
114114
}

0 commit comments

Comments
 (0)