Skip to content

Commit b1bcd0f

Browse files
Migrating snippets to the new format using utils/migrateSnippets.js
1 parent e41e1bc commit b1bcd0f

File tree

184 files changed

+3417
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+3417
-0
lines changed

snippets/c/basics/hello-world.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
Title: Hello, World!
3+
Description: Prints Hello, World! to the terminal.
4+
Author: 0xHouss
5+
Tags: c,printing,hello-world,utility
6+
---
7+
8+
```
9+
#include <stdio.h> // Includes the input/output library
10+
11+
int main() { // Defines the main function
12+
printf("Hello, World!\n") // Outputs Hello, World! and a newline
13+
14+
return 0; // indicate the program executed successfully
15+
}
16+
```

snippets/c/icon.svg

Lines changed: 15 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: Factorial Function
3+
Description: Calculates the factorial of a number.
4+
Author: 0xHouss
5+
Tags: c,math,factorial,utility
6+
---
7+
8+
```
9+
int factorial(int x) {
10+
int y = 1;
11+
12+
for (int i = 2; i <= x; i++)
13+
y *= i;
14+
15+
return y;
16+
}
17+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
Title: Power Function
3+
Description: Calculates the power of a number.
4+
Author: 0xHouss
5+
Tags: c,math,power,utility
6+
---
7+
8+
```
9+
int power(int x, int n) {
10+
int y = 1;
11+
12+
for (int i = 0; i < n; i++)
13+
y *= x;
14+
15+
return y;
16+
}
17+
```

snippets/cpp/basics/hello-world.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
Title: Hello, World!
3+
Description: Prints Hello, World! to the terminal.
4+
Author: James-Beans
5+
Tags: cpp,printing,hello-world,utility
6+
---
7+
8+
```
9+
#include <iostream> // Includes the input/output stream library
10+
11+
int main() { // Defines the main function
12+
std::cout << "Hello, World!" << std::endl; // Outputs Hello, World! and a newline
13+
return 0; // indicate the program executed successfully
14+
}
15+
```

snippets/cpp/icon.svg

Lines changed: 10 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: Reverse String
3+
Description: Reverses the characters in a string.
4+
Author: Vaibhav-kesarwani
5+
Tags: cpp,array,reverse,utility
6+
---
7+
8+
```
9+
#include <string>
10+
#include <algorithm>
11+
12+
std::string reverseString(const std::string& input) {
13+
std::string reversed = input;
14+
std::reverse(reversed.begin(), reversed.end());
15+
return reversed;
16+
}
17+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
Title: Split String
3+
Description: Splits a string by a delimiter
4+
Author: saminjay
5+
Tags: cpp,string,split,utility
6+
---
7+
8+
```
9+
#include <string>
10+
#include <vector>
11+
12+
std::vector<std::string> split_string(std::string str, std::string delim) {
13+
std::vector<std::string> splits;
14+
int i = 0, j;
15+
int inc = delim.length();
16+
while (j != std::string::npos) {
17+
j = str.find(delim, i);
18+
splits.push_back(str.substr(i, j - i));
19+
i = j + inc;
20+
}
21+
return splits;
22+
}
23+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
Title: 3D Button Effect
3+
Description: Adds a 3D effect to a button when clicked.
4+
Author: dostonnabotov
5+
Tags: css,button,3D,effect
6+
---
7+
8+
```
9+
.button {
10+
background-color: #28a745;
11+
color: white;
12+
padding: 10px 20px;
13+
border: none;
14+
border-radius: 5px;
15+
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
16+
transition: transform 0.1s;
17+
}
18+
19+
.button:active {
20+
transform: translateY(2px);
21+
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
22+
}
23+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
Title: Button Hover Effect
3+
Description: Creates a hover effect with a color transition.
4+
Author: dostonnabotov
5+
Tags: css,button,hover,transition
6+
---
7+
8+
```
9+
.button {
10+
background-color: #007bff;
11+
color: white;
12+
padding: 10px 20px;
13+
border: none;
14+
border-radius: 5px;
15+
cursor: pointer;
16+
transition: background-color 0.3s ease;
17+
}
18+
19+
.button:hover {
20+
background-color: #0056b3;
21+
}
22+
```

0 commit comments

Comments
 (0)