Skip to content

Commit 49b2835

Browse files
committed
2 parents 6c0959a + 6eccace commit 49b2835

File tree

13 files changed

+238
-0
lines changed

13 files changed

+238
-0
lines changed

public/consolidated/_index.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
"lang": "PYTHON",
3636
"icon": "/icons/python.svg"
3737
},
38+
{
39+
"lang": "REGEX",
40+
"icon": "/icons/regex.svg"
41+
},
3842
{
3943
"lang": "RUST",
4044
"icon": "/icons/rust.svg"

public/consolidated/c.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
],
2929
"contributors": [],
3030
"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"
31+
},
32+
{
33+
"title": "Swap numbers",
34+
"description": "Swaps two numbers without using third variable",
35+
"author": "Emosans",
36+
"tags": [
37+
"swap",
38+
"numbers"
39+
],
40+
"contributors": [],
41+
"code": "#include<stdio.h>\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"
3142
}
3243
]
3344
}

public/consolidated/cpp.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@
3232
}
3333
]
3434
},
35+
{
36+
"categoryName": "Debuging",
37+
"snippets": [
38+
{
39+
"title": "Vector Print",
40+
"description": "Overloads the << operator to print the contents of a vector just like in python.",
41+
"author": "Mohamed-faaris",
42+
"tags": [
43+
"printing",
44+
"debuging",
45+
"vector"
46+
],
47+
"contributors": [],
48+
"code": "#include <iostream> \n#include <vector> \n\ntemplate <typename T>\nstd::ostream& operator<<(std::ostream& os, const std::vector<T>& 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<int> numbers = {1, 2, 3, 4, 5};\nstd::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]\n\n"
49+
}
50+
]
51+
},
3552
{
3653
"categoryName": "Math And Numbers",
3754
"snippets": [

public/consolidated/regex.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"categoryName": "Miscellaneous",
4+
"snippets": [
5+
{
6+
"title": "Hexadecimal Color",
7+
"description": "Matches hex color codes",
8+
"author": "majvax",
9+
"tags": [
10+
"color",
11+
"hexadecimal"
12+
],
13+
"contributors": [],
14+
"code": "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$\n\n\n-> Usage:\n#FFF1 ✗\n#FFF ✓\n#FFF000 ✓\n"
15+
},
16+
{
17+
"title": "IPv4",
18+
"description": "Matches IPv4 address",
19+
"author": "majvax",
20+
"tags": [
21+
"ipv4",
22+
"networking"
23+
],
24+
"contributors": [],
25+
"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"
26+
},
27+
{
28+
"title": "Unintentional Duplication",
29+
"description": "Matches duplicated word in a text.",
30+
"author": "majvax",
31+
"tags": [
32+
"duplication"
33+
],
34+
"contributors": [],
35+
"code": "\\b(\\w+)\\s+\\1\\b\n\n\n-> Usage:\nI need to finish this task ✗\nI need to to finish this task ✓\n"
36+
},
37+
{
38+
"title": "Whitespace Trimmer",
39+
"description": "Matches leading and/or trailing whitespace.",
40+
"author": "majvax",
41+
"tags": [
42+
"trim"
43+
],
44+
"contributors": [],
45+
"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"
46+
}
47+
]
48+
},
49+
{
50+
"categoryName": "Validation pattern",
51+
"snippets": [
52+
{
53+
"title": "Email Address",
54+
"description": "Match any email address",
55+
"author": "majvax",
56+
"tags": [
57+
"email"
58+
],
59+
"contributors": [],
60+
"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"
61+
},
62+
{
63+
"title": "Strong Password",
64+
"description": "Match password with at least 12 characters, one uppercased letter, one number, and one special character.",
65+
"author": "majvax",
66+
"tags": [
67+
"password"
68+
],
69+
"contributors": [],
70+
"code": "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{12,}$\n\n-> Usage:\nlongpassword ✗\nlongpassw0rd ✗\nlongp@ssw0rd ✗\nLongp@ssw0rd ✓\n"
71+
}
72+
]
73+
}
74+
]

public/icons/regex.svg

Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Swap numbers
3+
description: Swaps two numbers without using third variable
4+
author: Emosans
5+
tags: swap,numbers
6+
---
7+
8+
```c
9+
#include<stdio.h>
10+
void swap(int* num1,int* num2){
11+
*num1 = *num1 + *num2;
12+
*num2 = *num1 - *num2;
13+
*num1 = *num1 - *num2;
14+
}
15+
16+
// Usage:
17+
int a = 3,b = 4;
18+
swap(&a,&b); // swaps the values of the a and b variables
19+
```

snippets/regex/icon.svg

Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
Title: Hexadecimal Color
3+
Description: Matches hex color codes
4+
Author: majvax
5+
Tags: color,hexadecimal
6+
---
7+
8+
9+
```regex
10+
^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
11+
12+
13+
-> Usage:
14+
#FFF1 ✗
15+
#FFF ✓
16+
#FFF000 ✓
17+
```

snippets/regex/miscellaneous/ipv4.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
Title: IPv4
3+
Description: Matches IPv4 address
4+
Author: majvax
5+
Tags: ipv4,networking
6+
---
7+
8+
9+
```regex
10+
^((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})$
11+
12+
13+
-> Usage:
14+
123.300.0.101 ✗
15+
127.0.0.1 ✓
16+
192.168.0.1 ✓
17+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
Title: Unintentional Duplication
3+
Description: Matches duplicated word in a text.
4+
Author: majvax
5+
Tags: duplication
6+
---
7+
8+
9+
```regex
10+
\b(\w+)\s+\1\b
11+
12+
13+
-> Usage:
14+
I need to finish this task ✗
15+
I need to to finish this task ✓
16+
```

0 commit comments

Comments
 (0)