Skip to content

Instantly share code, notes, and snippets.

View BenRogersWPG's full-sized avatar
👽

Ben Rogers BenRogersWPG

👽
View GitHub Profile
@BenRogersWPG
BenRogersWPG / Python-Print-Colors.py
Last active November 14, 2021 00:52
Colorful Python Print Statements
#Print a line to the console in red text:
print(f'\033[31mThis is red text\033[0m')
#Print a line to the console in green text:
print(f'\033[32mThis is green text\033[0m')
#Print a line to the console in yellow text:
print(f'\033[33mThis is yellow text\033[0m')
#Print a line to the console in blue text:
@BenRogersWPG
BenRogersWPG / Slugfinder.py
Last active October 14, 2024 22:15
Find URL Slug
def slugFinder(urlString):
"""
Finds and returns the slug from a given URL string.
A slug is typically the last segment of a URL after the last '/'.
This function handles the following cases:
- If the URL ends with a trailing slash, it returns the segment before the slash.
- If the URL does not end with a trailing slash, it returns the last segment.
- If the last segment is the top-level domain (TLD), it returns '/' to indicate the root.
@BenRogersWPG
BenRogersWPG / Python-Snippet-For-Items-Loop.json
Last active March 19, 2022 16:42
Python Snippet for VSCode to Populate a For Loop & Print Out Items
"For Items Loop": {
"prefix": "for items",
"body": [
"for items in ${TM_SELECTED_TEXT:$1}:",
" print(f'${TM_SELECTED_TEXT:$1} Item: {items}')"
],
"description": "For Items Loop"
}