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 6381a89

Browse files
committed
small typo
1 parent bf49d9c commit 6381a89

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

‎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/cpp.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@
3232
}
3333
]
3434
},
35+
{
36+
"categoryName": "Debuging",
37+
"snippets": [
38+
{
39+
"title": "Vector Print",
40+
"description": "Overloads the << operator to print the contents of a vector just like in python.",
41+
"author": "Mohamed-faaris",
42+
"tags": [
43+
"printing",
44+
"debuging",
45+
"vector"
46+
],
47+
"contributors": [],
48+
"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"
49+
}
50+
]
51+
},
3552
{
3653
"categoryName": "Math And Numbers",
3754
"snippets": [

‎public/consolidated/javascript.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@
8585
"description": "Converts RGB color values to hexadecimal color code.",
8686
"author": "jjcantu",
8787
"tags": [
88-
"javascript",
8988
"color",
90-
"conversion",
91-
"utility"
89+
"conversion"
9290
],
9391
"contributors": [],
9492
"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"
@@ -407,10 +405,8 @@
407405
"description": "Converts bytes into human-readable file size format.",
408406
"author": "jjcantu",
409407
"tags": [
410-
"javascript",
411408
"format",
412-
"size",
413-
"utility"
409+
"size"
414410
],
415411
"contributors": [],
416412
"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"
@@ -506,13 +502,11 @@
506502
"description": "Creates a deep copy of an object or array without reference.",
507503
"author": "jjcantu",
508504
"tags": [
509-
"javascript",
510505
"object",
511-
"clone",
512-
"utility"
506+
"clone"
513507
],
514508
"contributors": [],
515-
"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"
509+
"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"
516510
},
517511
{
518512
"title": "Filter Object",
@@ -758,9 +752,9 @@
758752
"description": "Generates a UUID (v4) string.",
759753
"author": "jjcantu",
760754
"tags": [
761-
"javascript",
762755
"uuid",
763-
"utility"
756+
"generate",
757+
"string"
764758
],
765759
"contributors": [],
766760
"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"

0 commit comments

Comments
(0)

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