diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index d01653a8..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -text eol=lf diff --git a/.gitignore b/.gitignore index 7622c90e..40b878db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -coverage -*.local -*.tsbuildinfo - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? - -# Consolidated snippets -public/consolidated -public/icons +node_modules/ \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 3b9f6bcf..e193cdc8 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,11 @@ -npm run snippets:check -npm run cspell +# TODO: Bring back tests +# npm run test-ci +# npm run cspell +npm run cspell:frontend +npm run format npm run lint -npm run test-ci -npm run build + +npm run build:backend + +# Run production consolidate script before commit +.husky/scripts/consolidateForProd.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0561809d..bef8b660 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,11 +13,11 @@ You can contribute in two main ways: ### How to report bugs -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. +If you spot a bug in the codebase or issues with the documentation, please open up a [GitHub issue](https://github.com/technoph1le/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. +If you are interested in proposing new features, please open up a new [GitHub discussion](https://github.com/technoph1le/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. @@ -118,7 +118,7 @@ Here’s an example for JavaScript: --- title: Format Date description: Formats a date in 'YYYY-MM-DD' format. -author: dostonnabotov +author: technoph1le tags: date,format --- @@ -274,6 +274,6 @@ It will update the snippets in the `/public` folder, making them available to th 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 a new [GitHub discussion](https://github.com/dostonnabotov/quicksnip/discussions). +If you have any questions or need help, feel free to open a new [GitHub discussion](https://github.com/technoph1le/quicksnip/discussions). Happy coding! 💻✨ diff --git a/LICENSE b/LICENSE index c25d9a45..eb6b14a0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Technophile +Copyright (c) 2025 Technophile Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d5337487..128dca4d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # QuickSnip -An open-source project that categorizes handy code snippets across various programming languages. Built with love and powered by an awesome community. 🚀 +QuickSnip is an open-source tool designed for developers who want to organize, search, and share code snippets across various programming languages. It provides a centralized platform for managing handy snippets. Built with love and powered by an awesome community. 🚀
(predicate))\n | std::ranges::to (predicate))\n | std::ranges::to Typerwriter Animation (predicate))\n | std::ranges::to (predicate))\n | std::ranges::to> zip(List list1, List list2) {\n // Create pairs by iterating through the indices of both lists\n return IntStream.range(0, Math.min(list1.size(), list2.size())) // Limit the range to the smaller list\n .mapToObj(i -> Arrays.asList(list1.get(i), list2.get(i))) // Pair elements from both lists at index i\n .collect(Collectors.toList()); // Collect the pairs into a List\n}\n\n// Usage:\nList
> zipped = zip(arr1, arr2);\n\nSystem.out.println(zipped); // Output: [[a, 1], [b, 2], [c, 3]]\n",
+ "extension": "java"
+ }
+ ]
+ },
+ {
+ "name": "Basics",
+ "snippets": [
+ {
+ "title": "Hello-World",
+ "description": "Prints Hello world in the console",
+ "author": "SarvariHarshitha",
+ "tags": [
+ "java",
+ "console",
+ "printing"
+ ],
+ "contributors": [],
+ "code": "// This is the main class of the Java program\npublic class Main {\n // The main method is the entry point of the program\n public static void main(String args[]) {\n // This statement prints \"Hello, World!\" to the console\n System.out.println(\"Hello, World!\");\n }\n}\n\n",
+ "extension": "java"
+ }
+ ]
+ },
+ {
+ "name": "Bit Manipulation",
+ "snippets": [
+ {
+ "title": "Bit Counting",
+ "description": "Counts the set bits in the binary representation of an integer",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "bits",
+ "bit-counting"
+ ],
+ "contributors": [],
+ "code": "public static int countBits(int number) {\n int bits = 0;\n \n while (number > 0) {\n bits += number & 1;\n number >>= 1;\n }\n\n return bits;\n}\n\n// Usage:\nint number = 5;\nSystem.out.println(countBits(5)); // 2 (101)\n",
+ "extension": "java"
+ },
+ {
+ "title": "Is Power Of Two",
+ "description": "Checks if a number is a power of two",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "bit",
+ "power-of-two"
+ ],
+ "contributors": [],
+ "code": "public static boolean isPowerOfTwo(int number) {\n return (number > 0) && ((number & (number - 1)) == 0);\n}\n\n// Usage:\nint number = 16;\nSystem.out.println(isPowerOfTwo(number)); // true (2^4)\n",
+ "extension": "java"
+ }
+ ]
+ },
+ {
+ "name": "Date Time",
+ "snippets": [
+ {
+ "title": "Date Time Formatting American",
+ "description": "Formats a timestamp to a human-readable date-time string in the format \"MM/dd/yyyy hh:mm:ss a\"",
+ "author": "Mcbencrafter",
+ "tags": [
+ "date",
+ "time",
+ "date-time",
+ "formatting",
+ "american"
+ ],
+ "contributors": [],
+ "code": "import java.time.Instant;\nimport java.time.ZoneId;\nimport java.time.format.DateTimeFormatter;\nimport java.util.concurrent.TimeUnit;\n\n// using the system default time zone\npublic static String formatDateTimeAmerican(long time, TimeUnit timeUnit) {\n return formatDateTimeAmerican(time, timeUnit, ZoneId.systemDefault());\n}\n\npublic static String formatDateTimeAmerican(long time, TimeUnit timeUnit, ZoneId timeZone) {\n return DateTimeFormatter.ofPattern(\"MM/dd/yyyy hh:mm:ss a\")\n .withZone(\n timeZone != null ? timeZone : ZoneId.systemDefault()\n )\n .format(Instant.ofEpochSecond(\n timeUnit.toSeconds(time)\n ));\n}\n\n// Usage:\nSystem.out.println(formatDateTimeAmerican(1735689599, TimeUnit.SECONDS)); // \"12/31/2024 | 11:59:59 PM\" for GMT+0000\nSystem.out.println(formatDateTimeAmerican(1735689599, TimeUnit.SECONDS, ZoneId.of(\"GMT+0000\"))); // \"12/31/2024 | 11:59:59 PM\"\n",
+ "extension": "java"
+ },
+ {
+ "title": "Date Time Formatting European",
+ "description": "Formats a timestamp to a human-readable date-time string in the format \"dd.MM.yyyy HH:mm:ss\"",
+ "author": "Mcbencrafter",
+ "tags": [
+ "date",
+ "time",
+ "date-time",
+ "formatting",
+ "european"
+ ],
+ "contributors": [],
+ "code": "import java.time.Instant;\nimport java.time.ZoneId;\nimport java.time.format.DateTimeFormatter;\nimport java.util.concurrent.TimeUnit;\n\n// using the system default time zone\npublic static String formatDateTimeEuropean(long time, TimeUnit timeUnit) {\n return formatDateTimeEuropean(time, timeUnit, ZoneId.systemDefault());\n}\n\npublic static String formatDateTimeEuropean(long time, TimeUnit timeUnit, ZoneId timeZone) {\n return DateTimeFormatter.ofPattern(\"dd.MM.yyyy HH:mm:ss\")\n .withZone(\n timeZone != null ? timeZone : ZoneId.systemDefault()\n )\n .format(Instant.ofEpochSecond(\n timeUnit.toSeconds(time)\n ));\n}\n\n// Usage:\nSystem.out.println(formatDateTimeEuropean(1735689599, TimeUnit.SECONDS)); // \"31.12.2024 | 23:59:59\" for GMT+0000\nSystem.out.println(formatDateTimeEuropean(1735689599, TimeUnit.SECONDS, ZoneId.of(\"GMT+0000\"))); // \"31.12.2024 | 23:59:59\"\n",
+ "extension": "java"
+ },
+ {
+ "title": "Duration Formatting Hours Minutes Seconds",
+ "description": "Converts a given time duration to a human-readable string in the format \"hh:mm(:ss)\"",
+ "author": "Mcbencrafter",
+ "tags": [
+ "time",
+ "formatting",
+ "hours",
+ "minutes",
+ "seconds"
+ ],
+ "contributors": [],
+ "code": "import java.util.concurrent.TimeUnit;\n \npublic static String formatDurationToHoursMinutesAndSeconds(int time, TimeUnit timeUnit, boolean showSeconds) {\n long totalSeconds = timeUnit.toSeconds(time);\n\n if (totalSeconds < 0)\n throw new IllegalArgumentException(\"Duration must be a non-negative value.\");\n\n // These variables can be directly used in the return statement,\n // but are kept as separate variables here for better readability.\n long hours = totalSeconds / 3600;\n long minutes = (totalSeconds % 3600) / 60;\n long seconds = totalSeconds % 60;\n\n if (showSeconds) {\n return String.format(\"%02d:%02d:%02d\", hours, minutes, seconds);\n } else {\n return String.format(\"%02d:%02d\", hours, minutes);\n }\n}\n\n// Usage:\nSystem.out.println(formatDurationToHoursMinutesAndSeconds(3810, TimeUnit.SECONDS, true)); // \"01:03:30\"\nSystem.out.println(formatDurationToHoursMinutesAndSeconds(3810, TimeUnit.SECONDS, false)); // \"01:03\"\n",
+ "extension": "java"
+ },
+ {
+ "title": "Duration Formatting Minutes Seconds",
+ "description": "Converts a given time duration to a human-readable string in the format \"mm:ss\"",
+ "author": "Mcbencrafter",
+ "tags": [
+ "time",
+ "formatting",
+ "minutes",
+ "seconds"
+ ],
+ "contributors": [],
+ "code": "import java.util.concurrent.TimeUnit;\n\npublic static String formatDurationToMinutesAndSeconds(int time, TimeUnit timeUnit) {\n long totalSeconds = timeUnit.toSeconds(time);\n\n if (totalSeconds < 0)\n throw new IllegalArgumentException(\"Duration must be a non-negative value.\");\n\n // These variables can be directly used in the return statement,\n // but are kept here as separate variables for better readability.\n long minutes = totalSeconds / 60;\n long seconds = totalSeconds % 60;\n\n return String.format(\"%02d:%02d\", minutes, seconds);\n}\n\n// Usage:\nSystem.out.println(formatDurationToMinutesAndSeconds(120, TimeUnit.SECONDS)); // \"02:00\"\nSystem.out.println(formatDurationToMinutesAndSeconds(75, TimeUnit.SECONDS)); // \"01:15\"\n",
+ "extension": "java"
+ }
+ ]
+ },
+ {
+ "name": "Math",
+ "snippets": [
+ {
+ "title": "Checksum",
+ "description": "Calculates the checksum of an int",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "checksum"
+ ],
+ "contributors": [],
+ "code": "public static int checksum(int number) {\n number = Math.abs(number);\n int sum = 0;\n\n while (number != 0) {\n sum += number % 10;\n number /= 10;\n }\n\n return sum;\n}\n\n// Usage:\nint number = 12345;\nSystem.out.println(checksum(number)); // 15 = 1+2+3+4+5\n",
+ "extension": "java"
+ },
+ {
+ "title": "Factorial",
+ "description": "Computes the factorial of a given number",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "factorial"
+ ],
+ "contributors": [],
+ "code": "import java.math.BigInteger;\n\npublic static BigInteger factorial(int number) {\n BigInteger result = BigInteger.ONE;\n\n for (int currentNumber = 1; currentNumber <= number; currentNumber++) {\n result = result.multiply(BigInteger.valueOf(currentNumber));\n }\n\n return result;\n}\n\n// Usage:\nint number = 6;\nSystem.out.println(factorial(number)); // 720 = 6*5*4*3*2\n",
+ "extension": "java"
+ },
+ {
+ "title": "Fibonacci",
+ "description": "Calculates the nth fibonacci number",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "fibonacci"
+ ],
+ "contributors": [],
+ "code": "public static int fibonacci(int number) {\n if (number <= 1) \n return number;\n \n return fibonacci(number - 1) + fibonacci(number - 2);\n}\n\n// Usage:\nint number = 5;\nSystem.out.println(fibonacci(number)) // 3 (0, 1, 1, 2, 3)\n",
+ "extension": "java"
+ },
+ {
+ "title": "Greatest Common Divisor",
+ "description": "Calculates the greatest common divisor (gcd) of two numbers",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "greatest-common-devisor",
+ "gcd",
+ "euclidean-algorithm"
+ ],
+ "contributors": [],
+ "code": "public static int gcd(int number1, int number2) {\n while (number2 != 0) {\n int remainder = number2;\n number2 = number1 % number2;\n number1 = remainder;\n }\n\n return number1;\n}\n\n// Usage:\nint a = 16;\nint b = 12;\nSystem.out.println(gcd(a, b)); // 4\n",
+ "extension": "java"
+ },
+ {
+ "title": "Least Common Multiple",
+ "description": "Calculates the least common multiple (lcm) of two numbers",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "least-common-multiple",
+ "lcm",
+ "euclidean-algorithm"
+ ],
+ "contributors": [],
+ "code": "public static int lcm(int number1, int number2) {\n int gcdNumber1 = number1;\n int gcdNumber2 = number2;\n \n while (gcdNumber2 != 0) {\n int remainder = gcdNumber2;\n gcdNumber2 = gcdNumber1 % gcdNumber2;\n gcdNumber1 = remainder;\n }\n \n return (number1 / gcdNumber1) * number2;\n}\n\n// Usage:\nint a = 16;\nint b = 12;\nSystem.out.println(lcm(a, b)); // 48\n",
+ "extension": "java"
+ },
+ {
+ "title": "Prime Check",
+ "description": "Checks if a number is a prime",
+ "author": "Mcbencrafter",
+ "tags": [
+ "math",
+ "number",
+ "prime"
+ ],
+ "contributors": [],
+ "code": "public static boolean isPrime(int number) {\n if (number <= 1) \n return false;\n\n if (number <= 3) \n return true;\n\n boolean prime = true;\n for (int divisor = 3; divisor < number; divisor++) {\n if (number % divisor != 0)\n continue;\n\n prime = false;\n break;\n }\n\n return prime;\n}\n\n// Usage:\nint number = 31;\nSystem.out.println(isPrime(number)); // true\n",
+ "extension": "java"
+ }
+ ]
+ },
+ {
+ "name": "String Manipulation",
+ "snippets": [
+ {
+ "title": "Ascii To String",
+ "description": "Converts a list of ascii numbers into a string",
+ "author": "Mcbencrafter",
+ "tags": [
+ "string",
+ "ascii",
+ "encoding",
+ "decode",
+ "conversion"
+ ],
+ "contributors": [],
+ "code": "import java.util.List;\n\npublic static String asciiToString(List
Hello, World!
\n