Skip to content

Miner miner mods refactor 1 #2

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 4 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 23 additions & 20 deletions public/consolidated/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,17 @@
"code": "def snake_to_camel(s):\n parts = s.split('_')\n return parts[0] + ''.join(word.capitalize() for word in parts[1:])\n\n# Usage:\nsnake_to_camel('hello_world') # Returns: 'helloWorld'\n"
},
{
"title": "Convert String to ASCII",
"description": "Converts a string into its ASCII representation.",
"title": "Convert String to Unicode",
"description": "Converts a string into its Unicode representation.",
"author": "axorax",
"tags": [
"string",
"ascii",
"unicode",
"convert"
],
"contributors": [],
"code": "def string_to_ascii(s):\n return [ord(char) for char in s]\n\n# Usage:\nstring_to_ascii('hello') # Returns: [104, 101, 108, 108, 111]\n"
"code": "def string_to_unicode(s):\n return [ord(char) for char in s]\n\n# Usage:\nstring_to_unicode('hello') # Returns: [104, 101, 108, 108, 111]\n"
},
{
"title": "Count Character Frequency",
Expand Down Expand Up @@ -626,6 +627,18 @@
"contributors": [],
"code": "import random\nimport string\n\ndef random_string(length):\n letters_and_digits = string.ascii_letters + string.digits\n return ''.join(random.choice(letters_and_digits) for _ in range(length))\n\n# Usage:\nrandom_string(10) # Results: Random 10-character string\n"
},
{
"title": "Remove Characters",
"description": "Removes specific characters from a string.",
"author": "axorax",
"tags": [
"string",
"remove",
"characters"
],
"contributors": [],
"code": "def remove_chars(s, chars):\n return ''.join(c for c in s if c not in chars)\n\n# Usage:\nremove_chars('hello world', 'eo') # Returns: 'hll wrld'\n"
},
{
"title": "Remove Duplicate Characters",
"description": "Removes duplicate characters from a string while maintaining the order.",
Expand All @@ -650,18 +663,6 @@
"contributors": [],
"code": "import string\n\ndef remove_punctuation(s):\n return s.translate(str.maketrans('', '', string.punctuation))\n\n# Usage:\nremove_punctuation('Hello, World!') # Returns: 'Hello World'\n"
},
{
"title": "Remove Specific Characters",
"description": "Removes specific characters from a string.",
"author": "axorax",
"tags": [
"string",
"remove",
"characters"
],
"contributors": [],
"code": "def remove_chars(s, chars):\n return ''.join(c for c in s if c not in chars)\n\n# Usage:\nremove_chars('hello world', 'eo') # Returns: 'hll wrld'\n"
},
{
"title": "Remove Whitespace",
"description": "Removes all whitespace from a string.",
Expand All @@ -683,7 +684,7 @@
"reverse"
],
"contributors": [],
"code": "def reverse_string(s):\n return s[::-1]\n\n# Usage:\nreverse_string('hello') # Returns: 'olleh'\n"
"code": "def reverse_string(s:str) -> str:\n return s[::-1]\n\n# Usage:\nreverse_string('hello') # Returns: 'olleh'\n"
},
{
"title": "Split Camel Case",
Expand All @@ -698,15 +699,17 @@
"code": "import re\n\ndef split_camel_case(s):\n return ' '.join(re.findall(r'[A-Z][a-z]*|[a-z]+', s))\n\n# Usage:\nsplit_camel_case('camelCaseString') # Returns: 'camel Case String'\n"
},
{
"title": "Truncate String",
"description": "Truncates a string to a specified length and adds an ellipsis.",
"title": "Truncate",
"description": "Truncates a string to a specified length and a toggleable truncation notation.",
"author": "axorax",
"tags": [
"string",
"truncate"
],
"contributors": [],
"code": "def truncate_string(s, length):\n return s[:length] + '...' if len(s) > length else s\n\n# Usage:\ntruncate_string('This is a long string', 10) # Returns: 'This is a ...'\n"
"contributors": [
"MinerMinerMods"
],
"code": "def truncate(s:str, length:int, suffix:bool = True) -> str :\n return (s[:length] + (\"...\" if suffix else \"\")) if len(s) > length else s\n\n# Usage:\ntruncate('This is a long string', 10) # Returns: 'This is a ...'\ntruncate('This is a long string', 10, False) # Returns: 'This is a '\n"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion snippets/python/string-manipulation/remove-characters.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Remove Specific Characters
title: Remove Characters
description: Removes specific characters from a string.
author: axorax
tags: string,remove,characters
Expand Down
2 changes: 1 addition & 1 deletion snippets/python/string-manipulation/truncate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Truncate String
title: Truncate
description: Truncates a string to a specified length and a toggleable truncation notation.
author: axorax
contributors: MinerMinerMods
Expand Down
Loading