From 794eccd629ad0c17d407d0c4eee716c3638e72a2 Mon Sep 17 00:00:00 2001 From: Emosans Date: Sat, 4 Jan 2025 12:53:07 +0530 Subject: [PATCH 01/13] new snippet - string to int --- .../cpp/string-manipulation/string-int.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 snippets/cpp/string-manipulation/string-int.md diff --git a/snippets/cpp/string-manipulation/string-int.md b/snippets/cpp/string-manipulation/string-int.md new file mode 100644 index 00000000..39f1ff8c --- /dev/null +++ b/snippets/cpp/string-manipulation/string-int.md @@ -0,0 +1,20 @@ +--- +title: String Int +description: Converts string to int without built in stoi() +author: Emosans +tags: string,int +--- + +```cpp +std::int to_num(const std::string& input){ + int num=0; + int len=input.size(); + for(int i=0;iint) +``` \ No newline at end of file From 943300610102c47d7aab1859e7617487abc768d7 Mon Sep 17 00:00:00 2001 From: Emosans Date: Sat, 4 Jan 2025 16:10:11 +0530 Subject: [PATCH 02/13] new snippet- swap numbers --- snippets/cpp/math-and-numbers/swap-numbers.md | 19 ++++++++++++++++++ .../cpp/string-manipulation/string-int.md | 20 ------------------- 2 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 snippets/cpp/math-and-numbers/swap-numbers.md delete mode 100644 snippets/cpp/string-manipulation/string-int.md diff --git a/snippets/cpp/math-and-numbers/swap-numbers.md b/snippets/cpp/math-and-numbers/swap-numbers.md new file mode 100644 index 00000000..27496a31 --- /dev/null +++ b/snippets/cpp/math-and-numbers/swap-numbers.md @@ -0,0 +1,19 @@ +--- +title: Swap numbers +description: Swaps two numbers without using third variable +author: Emosans +tags: swap,numbers +--- + +```cpp +#include +std::tuple swap(int num1,int num2){ + num1=num1+num2; + num2=num1-num2; + num1=num1-num2; + return std::make_tuple(num1,num2); +} + +// Usage +auto swapped=swap(3,4); // Returns a tuple (access the values using std::get<0>(swapped)/std::get<1>(swapped)) +``` \ No newline at end of file diff --git a/snippets/cpp/string-manipulation/string-int.md b/snippets/cpp/string-manipulation/string-int.md deleted file mode 100644 index 39f1ff8c..00000000 --- a/snippets/cpp/string-manipulation/string-int.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: String Int -description: Converts string to int without built in stoi() -author: Emosans -tags: string,int ---- - -```cpp -std::int to_num(const std::string& input){ - int num=0; - int len=input.size(); - for(int i=0;iint) -``` \ No newline at end of file From 78fa4a1d96cde3279d9a8e5997f37c937f4e1208 Mon Sep 17 00:00:00 2001 From: Emosans Date: Sat, 4 Jan 2025 16:33:41 +0530 Subject: [PATCH 03/13] snippet- changed to C --- .../c/mathematical-functions/swap-numbers.md | 19 +++++++++++++++++++ snippets/cpp/math-and-numbers/swap-numbers.md | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 snippets/c/mathematical-functions/swap-numbers.md delete mode 100644 snippets/cpp/math-and-numbers/swap-numbers.md diff --git a/snippets/c/mathematical-functions/swap-numbers.md b/snippets/c/mathematical-functions/swap-numbers.md new file mode 100644 index 00000000..c07d39b0 --- /dev/null +++ b/snippets/c/mathematical-functions/swap-numbers.md @@ -0,0 +1,19 @@ +--- +title: Swap numbers +description: Swaps two numbers without using third variable +author: Emosans +tags: swap,numbers +--- + +```c +#include +void swap(int* num1,int* num2){ + *num1= *num1 + *num2; + *num2= *num1 - *num2; + *num1= *num1 - *num2; +} + +// Usage: +int a=3,b=4; +auto swapped=swap(&a,&b); // simply use printf after this to print swapped values +``` \ No newline at end of file diff --git a/snippets/cpp/math-and-numbers/swap-numbers.md b/snippets/cpp/math-and-numbers/swap-numbers.md deleted file mode 100644 index 27496a31..00000000 --- a/snippets/cpp/math-and-numbers/swap-numbers.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: Swap numbers -description: Swaps two numbers without using third variable -author: Emosans -tags: swap,numbers ---- - -```cpp -#include -std::tuple swap(int num1,int num2){ - num1=num1+num2; - num2=num1-num2; - num1=num1-num2; - return std::make_tuple(num1,num2); -} - -// Usage -auto swapped=swap(3,4); // Returns a tuple (access the values using std::get<0>(swapped)/std::get<1>(swapped)) -``` \ No newline at end of file From bf49d9c496adf9f42df75e74c0341e784896112d Mon Sep 17 00:00:00 2001 From: Emosans Date: Sat, 4 Jan 2025 16:45:06 +0530 Subject: [PATCH 04/13] changes --- snippets/c/mathematical-functions/swap-numbers.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snippets/c/mathematical-functions/swap-numbers.md b/snippets/c/mathematical-functions/swap-numbers.md index c07d39b0..a655a4cf 100644 --- a/snippets/c/mathematical-functions/swap-numbers.md +++ b/snippets/c/mathematical-functions/swap-numbers.md @@ -8,12 +8,12 @@ tags: swap,numbers ```c #include void swap(int* num1,int* num2){ - *num1= *num1 + *num2; - *num2= *num1 - *num2; - *num1= *num1 - *num2; + *num1 = *num1 + *num2; + *num2 = *num1 - *num2; + *num1 = *num1 - *num2; } // Usage: -int a=3,b=4; -auto swapped=swap(&a,&b); // simply use printf after this to print swapped values +int a = 3,b = 4; +swap(&a,&b); // simply use printf after this to print swapped values ``` \ No newline at end of file From 6381a89ca52eeece5dae4165d26bdc26a5921c88 Mon Sep 17 00:00:00 2001 From: Emosans Date: Sat, 4 Jan 2025 16:57:37 +0530 Subject: [PATCH 05/13] small typo --- public/consolidated/c.json | 11 +++++++++++ public/consolidated/cpp.json | 17 +++++++++++++++++ public/consolidated/javascript.json | 18 ++++++------------ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/public/consolidated/c.json b/public/consolidated/c.json index a9a23234..1588cd69 100644 --- a/public/consolidated/c.json +++ b/public/consolidated/c.json @@ -28,6 +28,17 @@ ], "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\n// Usage:\nfactorial(4); // Returns: 24\n" + }, + { + "title": "Swap numbers", + "description": "Swaps two numbers without using third variable", + "author": "Emosans", + "tags": [ + "swap", + "numbers" + ], + "contributors": [], + "code": "#include\nvoid swap(int* num1,int* num2){\n *num1 = *num1 + *num2;\n *num2 = *num1 - *num2;\n *num1 = *num1 - *num2;\n}\n\n// Usage:\nint a = 3,b = 4;\nswap(&a,&b); // simply use printf after this to print swapped values\n" } ] } diff --git a/public/consolidated/cpp.json b/public/consolidated/cpp.json index e560e82d..6427f04f 100644 --- a/public/consolidated/cpp.json +++ b/public/consolidated/cpp.json @@ -32,6 +32,23 @@ } ] }, + { + "categoryName": "Debuging", + "snippets": [ + { + "title": "Vector Print", + "description": "Overloads the << operator to print the contents of a vector just like in python.", + "author": "Mohamed-faaris", + "tags": [ + "printing", + "debuging", + "vector" + ], + "contributors": [], + "code": "#include \n#include \n\ntemplate \nstd::ostream& operator<<(std::ostream& os, const std::vector& vec) {\n os << \"[\"; \n for (size_t i = 0; i < vec.size(); ++i) {\n os << vec[i]; // Print each vector element\n if (i != vec.size() - 1) {\n os << \", \"; // Add separator\n }\n }\n os << \"]\"; \n return os; // Return the stream\n}\n\n// Usage:\nstd::vector numbers = {1, 2, 3, 4, 5};\nstd::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]\n\n" + } + ] + }, { "categoryName": "Math And Numbers", "snippets": [ diff --git a/public/consolidated/javascript.json b/public/consolidated/javascript.json index 99588330..c7b78ff8 100644 --- a/public/consolidated/javascript.json +++ b/public/consolidated/javascript.json @@ -85,10 +85,8 @@ "description": "Converts RGB color values to hexadecimal color code.", "author": "jjcantu", "tags": [ - "javascript", "color", - "conversion", - "utility" + "conversion" ], "contributors": [], "code": "function rgbToHex(r, g, b) {\n const toHex = (n) => {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n \n return '#' + toHex(r) + toHex(g) + toHex(b);\n}\n\n// Usage:\nconsole.log(rgbToHex(255, 128, 0)); // Output: \"#ff8000\"\nconsole.log(rgbToHex(0, 255, 0)); // Output: \"#00ff00\"\n" @@ -407,10 +405,8 @@ "description": "Converts bytes into human-readable file size format.", "author": "jjcantu", "tags": [ - "javascript", "format", - "size", - "utility" + "size" ], "contributors": [], "code": "function formatFileSize(bytes) {\n if (bytes === 0) return '0 Bytes';\n \n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n \n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n}\n\n// Usage:\nconsole.log(formatFileSize(1234)); // Output: \"1.21 KB\"\nconsole.log(formatFileSize(1234567)); // Output: \"1.18 MB\"\n" @@ -506,13 +502,11 @@ "description": "Creates a deep copy of an object or array without reference.", "author": "jjcantu", "tags": [ - "javascript", "object", - "clone", - "utility" + "clone" ], "contributors": [], - "code": "function deepClone(obj) {\n if (obj === null || typeof obj !== 'object') return obj;\n \n const clone = Array.isArray(obj) ? [] : {};\n \n for (let key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = deepClone(obj[key]);\n }\n }\n \n return clone;\n}\n\n// Usage:\nconst original = { a: 1, b: { c: 2 }, d: [1, 2, 3] };\nconst cloned = deepClone(original);\nconsole.log(cloned); // Output: { a: 1, b: { c: 2 }, d: [1, 2, 3] }\n" + "code": "function deepClone(obj) {\n if (obj === null || typeof obj !== 'object') return obj;\n \n const clone = Array.isArray(obj) ? [] : {};\n \n for (let key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = deepClone(obj[key]);\n }\n }\n \n return clone;\n}\n\n// Usage:\nconst original = { a: 1, b: { c: 2 }, d: [1, 2, 3] };\nconst cloned = deepClone(original);\nconsole.log(cloned); // Output: 'original' but cloned\n" }, { "title": "Filter Object", @@ -758,9 +752,9 @@ "description": "Generates a UUID (v4) string.", "author": "jjcantu", "tags": [ - "javascript", "uuid", - "utility" + "generate", + "string" ], "contributors": [], "code": "function generateUUID() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n const r = Math.random() * 16 | 0;\n const v = c === 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n}\n\n// Usage:\nconsole.log(generateUUID()); // Output: \"a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5\"\n" From f701f7da9138c4b84ad3ae58facef628c857fec3 Mon Sep 17 00:00:00 2001 From: majvax Date: Sat, 4 Jan 2025 15:21:43 +0100 Subject: [PATCH 06/13] Initial commit, added icon and 3 snippets --- snippets/regex/icon.svg | 6 ++++++ .../regex/miscellaneous/hexadecimal-color.md | 17 +++++++++++++++++ .../regex/validation pattern/email-address.md | 15 +++++++++++++++ .../regex/validation pattern/strong-password.md | 17 +++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 snippets/regex/icon.svg create mode 100644 snippets/regex/miscellaneous/hexadecimal-color.md create mode 100644 snippets/regex/validation pattern/email-address.md create mode 100644 snippets/regex/validation pattern/strong-password.md diff --git a/snippets/regex/icon.svg b/snippets/regex/icon.svg new file mode 100644 index 00000000..bdbe2fc2 --- /dev/null +++ b/snippets/regex/icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/snippets/regex/miscellaneous/hexadecimal-color.md b/snippets/regex/miscellaneous/hexadecimal-color.md new file mode 100644 index 00000000..7f3dfce4 --- /dev/null +++ b/snippets/regex/miscellaneous/hexadecimal-color.md @@ -0,0 +1,17 @@ +--- +Title: Hexadecimal Color +Description: Matches hex color codes +Author: majvax +Tags: color,hexadecimal +--- + + +```regex +^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$ + + +-> Usage: +#FFF1 ✗ +#FFF ✓ +#FFF000 ✓ +``` diff --git a/snippets/regex/validation pattern/email-address.md b/snippets/regex/validation pattern/email-address.md new file mode 100644 index 00000000..5a89f76e --- /dev/null +++ b/snippets/regex/validation pattern/email-address.md @@ -0,0 +1,15 @@ +--- +Title: Email Address +Description: Match any email address +Author: majvax +Tags: email +--- + + +```regex +^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ + +-> Usage: +example.name@domain.com.ru ✓ +name.surname@gmail.com ✓ +``` diff --git a/snippets/regex/validation pattern/strong-password.md b/snippets/regex/validation pattern/strong-password.md new file mode 100644 index 00000000..bda4352b --- /dev/null +++ b/snippets/regex/validation pattern/strong-password.md @@ -0,0 +1,17 @@ +--- +Title: Strong Password +Description: Match password with at least 12 characters, one uppercased letter, one number, and one special character. +Author: majvax +Tags: password +--- + + +```regex +^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{12,}$ + +-> Usage: +longpassword ✗ +longpassw0rd ✗ +longp@ssw0rd ✗ +Longp@ssw0rd ✓ +``` From f1a7b49ddcb0c1ac12c8a374b07d049cec34d083 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 4 Jan 2025 14:22:17 +0000 Subject: [PATCH 07/13] Update consolidated snippets --- public/consolidated/_index.json | 4 +++ public/consolidated/cpp.json | 17 ++++++++++++ public/consolidated/javascript.json | 18 ++++-------- public/consolidated/regex.json | 43 +++++++++++++++++++++++++++++ public/icons/regex.svg | 6 ++++ 5 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 public/consolidated/regex.json create mode 100644 public/icons/regex.svg diff --git a/public/consolidated/_index.json b/public/consolidated/_index.json index 6f82a67a..48d9f945 100644 --- a/public/consolidated/_index.json +++ b/public/consolidated/_index.json @@ -35,6 +35,10 @@ "lang": "PYTHON", "icon": "/icons/python.svg" }, + { + "lang": "REGEX", + "icon": "/icons/regex.svg" + }, { "lang": "RUST", "icon": "/icons/rust.svg" diff --git a/public/consolidated/cpp.json b/public/consolidated/cpp.json index e560e82d..6427f04f 100644 --- a/public/consolidated/cpp.json +++ b/public/consolidated/cpp.json @@ -32,6 +32,23 @@ } ] }, + { + "categoryName": "Debuging", + "snippets": [ + { + "title": "Vector Print", + "description": "Overloads the << operator to print the contents of a vector just like in python.", + "author": "Mohamed-faaris", + "tags": [ + "printing", + "debuging", + "vector" + ], + "contributors": [], + "code": "#include \n#include \n\ntemplate \nstd::ostream& operator<<(std::ostream& os, const std::vector& vec) {\n os << \"[\"; \n for (size_t i = 0; i < vec.size(); ++i) {\n os << vec[i]; // Print each vector element\n if (i != vec.size() - 1) {\n os << \", \"; // Add separator\n }\n }\n os << \"]\"; \n return os; // Return the stream\n}\n\n// Usage:\nstd::vector numbers = {1, 2, 3, 4, 5};\nstd::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]\n\n" + } + ] + }, { "categoryName": "Math And Numbers", "snippets": [ diff --git a/public/consolidated/javascript.json b/public/consolidated/javascript.json index 99588330..c7b78ff8 100644 --- a/public/consolidated/javascript.json +++ b/public/consolidated/javascript.json @@ -85,10 +85,8 @@ "description": "Converts RGB color values to hexadecimal color code.", "author": "jjcantu", "tags": [ - "javascript", "color", - "conversion", - "utility" + "conversion" ], "contributors": [], "code": "function rgbToHex(r, g, b) {\n const toHex = (n) => {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n \n return '#' + toHex(r) + toHex(g) + toHex(b);\n}\n\n// Usage:\nconsole.log(rgbToHex(255, 128, 0)); // Output: \"#ff8000\"\nconsole.log(rgbToHex(0, 255, 0)); // Output: \"#00ff00\"\n" @@ -407,10 +405,8 @@ "description": "Converts bytes into human-readable file size format.", "author": "jjcantu", "tags": [ - "javascript", "format", - "size", - "utility" + "size" ], "contributors": [], "code": "function formatFileSize(bytes) {\n if (bytes === 0) return '0 Bytes';\n \n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n \n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n}\n\n// Usage:\nconsole.log(formatFileSize(1234)); // Output: \"1.21 KB\"\nconsole.log(formatFileSize(1234567)); // Output: \"1.18 MB\"\n" @@ -506,13 +502,11 @@ "description": "Creates a deep copy of an object or array without reference.", "author": "jjcantu", "tags": [ - "javascript", "object", - "clone", - "utility" + "clone" ], "contributors": [], - "code": "function deepClone(obj) {\n if (obj === null || typeof obj !== 'object') return obj;\n \n const clone = Array.isArray(obj) ? [] : {};\n \n for (let key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = deepClone(obj[key]);\n }\n }\n \n return clone;\n}\n\n// Usage:\nconst original = { a: 1, b: { c: 2 }, d: [1, 2, 3] };\nconst cloned = deepClone(original);\nconsole.log(cloned); // Output: { a: 1, b: { c: 2 }, d: [1, 2, 3] }\n" + "code": "function deepClone(obj) {\n if (obj === null || typeof obj !== 'object') return obj;\n \n const clone = Array.isArray(obj) ? [] : {};\n \n for (let key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = deepClone(obj[key]);\n }\n }\n \n return clone;\n}\n\n// Usage:\nconst original = { a: 1, b: { c: 2 }, d: [1, 2, 3] };\nconst cloned = deepClone(original);\nconsole.log(cloned); // Output: 'original' but cloned\n" }, { "title": "Filter Object", @@ -758,9 +752,9 @@ "description": "Generates a UUID (v4) string.", "author": "jjcantu", "tags": [ - "javascript", "uuid", - "utility" + "generate", + "string" ], "contributors": [], "code": "function generateUUID() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n const r = Math.random() * 16 | 0;\n const v = c === 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n}\n\n// Usage:\nconsole.log(generateUUID()); // Output: \"a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5\"\n" diff --git a/public/consolidated/regex.json b/public/consolidated/regex.json new file mode 100644 index 00000000..f41a59b9 --- /dev/null +++ b/public/consolidated/regex.json @@ -0,0 +1,43 @@ +[ + { + "categoryName": "Miscellaneous", + "snippets": [ + { + "title": "Hexadecimal Color", + "description": "Matches hex color codes", + "author": "majvax", + "tags": [ + "color", + "hexadecimal" + ], + "contributors": [], + "code": "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$\n\n\n-> Usage:\n#FFF1 ✗\n#FFF ✓\n#FFF000 ✓\n" + } + ] + }, + { + "categoryName": "Validation pattern", + "snippets": [ + { + "title": "Email Address", + "description": "Match any email address", + "author": "majvax", + "tags": [ + "email" + ], + "contributors": [], + "code": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$\n\n-> Usage:\nexample.name@domain.com.ru ✓\nname.surname@gmail.com ✓\n" + }, + { + "title": "Strong Password", + "description": "Match password with at least 12 characters, one uppercased letter, one number, and one special character.", + "author": "majvax", + "tags": [ + "password" + ], + "contributors": [], + "code": "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{12,}$\n\n-> Usage:\nlongpassword ✗\nlongpassw0rd ✗\nlongp@ssw0rd ✗\nLongp@ssw0rd ✓\n" + } + ] + } +] \ No newline at end of file diff --git a/public/icons/regex.svg b/public/icons/regex.svg new file mode 100644 index 00000000..bdbe2fc2 --- /dev/null +++ b/public/icons/regex.svg @@ -0,0 +1,6 @@ + + + + + + From 5ac43f75d1a84af8c49bd2eea37c3a11d81d4e1a Mon Sep 17 00:00:00 2001 From: majvax Date: Sat, 4 Jan 2025 15:53:56 +0100 Subject: [PATCH 08/13] added 3 more snippets --- snippets/regex/miscellaneous/ipv4.md | 17 +++++++++++++++++ .../unintentional-duplication.md | 16 ++++++++++++++++ .../regex/miscellaneous/whitespace-trimmer.md | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 snippets/regex/miscellaneous/ipv4.md create mode 100644 snippets/regex/miscellaneous/unintentional-duplication.md create mode 100644 snippets/regex/miscellaneous/whitespace-trimmer.md diff --git a/snippets/regex/miscellaneous/ipv4.md b/snippets/regex/miscellaneous/ipv4.md new file mode 100644 index 00000000..8ca4a157 --- /dev/null +++ b/snippets/regex/miscellaneous/ipv4.md @@ -0,0 +1,17 @@ +--- +Title: IPv4 +Description: Matches IPv4 address +Author: majvax +Tags: ipv4,networking +--- + + +```regex +^((25[0-5]|2[0-4]\d|1\d{2}|\d{1,2})\.){3}(25[0-5]|2[0-4]\d|1\d{2}|\d{1,2})$ + + +-> Usage: +123.300.0.101 ✗ +127.0.0.1 ✓ +192.168.0.1 ✓ +``` diff --git a/snippets/regex/miscellaneous/unintentional-duplication.md b/snippets/regex/miscellaneous/unintentional-duplication.md new file mode 100644 index 00000000..d03a089e --- /dev/null +++ b/snippets/regex/miscellaneous/unintentional-duplication.md @@ -0,0 +1,16 @@ +--- +Title: Unintentional Duplication +Description: Matches duplicated word in a text. +Author: majvax +Tags: trim +--- + + +```regex +\b(\w+)\s+\1\b + + +-> Usage: +I need to finish this task ✗ +I need to to finish this task ✓ +``` diff --git a/snippets/regex/miscellaneous/whitespace-trimmer.md b/snippets/regex/miscellaneous/whitespace-trimmer.md new file mode 100644 index 00000000..e55ae56f --- /dev/null +++ b/snippets/regex/miscellaneous/whitespace-trimmer.md @@ -0,0 +1,19 @@ +--- +Title: Whitespace Trimmer +Description: Matches leading and/or trailing whitespace. +Author: majvax +Tags: trim +--- + + +```regex +^\s+|\s+$ + + +-> Usage: +(don't account for the quotation marks, it just to visualize whitespace) +"Hello World" ✗ +" Hello World" ✓ +"Hello World " ✓ +" Hello World " ✓ +``` From 9eda0f6033a231f0be43bcccc10f07d72b421616 Mon Sep 17 00:00:00 2001 From: majvax Date: Sat, 4 Jan 2025 15:54:39 +0100 Subject: [PATCH 09/13] Auto stash before merge of "regex" and "origin/regex" --- public/consolidated/regex.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/public/consolidated/regex.json b/public/consolidated/regex.json index f41a59b9..759b8b79 100644 --- a/public/consolidated/regex.json +++ b/public/consolidated/regex.json @@ -12,6 +12,40 @@ ], "contributors": [], "code": "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$\n\n\n-> Usage:\n#FFF1 ✗\n#FFF ✓\n#FFF000 ✓\n" +<<<<<<< Updated upstream +======= + }, + { + "title": "IPv4", + "description": "Matches IPv4 address", + "author": "majvax", + "tags": [ + "ipv4", + "networking" + ], + "contributors": [], + "code": "^((25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.){3}(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})$\n\n\n-> Usage:\n123.300.0.101 ✗\n127.0.0.1 ✓\n192.168.0.1 ✓\n" + }, + { + "title": "Unintentional Duplication", + "description": "Matches duplicated word in a text.", + "author": "majvax", + "tags": [ + "trim" + ], + "contributors": [], + "code": "\\b(\\w+)\\s+\\1\\b\n\n\n-> Usage:\nI need to finish this task ✗\nI need to to finish this task ✓\n" + }, + { + "title": "Whitespace Trimmer", + "description": "Matches leading and/or trailing whitespace.", + "author": "majvax", + "tags": [ + "trim" + ], + "contributors": [], + "code": "^\\s+|\\s+$\n\n\n-> Usage:\n(don't account for the quotation marks, it just to visualize whitespace)\n\"Hello World\" ✗\n\" Hello World\" ✓\n\"Hello World \" ✓\n\" Hello World \" ✓\n" +>>>>>>> Stashed changes } ] }, From 4b438ef8d7aa57b19f119e96bd5a5359c42a40ee Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 4 Jan 2025 14:55:15 +0000 Subject: [PATCH 10/13] Update consolidated snippets --- public/consolidated/regex.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/public/consolidated/regex.json b/public/consolidated/regex.json index 759b8b79..274c9b2a 100644 --- a/public/consolidated/regex.json +++ b/public/consolidated/regex.json @@ -12,8 +12,6 @@ ], "contributors": [], "code": "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$\n\n\n-> Usage:\n#FFF1 ✗\n#FFF ✓\n#FFF000 ✓\n" -<<<<<<< Updated upstream -======= }, { "title": "IPv4", @@ -45,7 +43,6 @@ ], "contributors": [], "code": "^\\s+|\\s+$\n\n\n-> Usage:\n(don't account for the quotation marks, it just to visualize whitespace)\n\"Hello World\" ✗\n\" Hello World\" ✓\n\"Hello World \" ✓\n\" Hello World \" ✓\n" ->>>>>>> Stashed changes } ] }, From b3ad9071a9b9d09da9d0c1cfd2da7529e812cb18 Mon Sep 17 00:00:00 2001 From: majvax Date: Sat, 4 Jan 2025 15:56:00 +0100 Subject: [PATCH 11/13] fixed a tag --- snippets/regex/miscellaneous/unintentional-duplication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/regex/miscellaneous/unintentional-duplication.md b/snippets/regex/miscellaneous/unintentional-duplication.md index d03a089e..ee6713f3 100644 --- a/snippets/regex/miscellaneous/unintentional-duplication.md +++ b/snippets/regex/miscellaneous/unintentional-duplication.md @@ -2,7 +2,7 @@ Title: Unintentional Duplication Description: Matches duplicated word in a text. Author: majvax -Tags: trim +Tags: duplication --- From 124a614f2341078aebac968d726b2d97647e6c31 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 4 Jan 2025 14:56:37 +0000 Subject: [PATCH 12/13] Update consolidated snippets --- public/consolidated/regex.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/consolidated/regex.json b/public/consolidated/regex.json index 274c9b2a..2d8330c7 100644 --- a/public/consolidated/regex.json +++ b/public/consolidated/regex.json @@ -29,7 +29,7 @@ "description": "Matches duplicated word in a text.", "author": "majvax", "tags": [ - "trim" + "duplication" ], "contributors": [], "code": "\\b(\\w+)\\s+\\1\\b\n\n\n-> Usage:\nI need to finish this task ✗\nI need to to finish this task ✓\n" From e4b3b5f8c8568a36082495959190807fdd4828cc Mon Sep 17 00:00:00 2001 From: Emosans Date: Sat, 4 Jan 2025 21:45:42 +0530 Subject: [PATCH 13/13] changes --- snippets/c/mathematical-functions/swap-numbers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/c/mathematical-functions/swap-numbers.md b/snippets/c/mathematical-functions/swap-numbers.md index a655a4cf..bbbc4a2b 100644 --- a/snippets/c/mathematical-functions/swap-numbers.md +++ b/snippets/c/mathematical-functions/swap-numbers.md @@ -15,5 +15,5 @@ void swap(int* num1,int* num2){ // Usage: int a = 3,b = 4; -swap(&a,&b); // simply use printf after this to print swapped values +swap(&a,&b); // swaps the values of the a and b variables ``` \ No newline at end of file