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/regex.json b/public/consolidated/regex.json new file mode 100644 index 00000000..2d8330c7 --- /dev/null +++ b/public/consolidated/regex.json @@ -0,0 +1,74 @@ +[ + { + "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" + }, + { + "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": [ + "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" + }, + { + "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" + } + ] + }, + { + "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 @@ + + + + + + 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/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..ee6713f3 --- /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: duplication +--- + + +```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 " ✓ +``` 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 ✓ +```