Skip to content

Instantly share code, notes, and snippets.

View BenRogersWPG's full-sized avatar
🇨🇦

Ben Rogers BenRogersWPG

🇨🇦
View GitHub Profile
@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"
}
@BenRogersWPG
BenRogersWPG / Slugfinder.py
Created November 14, 2021 18:11
Find URL Slug
def slugFinder(urlString):
slashSplit = urlString.split('/')
if len(slashSplit[-1]) < 1:
# If the trailing slash exists, just return the item before that, as the trailing slash contains 0 characters after it
if len(slashSplit[3]) == 0:
return '/'
else:
return slashSplit[-2]
else:
@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: