Skip to content

Commit defc7c4

Browse files
Merge branch 'dostonnabotov:main' into main
2 parents ba6337f + 621db73 commit defc7c4

File tree

14 files changed

+259
-0
lines changed

14 files changed

+259
-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/javascript.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,22 @@
364364
}
365365
]
366366
},
367+
{
368+
"categoryName": "Mathematical Functions",
369+
"snippets": [
370+
{
371+
"title": "Greatest Common Divisor",
372+
"description": "Calculates the largest positive integer that divides each of the integers without leaving a remainder. Useful for calculating aspect ratios.",
373+
"author": "JanluOfficial",
374+
"tags": [
375+
"math",
376+
"division"
377+
],
378+
"contributors": [],
379+
"code": "function gcd(a, b) {\n while (b !== 0) {\n let temp = b;\n b = a % b;\n a = temp;\n }\n return a;\n}\n\n// Usage:\ngcd(1920, 1080); // Returns: 120\ngcd(1920, 1200); // Returns: 240\ngcd(5,12); // Returns: 1\n"
380+
}
381+
]
382+
},
367383
{
368384
"categoryName": "Number Formatting",
369385
"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:\n[email protected]\n[email protected]\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+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Greatest Common Divisor
3+
description: Calculates the largest positive integer that divides each of the integers without leaving a remainder. Useful for calculating aspect ratios.
4+
author: JanluOfficial
5+
tags: math,division
6+
---
7+
8+
```js
9+
function gcd(a, b) {
10+
while (b !== 0) {
11+
let temp = b;
12+
b = a % b;
13+
a = temp;
14+
}
15+
return a;
16+
}
17+
18+
// Usage:
19+
gcd(1920, 1080); // Returns: 120
20+
gcd(1920, 1200); // Returns: 240
21+
gcd(5,12); // Returns: 1
22+
```

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+
```

0 commit comments

Comments
 (0)