Skip to content

Instantly share code, notes, and snippets.

View nick3499's full-sized avatar
🏠
Working from home

nick3499 nick3499

🏠
Working from home
  • USA
View GitHub Profile
@nick3499
nick3499 / word_count.py
Created July 14, 2023 00:21
Word Counter: os.listdir()
#!/bin/python3
'''Count word total in text file.'''
from os import listdir
print(listdir()) # optional
inp = input('Enter filename: ')
with open(inp) as file:
text = file.read()
@nick3499
nick3499 / gen_hex_patt.py
Created July 14, 2023 00:04
Generate Hexadecimal Pattern: random.randrange()
#!/bin/python3
'''
generate password based on hex pattern
93b44021-a479-5fc2-4037-08b690031c73
xxxx-xx-xx-xx-xxxxxx
'''
from random import randrange
patt = [4, 2, 2, 2, 6]
hex_sets = []
@nick3499
nick3499 / launcher-gen.sh
Created July 13, 2023 23:46
Desktop Launcher
#!/bin/sh
# Create Chromium URL-as-app launcher given name of video and URL
# Example:
# $ sh launcher-gen.sh 'Dark Drum and Bass - VOL 2' https://www.youtube.com/watch?v=55kZd_JDrfI
NAME="$1"
URL=$2
echo '[Desktop Entry]\nVersion=1.0\nType=Application' > /home/$USER/Desktop/$NAME.desktop
echo "Name=$NAME" >> /home/$USER/Desktop/$NAME.desktop
@nick3499
nick3499 / countdown.py
Created July 13, 2023 23:32
Countdown Timer: time.sleep(), sys.argv()
#!/bin/python3
'''Countdown Timer
`$ python3 countdown.py 15` <-- 15 min timer example'''
from time import sleep
from sys import argv
tot_secs = int(argv[1]) * 60 # convert minute(s) string
def countdown(tot_secs):
@nick3499
nick3499 / app.py
Created July 13, 2023 23:25
IPGeolocation’s Astronomy API: json.loads(), requests.get(), pendulum.parse(), pendulum.parsing.ParserError()
#!/bin/python3
'''Get data from IPGeolocation’s Astronomy API.'''
from json import loads
from requests import get
from pendulum import parse
from pendulum.parsing import ParserError
API_KEY: str = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
LATITUDE: str = '00.000000'
LONGITUDE: str = '-00.000000'
@nick3499
nick3499 / app.py
Created March 20, 2023 22:13
Web scraper which scrapes embed/ link; requests.get; BeautifulSoup; subprocess.run
#!/bin/python3
'''Scrape embed link from white hat Web page.'''
from requests import get
from subprocess import run
from bs4 import BeautifulSoup
# color codes
orng = '\x1b[33m'
rset = '\x1b[0m'
@nick3499
nick3499 / prime_factorization.py
Created May 17, 2022 04:42
Prime Factorization
p = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
n = 7775460
l = []
n1 = 0
while n not in p:
if n % 2 == 0:
n = n // 2
l.append(2)
else:
@nick3499
nick3499 / vowel_encoding.py
Last active May 10, 2022 00:05
Vowel Encoding: Python 3: 'vowel encoding' changes vowels to numbers in order to obfuscate context
#!/bin/python3
'''Use encoding to disguise message by converting vowels to numbers.'''
# Permission granted under “The MIT License” (open source)
def encode(s: str) -> str:
enc = { 'a': '1', 'e': '2', 'i': '3', 'o': '4', 'u': '5' }
return ''.join(enc[x] if x in enc else x for x in s)
@nick3499
nick3499 / README.md
Last active April 29, 2022 23:43
Display weather data from Timeline API in terminal emulator; Python 3; json, pendulum.parse

README

Import Module Methods

from json import loads
from pendulum import parse
from requests import get
from os import environ
@nick3499
nick3499 / web_safe_color_table.py
Created February 9, 2022 07:04
Print Web-safe Color Table: Python3
#!/bin/python3
'''Print Web-safe color table.'''
def print_table():
'''Print table.'''
ws_rgb = ['0', '51', '102', '153', '255']
print('\x1b[31m Web-safe Color Table\x1b[0m')