-
-
Notifications
You must be signed in to change notification settings - Fork 128
Add JavaScript snippets #51
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
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
151c71d
Add more JS snippets
Axorax fdb59e1
Merge branch 'dostonnabotov:main' into main
Axorax 013edbe
Add more snippets for JS and PY
Axorax f2f81d6
Add Java
Axorax 801f4e7
Merge branch 'dostonnabotov:main' into main
Axorax 5b332a0
remove java
Axorax 9332601
Add JavaScript snippets
Axorax e21abf0
Merge branch 'dostonnabotov:main' into main
Axorax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,9 @@ | |
{ | ||
"lang": "Rust", | ||
"icon": "/icons/rust.svg" | ||
}, | ||
{ | ||
"lang": "Java", | ||
"icon": "/icons/java.svg" | ||
} | ||
] |
129 changes: 129 additions & 0 deletions
public/data/java.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
[ | ||
{ | ||
"categoryName": "Basics", | ||
"snippets": [ | ||
{ | ||
"title": "Hello, World!", | ||
"description": "Prints Hello, World! to the terminal.", | ||
"code": [ | ||
"public class HelloWorld {", | ||
" public static void main(String[] args) {", | ||
" // Output: \"Hello, World!\"", | ||
" System.out.println(\"Hello, World!\");", | ||
" }", | ||
"}" | ||
], | ||
"tags": ["java", "hello-world"], | ||
"author": "axorax" | ||
} | ||
] | ||
}, | ||
{ | ||
"categoryName": "String Manipulation", | ||
"snippets": [ | ||
{ | ||
"title": "Reverse String", | ||
"description": "Reverses the characters in a string.", | ||
"code": [ | ||
"public class StringManipulation {", | ||
" public static String reverseString(String s) {", | ||
" StringBuilder reversed = new StringBuilder(s);", | ||
" return reversed.reverse().toString();", | ||
" }", | ||
"", | ||
" // Usage:", | ||
" public static void main(String[] args) {", | ||
" System.out.println(reverseString('hello')); // Output: 'olleh'", | ||
" }", | ||
"}" | ||
], | ||
"tags": ["java", "string", "reverse", "utility"], | ||
"author": "axorax" | ||
}, | ||
{ | ||
"title": "Check Palindrome", | ||
"description": "Checks if a string is a palindrome.", | ||
"code": [ | ||
"public class StringManipulation {", | ||
" public static boolean isPalindrome(String s) {", | ||
" String cleanString = s.replaceAll(\"\\s+\", \"\").toLowerCase();", | ||
" StringBuilder reversed = new StringBuilder(cleanString);", | ||
" return cleanString.equals(reversed.reverse().toString());", | ||
" }", | ||
"", | ||
" // Usage:", | ||
" public static void main(String[] args) {", | ||
" System.out.println(isPalindrome('A man a plan a canal Panama')); // Output: true", | ||
" }", | ||
"}" | ||
], | ||
"tags": ["java", "string", "palindrome", "check"], | ||
"author": "axorax" | ||
}, | ||
{ | ||
"title": "Count Vowels", | ||
"description": "Counts the number of vowels in a string.", | ||
"code": [ | ||
"public class StringManipulation {", | ||
" public static int countVowels(String s) {", | ||
" int count = 0;", | ||
" String vowels = 'aeiouAEIOU';", | ||
Axorax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
" for (int i = 0; i < s.length(); i++) {", | ||
" if (vowels.indexOf(s.charAt(i)) != -1) {", | ||
" count++;", | ||
" }", | ||
" }", | ||
" return count;", | ||
" }", | ||
"", | ||
" // Usage:", | ||
" public static void main(String[] args) {", | ||
" System.out.println(countVowels('hello')); // Output: 2", | ||
" }", | ||
"}" | ||
], | ||
"tags": ["java", "string", "vowels", "count"], | ||
"author": "axorax" | ||
}, | ||
{ | ||
"title": "Find Substring First Occurrence", | ||
"description": "Finds the first occurrence of a substring in a string.", | ||
"code": [ | ||
"public class StringManipulation {", | ||
" public static int findSubstring(String s, String substring) {", | ||
" return s.indexOf(substring);", | ||
" }", | ||
"", | ||
" // Usage:", | ||
" public static void main(String[] args) {", | ||
" System.out.println(findSubstring('hello world', 'world')); // Output: 6", | ||
" }", | ||
"}" | ||
], | ||
"tags": ["java", "string", "substring", "search"], | ||
"author": "axorax" | ||
}, | ||
{ | ||
"title": "Capitalize First Letter", | ||
"description": "Capitalizes the first letter of a string.", | ||
"code": [ | ||
"public class StringManipulation {", | ||
" public static String capitalizeFirstLetter(String s) {", | ||
" if (s == null || s.isEmpty()) {", | ||
" return s;", | ||
" }", | ||
" return s.substring(0, 1).toUpperCase() + s.substring(1);", | ||
" }", | ||
"", | ||
" // Usage:", | ||
" public static void main(String[] args) {", | ||
" System.out.println(capitalizeFirstLetter('hello')); // Output: 'Hello'", | ||
" }", | ||
"}" | ||
], | ||
"tags": ["java", "string", "capitalize", "utility"], | ||
"author": "axorax" | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.