Skip to content

Instantly share code, notes, and snippets.

View 16BitS3G4l's full-sized avatar

Yehoshua Segal 16BitS3G4l

  • Brooklyn, New York
View GitHub Profile
@16BitS3G4l
16BitS3G4l / decode_username.py
Last active August 9, 2023 18:21
Decode Username
import math
# note: this can easily be implemented using conditions, but I like leveraging math for it instead
# map input to 1 (when a = x), other values (a != x) to 0; domain is ASCII table values (0-255)
# 0.0001 should be an arbitrarily small number approaching 0 to prevent dividing by zero error when x=a
def f(x, a):
return math.floor(1 - ( abs(x-a)/(abs(x-a) + 0.0001) ))
def decode(character):
@16BitS3G4l
16BitS3G4l / clone.sh
Last active November 17, 2020 16:26
Bash script to download all of a user's repositories (public only, unless password is cached)
#!/bin/bash
USER="your-username"
curl -s https://api.github.com/users/$USER/repos | grep "https://github.com/[a-zA-Z0-9-]*/[a-zA-Z0-9-]*.git" -o | xargs -n1 git clone
@16BitS3G4l
16BitS3G4l / progress_cli.py
Last active April 5, 2021 12:59
Progress class that allows you to track progress (Python 3+), and maintain a visual and programmatic structure that represents real time progression of a process (not in the conventional sense - any process that you designate, like a for loop, or a function, etc)
import time, threading, logging
class Progress_Bar:
"""
Maintain an easily identifiable progress bar(live updates to the CLI), along with important progress information all encapsulated in one object.
"""
logger = logging.getLogger("progress_logger")
logger.setLevel(logging.DEBUG)
logging.basicConfig(filename="app.log", filemode="w", format="%(asctime)s %(levelname)s:%(funcName)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")