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

[Snippets-C++] Added two snippets from #209 #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
majvax merged 24 commits into quicksnip-dev:main from majvax:snippets-c++
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e93bcac
[C++] added snippet
majvax Jan 1, 2025
2a6b1e2
Merge remote-tracking branch 'origin/snippets-c++' into snippets-c++
majvax Jan 1, 2025
aad3f79
[C++] added 3 snippets for string.
majvax Jan 1, 2025
f472a29
Added missing chrono header
majvax Jan 2, 2025
31b43b5
fixed tags
majvax Jan 2, 2025
29112d8
Merge remote-tracking branch 'origin/snippets-c++' into snippets-c++
majvax Jan 2, 2025
4638879
fixed exemple needing std=c++20
majvax Jan 2, 2025
98ddffc
Fixed Usage to accommodate to new guidelines
majvax Jan 2, 2025
aebefde
Fixed all tags + type
majvax Jan 3, 2025
d76dbfd
Revert "Fixed all tags + type"
majvax Jan 3, 2025
c188670
Merge remote-tracking branch 'upstream/main' into snippets-c++
majvax Jan 3, 2025
9364abb
Fixed type and all tags
majvax Jan 3, 2025
3a99176
fixed gh check failing
majvax Jan 3, 2025
c0d6f04
Update consolidated snippets
actions-user Jan 3, 2025
1dd6a8f
Merge branch 'dostonnabotov:main' into snippets-c++
majvax Jan 3, 2025
fce087f
Update consolidated snippets
actions-user Jan 3, 2025
a959e95
Update consolidated snippets
actions-user Jan 3, 2025
4708bd9
Merge remote-tracking branch 'origin/main' into snippets-c++
majvax Jan 4, 2025
112302e
Revert "Merge remote-tracking branch 'origin/main' into snippets-c++"
majvax Jan 6, 2025
60496ec
Merge remote-tracking branch 'origin/main' into snippets-c++
majvax Jan 6, 2025
812842f
Update consolidated snippets
actions-user Jan 6, 2025
1fbaec8
Merge remote-tracking branch 'origin/main' into snippets-c++
majvax Jan 10, 2025
7c0ca05
added two snippets from #209
majvax Jan 10, 2025
da7b75c
resolve check not passing
majvax Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update consolidated snippets
  • Loading branch information
actions-user committed Jan 3, 2025
commit a959e9503bef55728a97282c68aefb0fa0f3681b
17 changes: 17 additions & 0 deletions public/consolidated/cpp.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@
}
]
},
{
"categoryName": "Debuging",
"snippets": [
{
"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"
],
"contributors": [],
"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"
}
]
},
{
"categoryName": "File Handling",
"snippets": [
Expand Down
18 changes: 6 additions & 12 deletions public/consolidated/javascript.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@
"description": "Converts RGB color values to hexadecimal color code.",
"author": "jjcantu",
"tags": [
"javascript",
"color",
"conversion",
"utility"
"conversion"
],
"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"
Expand Down Expand Up @@ -407,10 +405,8 @@
"description": "Converts bytes into human-readable file size format.",
"author": "jjcantu",
"tags": [
"javascript",
"format",
"size",
"utility"
"size"
],
"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"
Expand Down Expand Up @@ -506,13 +502,11 @@
"description": "Creates a deep copy of an object or array without reference.",
"author": "jjcantu",
"tags": [
"javascript",
"object",
"clone",
"utility"
"clone"
],
"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"
"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: 'original' but cloned\n"
},
{
"title": "Filter Object",
Expand Down Expand Up @@ -758,9 +752,9 @@
"description": "Generates a UUID (v4) string.",
"author": "jjcantu",
"tags": [
"javascript",
"uuid",
"utility"
"generate",
"string"
],
"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"
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /