Skip to content

Commit

Permalink
Merge branch 'dostonnabotov:main' into snippets-c++
Browse files Browse the repository at this point in the history
  • Loading branch information
majvax authored Jan 3, 2025
2 parents c0d6f04 + 11625c1 commit 1dd6a8f
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 21 deletions.
7 changes: 5 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
* @Mathys-Gasnier

# Code maintainers
/src/ @psychlone77 @saminjay
/src/ @psychlone77 @saminjay @Mathys-Gasnier

# Snippets maintainers
/snippets @Mathys-Gasnier
/snippets @majvax @Mathys-Gasnier
/snippets/javascript @psychlone77 @saminjay
/snippets/python @psychlone77 @saminjay
/snippets/cpp @saminjay


# ---------- What is a maintainer ----------
Expand Down
39 changes: 28 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,41 @@ You can contribute in two main ways:

## Improving the code

If you have a feature request or want to fix a bug, feel free to:
### How to report bugs

- [Open an Issue](https://github.com/dostonnabotov/quicksnip/issues) to let us know what’s up.
- [Send a Pull Request](https://github.com/dostonnabotov/quicksnip/pulls) with your changes.
If you spot a bug in the codebase or issues with the documentation, please open up a [GitHub issue](https://github.com/dostonnabotov/quicksnip/issues) detailing the problem before creating a PR. Once confirmed with maintainers, you can then create a PR.

### How to propose new features

If you are interested in proposing new features, please open up a new [GitHub discussion](https://github.com/dostonnabotov/quicksnip/discussions) with details for the proposed feature.

Please do not create a PR for a new feature without first discussing it with the maintainers. If you create a PR for a new feature without discussing it first, then your PR will be closed.

---

## Snippets Guidelines

### Snippet Tags

Tags must describe the snippet with simple word. \
For example a snippet that capitalize a word would have `string` and `capitalize` as tags. \
**! Do not add the language you are using as a tag, nor some generic keyword like `utility` !**
- Tags must describe the snippet with simple word.

Here's an example:

```md
---
title: Convert Number to Currency
description: Converts a number to a currency format with a specific locale.
author: axorax
tags: number,currency
---
```

**Do not use generic keywords or the language itself as a tag `utility` or `javascript`!**

### Snippet Format

**All** snippets should follow the following structure:

- A `code` segment, containing a function with the actual snippet functionnality
- An `example` segement, containing one or more examples of use

Expand All @@ -41,17 +58,17 @@ function example(x) {
// Usage:
example(5) // Returns: 10
```
If your function doesn't return anything just show how to use it. \
If the result of your function is too complicated to be expressed in a single comment, your snippet is probably too complex to begin with.

If your function doesn't return anything just show how to use it. If the result of your function is too complicated to be expressed in a single comment, your snippet is probably too complex to begin with.

### Snippet boundaries

To **check if your snippet will not get refused** ask yourself those questions:
To ensure your snippet isn’t refused, consider these questions:
- **Does the standard library of my language provide an easy way of doing this ?**
- **Does that snippet have a real, and practical use case ?**
- **Could it be split into separate parts to be better understood ?**

If one of question is true, then your snippet will most likely get refused !
If any answer is yes, then your snippet will most likely get rejected.

---

Expand Down Expand Up @@ -230,6 +247,6 @@ If you want to introduce a new programming language, here's how to do it:

Whether you’re fixing a tiny typo, writing a new snippet, or dreaming up big features, every bit counts! 🛠️

If you have any questions or need help, feel free to open an issue or tag me.
If you have any questions or need help, feel free to open a new [GitHub discussion](https://github.com/dostonnabotov/quicksnip/discussions).

Happy coding! 💻✨
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ Be sure to check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file for detailed g

### Improving the code

Got a feature idea or bug fix? Here's how you can contribute:
- **Reporting bugs**

- [Open an issue](https://github.com/dostonnabotov/quicksnip/issues) to share your ideas or report a bug.
- [Send a pull request](https://github.com/dostonnabotov/quicksnip/pulls) with your changes.
- If you spot a bug in the codebase or issues with the documentation, please open up a [GitHub issue](https://github.com/dostonnabotov/quicksnip/issues) detailing the problem before creating a PR.
- Once confirmed with maintainers, you can then create a PR.

- **Proposing new features**

- If you are interested in proposing new features, please open up a new [GitHub discussion](https://github.com/dostonnabotov/quicksnip/discussions) with details for the proposed feature.
- Please do **not** create a PR for a new feature without first discussing it with the maintainers. If you create a PR for a new feature without discussing it first, then your PR will be closed.

### Adding a Snippet

Expand Down Expand Up @@ -99,11 +104,13 @@ For more details about adding new categories or programming languages, check out

To keep things smooth and consistent, please:

- Follow the formatting rules described above.
- Include all mandatory fields in the snippet.
- Test your snippet to ensure it works as expected.
- [x] Follow the style and contribution guidelines of this project.
- [x] Include all mandatory fields in the snippet.
- [x] Test your snippet to ensure it works as expected.

Following these guidelines helps us (and everyone else) review and merge your contributions faster.

Following these guidelines helps me (and everyone else) review and merge your contributions faster.
**If you fail to meet the guidelines, your PR will most likely get rejected.**

## License

Expand Down
54 changes: 53 additions & 1 deletion VISION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
# Vision for QuickSnip

Will be updating soon...
## What is QuickSnip?

QuickSnip is an open-source tool designed for developers who want to organize, search, and share code snippets. It aims to streamline the coding process by providing a centralized platform for snippet management.

## Core Principles

- **Developer Focused**: Focus on features that truly improve developer productivity.

- **Open and Extensible**: Encourage community contributions and integrations.

- **Lightweight and Fast**: Keep performance high and avoid unnecessary complexity.

## Our Goals

- Seamless snippet management without turning into an overly complex tool

- Enable collaboration and sharing while respecting user privacy and customization needs.

We do **NOT** aim to be:

- a component library
- a documentation

## QuickSnip Roadmap

### v1.0 (Launching Soon)

- [x] A new snippets storage system for better maintainability and scalability
- [ ] Search functionality
- [ ] A support for frameworks and libraries
- [ ] An ability to share snippets with others
- [ ] A basic SEO (Search Engine Optimization)

### v2.0 (Planned Vision)

- [ ] An ability to have private snippets with personal account
- [ ] Improved search functionality with filters
- [ ] An improved SEO (Search Engine Optimization)

### Potential Future Ideas

- [ ] Plugins for IDEs like VS Code and JetBrains
- [ ] Enterprise-grade support for larger organizations

## Disclaimer on Future Plans

This roadmap outlines our current vision for QuickSnip and may evolve based on user feedback, community contributions, and shifting priorities. We welcome your input and encourage you to help shape QuickSnip’s future.

## Future Vision

QuickSnip aims to become the preferred platform for developers to store, retrieve, and collaborate on code snippets.

Explore our [GitHub Releases](https://github.com/dostonnabotov/quicksnip/releases) for updates and join us on this journey.
56 changes: 56 additions & 0 deletions public/consolidated/javascript.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@
}
]
},
{
"categoryName": "Color Manipulation",
"snippets": [
{
"title": "RGB to Hex Color",
"description": "Converts RGB color values to hexadecimal color code.",
"author": "jjcantu",
"tags": [
"javascript",
"color",
"conversion",
"utility"
],
"contributors": [],
"code": "function rgbToHex(r, g, b) {\n const toHex = (n) => {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n \n return '#' + toHex(r) + toHex(g) + toHex(b);\n}\n\n// Usage:\nconsole.log(rgbToHex(255, 128, 0)); // Output: \"#ff8000\"\nconsole.log(rgbToHex(0, 255, 0)); // Output: \"#00ff00\"\n"
}
]
},
{
"categoryName": "Date And Time",
"snippets": [
Expand Down Expand Up @@ -384,6 +402,19 @@
"contributors": [],
"code": "const toScientificNotation = (num) => {\n if (isNaN(num)) {\n throw new Error('Input must be a number');\n }\n if (num === 0) {\n return '0e+0';\n }\n const exponent = Math.floor(Math.log10(Math.abs(num)));\n const mantissa = num / Math.pow(10, exponent);\n return `${mantissa.toFixed(2)}e${exponent >= 0 ? '+' : ''}${exponent}`;\n};\n\n// Usage:\ntoScientificNotation(12345); // Returns: '1.23e+4'\ntoScientificNotation(0.0005678); // Returns: '5.68e-4'\ntoScientificNotation(1000); // Returns: '1.00e+3'\ntoScientificNotation(0); // Returns: '0e+0'\ntoScientificNotation(-54321); // Returns: '-5.43e+4'\n"
},
{
"title": "Format File Size",
"description": "Converts bytes into human-readable file size format.",
"author": "jjcantu",
"tags": [
"javascript",
"format",
"size",
"utility"
],
"contributors": [],
"code": "function formatFileSize(bytes) {\n if (bytes === 0) return '0 Bytes';\n \n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n \n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n}\n\n// Usage:\nconsole.log(formatFileSize(1234)); // Output: \"1.21 KB\"\nconsole.log(formatFileSize(1234567)); // Output: \"1.18 MB\"\n"
},
{
"title": "Format Number with Commas",
"description": "Formats a number with commas for better readability (e.g., 1000 -> 1,000).",
Expand Down Expand Up @@ -470,6 +501,19 @@
"contributors": [],
"code": "function countProperties(obj) {\n return Object.keys(obj).length;\n}\n\n// Usage:\nconst obj = { a: 1, b: 2, c: 3 };\ncountProperties(obj); // Returns: 3\n"
},
{
"title": "Deep Clone Object",
"description": "Creates a deep copy of an object or array without reference.",
"author": "jjcantu",
"tags": [
"javascript",
"object",
"clone",
"utility"
],
"contributors": [],
"code": "function deepClone(obj) {\n if (obj === null || typeof obj !== 'object') return obj;\n \n const clone = Array.isArray(obj) ? [] : {};\n \n for (let key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = deepClone(obj[key]);\n }\n }\n \n return clone;\n}\n\n// Usage:\nconst original = { a: 1, b: { c: 2 }, d: [1, 2, 3] };\nconst cloned = deepClone(original);\nconsole.log(cloned); // Output: { a: 1, b: { c: 2 }, d: [1, 2, 3] }\n"
},
{
"title": "Filter Object",
"description": "Filter out entries in an object where the value is falsy, including empty strings, empty objects, null, and undefined.",
Expand Down Expand Up @@ -709,6 +753,18 @@
"contributors": [],
"code": "function getInitials(name) {\n return name.split(' ').map(part => part.charAt(0).toUpperCase()).join('');\n}\n\n// Usage:\ngetInitials('John Doe'); // Returns: 'JD'\n"
},
{
"title": "Generate UUID",
"description": "Generates a UUID (v4) string.",
"author": "jjcantu",
"tags": [
"javascript",
"uuid",
"utility"
],
"contributors": [],
"code": "function generateUUID() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n const r = Math.random() * 16 | 0;\n const v = c === 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n}\n\n// Usage:\nconsole.log(generateUUID()); // Output: \"a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5\"\n"
},
{
"title": "Mask Sensitive Information",
"description": "Masks parts of a sensitive string, like a credit card or email address.",
Expand Down
29 changes: 29 additions & 0 deletions snippets/cpp/debuging/vector-print.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
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
---

```cpp
#include <iostream>
#include <vector>

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i]; // Print each vector element
if (i != vec.size() - 1) {
os << ", "; // Add separator
}
}
os << "]";
return os; // Return the stream
}

// Usage:
std::vector<int> numbers = {1, 2, 3, 4, 5};
std::cout << numbers << std::endl; // Outputs: [1, 2, 3, 4, 5]

```
21 changes: 21 additions & 0 deletions snippets/javascript/color-manipulation/rgb-to-hex-color.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: RGB to Hex Color
description: Converts RGB color values to hexadecimal color code.
author: jjcantu
tags: color,conversion
---

```js
function rgbToHex(r, g, b) {
const toHex = (n) => {
const hex = n.toString(16);
return hex.length === 1 ? '0' + hex : hex;
};

return '#' + toHex(r) + toHex(g) + toHex(b);
}

// Usage:
console.log(rgbToHex(255, 128, 0)); // Output: "#ff8000"
console.log(rgbToHex(0, 255, 0)); // Output: "#00ff00"
```
22 changes: 22 additions & 0 deletions snippets/javascript/number-formatting/format-file-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Format File Size
description: Converts bytes into human-readable file size format.
author: jjcantu
tags: format,size
---

```js
function formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';

const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));

return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}

// Usage:
console.log(formatFileSize(1234)); // Output: "1.21 KB"
console.log(formatFileSize(1234567)); // Output: "1.18 MB"
```
27 changes: 27 additions & 0 deletions snippets/javascript/object-manipulation/deep-clone-object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Deep Clone Object
description: Creates a deep copy of an object or array without reference.
author: jjcantu
tags: object,clone
---

```js
function deepClone(obj) {
if (obj === null || typeof obj !== 'object') return obj;

const clone = Array.isArray(obj) ? [] : {};

for (let key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
clone[key] = deepClone(obj[key]);
}
}

return clone;
}

// Usage:
const original = { a: 1, b: { c: 2 }, d: [1, 2, 3] };
const cloned = deepClone(original);
console.log(cloned); // Output: 'original' but cloned
```
Loading

0 comments on commit 1dd6a8f

Please sign in to comment.