Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c59610

Browse files
committed
Merge branch 'main' into feature/optimised-highlighter
2 parents f205b88 + 750abfe commit 9c59610

Some content is hidden

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

59 files changed

+1535
-60
lines changed

‎.github/workflows/check-snippets.yml‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ jobs:
99
check-snippets:
1010
runs-on: ubuntu-latest
1111

12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
1216
steps:
1317
- name: Checkout repository
14-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1519

1620
- name: Set up Node.js
17-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
1822
with:
19-
node-version: "16"
23+
node-version: 22
2024

2125
- name: Check if snippets are formated correctly
22-
run: |
23-
node utils/checkSnippetFormatting.js # Run the script located in the utils/ folder
26+
uses: int128/comment-action@v1
27+
with:
28+
run: node utils/checkSnippetFormatting.js # Run the script located in the utils/ folder
29+
post-on-failure: |
30+
## :x: Snippet Format Error
31+
${run.output}

‎.github/workflows/consolidate-snippets.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818

1919
- name: Set up Node.js
20-
uses: actions/setup-node@v3
20+
uses: actions/setup-node@v4
2121
with:
22-
node-version: "16"
22+
node-version: 22
2323

2424
- name: Install dependencies
2525
run: |
@@ -34,5 +34,6 @@ jobs:
3434
git config --global user.name "GitHub Action"
3535
git config --global user.email "action@github.com"
3636
git add public/consolidated/*
37+
git add public/icons/*
3738
git commit -m "Update consolidated snippets"
3839
git push

‎.prettierignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
node_modules
22
dist
3+
snippets
4+
public
35
.vite
46
coverage
57
package-lock.json

‎CONTRIBUTING.md‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,51 +43,55 @@ To add a new code snippet:
4343

4444
- Use the following format to structure your snippet:
4545

46-
```md
46+
````md
4747
---
4848
title: Name of the snippet
4949
description: A short explanation of what the snippet does
5050
tags: tag1, tag2, tag3
5151
author: your-github-username
5252
---
5353

54+
```lang
5455
// Your code here
5556
```
57+
````
5658

5759
Here’s an example for JavaScript:
5860

59-
```
61+
````md
6062
---
6163
title: Format Date
6264
description: Formats a date in 'YYYY-MM-DD' format.
6365
author: dostonnabotov
64-
tags: javascript,date,format,utility
66+
tags: javascript,date,format
6567
---
6668

69+
```js
6770
const formatDate = (date) => date.toISOString().split('T')[0];
6871

6972
// Usage:
7073
console.log(formatDate(new Date())); // Output: '2024年12月10日'
7174
```
75+
````
7276

7377
5. **Use syntax highlighting:**
7478
- Enclose your code with triple backticks (```).
7579
- Specify the language after the first set of backticks for syntax highlighting.
7680

77-
![snippet code example in markdown file](https://github.com/user-attachments/assets/be650cfe-fd17-49e7-ae82-e1c88e30d4c9)
78-
7981
6. **Test your snippet:**
8082
- Ensure your code runs as expected.
8183

82-
Expected structure:
84+
Expected file structure:
8385

84-
```txt
85-
snippets
86+
```md
87+
/snippets
8688
|- language
87-
|- category
89+
|- category-name
8890
|- your-snippet-here.md
8991
```
9092

93+
> Please do **NOT** add or edit anything in `/public` folder. It will be used for consolidating snippets.
94+
9195
### Editing a Existing Snippet
9296

9397
If you’d like to refine or improve an existing snippet:
@@ -96,7 +100,7 @@ If you’d like to refine or improve an existing snippet:
96100

97101
- Include your GitHub username under the `contributors` field in the metadata section.
98102

99-
```md
103+
````md
100104
---
101105
title: Name of the snippet
102106
description: A short explanation of what the snippet does
@@ -105,8 +109,10 @@ author: original-author
105109
contributors: your-github-username
106110
---
107111

112+
```
108113
Updated code here
109114
```
115+
````
110116

111117
2. **Credit all contributors:**
112118

@@ -118,9 +124,9 @@ contributors: contributor1, contributor2, your-github-username
118124

119125
3. **Document changes:**
120126

121-
Clearly indicate what you updated and why in your pull request description.
127+
-Clearly indicate what you updated and why in your pull request description.
122128

123-
We want to make sure that original author and contributor(s) are credited for their work.
129+
> We want to make sure that original author and contributor(s) are credited for their work.
124130
125131

126132
### Adding a New Category
@@ -141,10 +147,10 @@ Example structure:
141147

142148
```md
143149
/snippets
144-
|_ python
145-
|_ file-handling
146-
|_ list-manipulation
147-
|_ ....
150+
|- python
151+
|- file-handling
152+
|- list-manipulation
153+
|- ....
148154
```
149155

150156
### Adding a New Language

‎README.md‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
An open-source project that categorizes handy code snippets across various programming languages. Built with love and powered by an awesome community. 🚀
44

5-
<a href="https://youtu.be/BhRi7fJzPgk?si=z1sVXU7uRS0bkSEt" target="_blank" style="text-decoration: none;">
6-
<img src="https://img.shields.io/static/v1?label=&message=Watch%20on%20YouTube&labelColor=FFFFFF&color=FF0000&style=for-the-badge&logo=youtube&logoColor=FF0000" alt="Watch on YouTube" style="margin-right: 20px">
5+
<div>
6+
<a href="https://youtu.be/BhRi7fJzPgk?si=z1sVXU7uRS0bkSEt" target="_blank">
7+
<img src="https://img.shields.io/static/v1?label=&message=Watch%20on%20YouTube&labelColor=FFFFFF&color=FF0000&style=for-the-badge&logo=youtube&logoColor=FF0000" alt="Watch on YouTube">
78
</a>
9+
<div>
810

911
<br>
1012

@@ -36,20 +38,47 @@ The snippets database is located in the `/snippets` folder.
3638

3739
3. Create a markdown file and add your snippet using the following format:
3840

39-
```md
41+
````md
4042
---
4143
title: Name of the snippet
4244
description: A short explanation of what the snippet does
4345
tags: tag1, tag2, tag3
4446
author: your-github-username
4547
---
4648

49+
```lang
4750
// Your code here
4851
```
52+
````
4953

5054
Here's an example for JavaScript:
5155

52-
![code example in markdown file](https://github.com/user-attachments/assets/dba9fda3-76fe-4d92-b12a-8bc065286b90)
56+
````md
57+
---
58+
title: Format Date
59+
description: Formats a date in 'YYYY-MM-DD' format.
60+
author: dostonnabotov
61+
tags: javascript,date,format
62+
---
63+
64+
```js
65+
const formatDate = (date) => date.toISOString().split('T')[0];
66+
67+
// Usage:
68+
console.log(formatDate(new Date())); // Output: '2024年12月10日'
69+
```
70+
````
71+
72+
Expected file structure:
73+
74+
```md
75+
/snippets
76+
|- language
77+
|- category-name
78+
|- your-snippet-here.md
79+
```
80+
81+
> Please do **NOT** add or edit anything in `/public` folder. It will be used for consolidating snippets.
5382
5483
For more details about adding new categories or programming languages, check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file.
5584

‎package-lock.json‎

Lines changed: 38 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"prepare": "husky"
1414
},
1515
"dependencies": {
16+
"framer-motion": "^11.15.0",
1617
"prismjs": "^1.29.0",
1718
"react": "^18.3.1",
1819
"react-dom": "^18.3.1",

‎public/consolidated/_index.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@
77
"lang": "CPP",
88
"icon": "/icons/cpp.svg"
99
},
10+
{
11+
"lang": "CSHARP",
12+
"icon": "/icons/csharp.svg"
13+
},
1014
{
1115
"lang": "CSS",
1216
"icon": "/icons/css.svg"
1317
},
18+
{
19+
"lang": "HASKELL",
20+
"icon": "/icons/haskell.svg"
21+
},
1422
{
1523
"lang": "HTML",
1624
"icon": "/icons/html.svg"

‎public/consolidated/cpp.json‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,41 @@
1717
}
1818
]
1919
},
20+
{
21+
"categoryName": "Data Structure Conversion",
22+
"snippets": [
23+
{
24+
"title": "Vector to Queue",
25+
"description": "Convert vector into queue quickly",
26+
"author": "mrityunjay2003",
27+
"tags": [
28+
"cpp",
29+
"data structures",
30+
"queue",
31+
"vector"
32+
],
33+
"contributors": [],
34+
"code": "#include<queue>\n#include<vector>\n#include<deque>\n\nstd::queue<int> vectorToQueue(const std::vector<int>& v) {\n return std::queue<int>(std::deque<int>(v.begin(), v.end()));\n}\n"
35+
}
36+
]
37+
},
38+
{
39+
"categoryName": "Math And Numbers",
40+
"snippets": [
41+
{
42+
"title": "Check Prime Number",
43+
"description": "Check if an integer is a prime number",
44+
"author": "MihneaMoso",
45+
"tags": [
46+
"cpp",
47+
"number",
48+
"prime"
49+
],
50+
"contributors": [],
51+
"code": "bool is_prime(int n) {\n if (n < 2) return false;\n if (n == 2 || n == 3) return true;\n if (n % 2 == 0) return false;\n for (int i = 3; i * i <= n; i += 2) {\n if (n % i == 0) return false;\n }\n return true;\n}\n\n// Usage\n#include <iostream>\n\nint main() {\n std::cout << is_prime(29) << std::endl; // Output: 1\n return 0;\n}\n"
52+
}
53+
]
54+
},
2055
{
2156
"categoryName": "String Manipulation",
2257
"snippets": [

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /