Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
neoRandom authored Jan 7, 2025
2 parents 2b6dd3b + 34bd82f commit 592cc68
Show file tree
Hide file tree
Showing 82 changed files with 2,537 additions and 220 deletions.
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "lf",
"jsxSingleQuote": false
}
35 changes: 32 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"snippets:consolidate": "node ./utils/consolidateSnippets.js"
},
"dependencies": {
"framer-motion": "^11.15.0",
"motion": "^11.15.0",
"prismjs": "^1.29.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
70 changes: 46 additions & 24 deletions public/consolidated/_index.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,72 @@
[
{
"lang": "C",
"icon": "/icons/c.svg"
"name": "C",
"icon": "/icons/c.svg",
"subLanguages": []
},
{
"lang": "CPP",
"icon": "/icons/cpp.svg"
"name": "CPP",
"icon": "/icons/cpp.svg",
"subLanguages": []
},
{
"lang": "CSHARP",
"icon": "/icons/csharp.svg"
"name": "CSHARP",
"icon": "/icons/csharp.svg",
"subLanguages": []
},
{
"lang": "CSS",
"icon": "/icons/css.svg"
"name": "CSS",
"icon": "/icons/css.svg",
"subLanguages": []
},
{
"lang": "HASKELL",
"icon": "/icons/haskell.svg"
"name": "HASKELL",
"icon": "/icons/haskell.svg",
"subLanguages": []
},
{
"lang": "HTML",
"icon": "/icons/html.svg"
"name": "HTML",
"icon": "/icons/html.svg",
"subLanguages": []
},
{
"lang": "JAVA",
"icon": "/icons/java.svg"
"name": "JAVA",
"icon": "/icons/java.svg",
"subLanguages": []
},
{
"lang": "JAVASCRIPT",
"icon": "/icons/javascript.svg"
"name": "JAVASCRIPT",
"icon": "/icons/javascript.svg",
"subLanguages": []
},
{
"lang": "PYTHON",
"icon": "/icons/python.svg"
"name": "PYTHON",
"icon": "/icons/python.svg",
"subLanguages": []
},
{
"lang": "RUST",
"icon": "/icons/rust.svg"
"name": "REGEX",
"icon": "/icons/regex.svg",
"subLanguages": []
},
{
"lang": "SCSS",
"icon": "/icons/scss.svg"
"name": "RUBY",
"icon": "/icons/ruby.svg",
"subLanguages": []
},
{
"lang": "TYPESCRIPT",
"icon": "/icons/typescript.svg"
"name": "RUST",
"icon": "/icons/rust.svg",
"subLanguages": []
},
{
"name": "SCSS",
"icon": "/icons/scss.svg",
"subLanguages": []
},
{
"name": "TYPESCRIPT",
"icon": "/icons/typescript.svg",
"subLanguages": []
}
]
116 changes: 114 additions & 2 deletions public/consolidated/c.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"categoryName": "Basics",
"name": "Basics",
"snippets": [
{
"title": "Hello, World!",
Expand All @@ -16,7 +16,7 @@
]
},
{
"categoryName": "Mathematical Functions",
"name": "Mathematical Functions",
"snippets": [
{
"title": "Factorial Function",
Expand All @@ -28,6 +28,118 @@
],
"contributors": [],
"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"
},
{
"title": "Swap numbers",
"description": "Swaps two numbers without using third variable",
"author": "Emosans",
"tags": [
"swap",
"numbers"
],
"contributors": [],
"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); // swaps the values of the a and b variables\n"
}
]
},
{
"name": "Search",
"snippets": [
{
"title": "Binary Search ",
"description": "Searches for an element in a sorted array using the Binary Search algorithm.",
"author": "0xHouss",
"tags": [
"search",
"binarysearch",
"array",
"algorithm"
],
"contributors": [],
"code": "int binarySearch(int arr[], int low, int high, int x) {\n while (low <= high) {\n int mid = low + (high - low) / 2;\n\n // Check if x is present at mid\n if (arr[mid] == x) {\n return mid;\n }\n\n // If x is smaller, search the left half\n if (arr[mid] > x) {\n high = mid - 1;\n } else { // If x is larger, search the right half\n low = mid + 1;\n }\n }\n return -1; // Element not found\n}\n\n// Usage:\nint arr[] = {2, 3, 4, 10, 40};\nint n = sizeof(arr) / sizeof(arr[0]);\nint x = 10;\nint result = binarySearch(arr, 0, n - 1, x);\n// result = 3 (index of the element 10)\n\n\n"
},
{
"title": "Linear Search ",
"description": "Searches for an element in an array using the Linear Search algorithm.",
"author": "0xHouss",
"tags": [
"search",
"linearsearch",
"array",
"algorithm"
],
"contributors": [],
"code": "int linearSearch(int arr[], int n, int x) {\n for (int i = 0; i < n; i++) {\n if (arr[i] == x) {\n return i; // Element found at index i\n }\n }\n return -1; // Element not found\n}\n\n// Usage:\nint arr[] = {10, 20, 30, 40, 50};\nint n = sizeof(arr) / sizeof(arr[0]);\nint x = 30;\nint result = linearSearch(arr, n, x);\n// result = 2 (index of the element 30)\n\n"
}
]
},
{
"name": "Sorting",
"snippets": [
{
"title": "Bubble Sort ",
"description": "Sorts an array of integers using the Bubble Sort algorithm.",
"author": "0xHouss",
"tags": [
"sorting",
"bubblesort",
"array",
"algorithm"
],
"contributors": [],
"code": "void bubbleSort(int arr[], int n) {\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j < n - i - 1; j++) {\n if (arr[j] > arr[j + 1]) {\n // Swap arr[j] and arr[j + 1]\n int temp = arr[j];\n arr[j] = arr[j + 1];\n arr[j + 1] = temp;\n }\n }\n }\n}\n\n// Usage:\nint arr[] = {64, 34, 25, 12, 22, 11, 90};\nint n = sizeof(arr) / sizeof(arr[0]);\nbubbleSort(arr, n);\n// Now arr[] is sorted: {11, 12, 22, 25, 34, 64, 90}\n"
},
{
"title": "Insertion Sort ",
"description": "Sorts an array of integers using the Insertion Sort algorithm.",
"author": "0xHouss",
"tags": [
"sorting",
"insertionsort",
"array",
"algorithm"
],
"contributors": [],
"code": "void insertionSort(int arr[], int n) {\n for (int i = 1; i < n; i++) {\n int key = arr[i];\n int j = i - 1;\n\n // Move elements of arr[0..i-1] that are greater than key\n // to one position ahead of their current position\n while (j >= 0 && arr[j] > key) {\n arr[j + 1] = arr[j];\n j--;\n }\n arr[j + 1] = key;\n }\n}\n\n// Usage:\nint arr[] = {12, 11, 13, 5, 6};\nint n = sizeof(arr) / sizeof(arr[0]);\ninsertionSort(arr, n);\n// Now arr[] is sorted: {5, 6, 11, 12, 13}\n\n"
},
{
"title": "Merge Sort ",
"description": "Sorts an array of integers using the Merge Sort algorithm.",
"author": "0xHouss",
"tags": [
"sorting",
"mergesort",
"array",
"algorithm"
],
"contributors": [],
"code": "#include <stdio.h>\n\nvoid merge(int arr[], int l, int m, int r) {\n int n1 = m - l + 1;\n int n2 = r - m;\n\n // Temporary arrays\n int L[n1], R[n2];\n\n // Copy data to temporary arrays L[] and R[]\n for (int i = 0; i < n1; i++)\n L[i] = arr[l + i];\n for (int j = 0; j < n2; j++)\n R[j] = arr[m + 1 + j];\n\n int i = 0, j = 0, k = l;\n\n // Merge the temporary arrays back into arr[l..r]\n while (i < n1 && j < n2) {\n if (L[i] <= R[j]) {\n arr[k] = L[i];\n i++;\n } else {\n arr[k] = R[j];\n j++;\n }\n k++;\n }\n\n // Copy remaining elements of L[], if any\n while (i < n1) {\n arr[k] = L[i];\n i++;\n k++;\n }\n\n // Copy remaining elements of R[], if any\n while (j < n2) {\n arr[k] = R[j];\n j++;\n k++;\n }\n}\n\nvoid mergeSort(int arr[], int l, int r) {\n if (l < r) {\n int m = l + (r - l) / 2;\n\n // Sort first and second halves\n mergeSort(arr, l, m);\n mergeSort(arr, m + 1, r);\n\n merge(arr, l, m, r);\n }\n}\n\n// Usage:\nint arr[] = {38, 27, 43, 3, 9, 82, 10};\nint n = sizeof(arr) / sizeof(arr[0]);\nmergeSort(arr, 0, n - 1);\n// Now arr[] is sorted: {3, 9, 10, 27, 38, 43, 82}\n\n"
},
{
"title": "Quick Sort ",
"description": "Sorts an array of integers using the Quick Sort algorithm.",
"author": "0xHouss",
"tags": [
"sorting",
"quicksort",
"array",
"algorithm"
],
"contributors": [],
"code": "int partition(int arr[], int low, int high) {\n int pivot = arr[high]; // Pivot element\n int i = low - 1;\n\n for (int j = low; j < high; j++) {\n if (arr[j] < pivot) {\n i++;\n // Swap arr[i] and arr[j]\n int temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n }\n\n // Swap arr[i + 1] and arr[high] (pivot)\n int temp = arr[i + 1];\n arr[i + 1] = arr[high];\n arr[high] = temp;\n\n return i + 1;\n}\n\nvoid quickSort(int arr[], int low, int high) {\n if (low < high) {\n int pi = partition(arr, low, high);\n\n // Recursively sort elements before and after partition\n quickSort(arr, low, pi - 1);\n quickSort(arr, pi + 1, high);\n }\n}\n\n// Usage:\nint arr[] = {10, 7, 8, 9, 1, 5};\nint n = sizeof(arr) / sizeof(arr[0]);\nquickSort(arr, 0, n - 1);\n// Now arr[] is sorted: {1, 5, 7, 8, 9, 10}\n\n"
},
{
"title": "Selection Sort ",
"description": "Sorts an array of integers using the Selection Sort algorithm.",
"author": "0xHouss",
"tags": [
"sorting",
"selectionsort",
"array",
"algorithm"
],
"contributors": [],
"code": "void selectionSort(int arr[], int n) {\n for (int i = 0; i < n - 1; i++) {\n int minIdx = i;\n\n // Find the minimum element in the unsorted part of the array\n for (int j = i + 1; j < n; j++) {\n if (arr[j] < arr[minIdx]) {\n minIdx = j;\n }\n }\n\n // Swap the found minimum element with the first element of the unsorted part\n int temp = arr[minIdx];\n arr[minIdx] = arr[i];\n arr[i] = temp;\n }\n}\n\n// Usage:\nint arr[] = {64, 25, 12, 22, 11};\nint n = sizeof(arr) / sizeof(arr[0]);\nselectionSort(arr, n);\n// Now arr[] is sorted: {11, 12, 22, 25, 64}\n\n"
}
]
}
Expand Down
27 changes: 22 additions & 5 deletions public/consolidated/cpp.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"categoryName": "Basics",
"name": "Basics",
"snippets": [
{
"title": "Hello, World!",
Expand All @@ -16,7 +16,7 @@
]
},
{
"categoryName": "Data Structure Conversion",
"name": "Data Structure Conversion",
"snippets": [
{
"title": "Vector to Queue",
Expand All @@ -33,7 +33,7 @@
]
},
{
"categoryName": "Debuging",
"name": "Debugging",
"snippets": [
{
"title": "Vector Print",
Expand All @@ -50,7 +50,24 @@
]
},
{
"categoryName": "Math And Numbers",
"name": "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"
}
]
},
{
"name": "Math And Numbers",
"snippets": [
{
"title": "Check Prime Number",
Expand All @@ -66,7 +83,7 @@
]
},
{
"categoryName": "String Manipulation",
"name": "String Manipulation",
"snippets": [
{
"title": "Reverse String",
Expand Down
Loading

0 comments on commit 592cc68

Please sign in to comment.