A set of scripts for an internal Pokemon game - here for archival only.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test() { | |
# strip test_ and .py from input | |
stripped=$(echo "$1" | sed "s/^test_//;s/\.py$//") | |
# declare empty array | |
test_matches=() | |
# pipe matches from find command into array | |
# exclude tests in venv dirs | |
while IFS= read -r -d $'\0'; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import sys | |
import shlex | |
import subprocess | |
REPO_DIR = os.environ.get("REPO_LOCATION", None) | |
MIGRATIONS_DIR = os.path.join(REPO_DIR, 'core', 'migrations') | |
MAX_MIGRATION = os.path.join(MIGRATIONS_DIR, 'max_migration.txt') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
REPO_DIR = os.environ.get("REPO_LOCATION", None) | |
MIGRATIONS_DIR = os.path.join(REPO_DIR, 'core', 'migrations') | |
MAX_MIGRATION = os.path.join(MIGRATIONS_DIR, 'max_migration.txt') | |
def get_migration_number(migration: str) -> str: | |
"""Return the number part of a migration name.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
; #Warn ; Enable warnings to assist with detecting common errors. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
#SingleInstance Force | |
WinWait, ahk_exe voicemeeterpro.exe ; wait for voicemeeter | |
DllLoad := DllCall("LoadLibrary", "Str", "C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv | |
#Warn | |
#SingleInstance Force | |
#InstallKeybdHook | |
#UseHook On | |
SendMode Input | |
Release() { | |
Send {w up} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://zapier.com/engineering/profiling-python-boss/ | |
# Requires https://pypi.org/project/line_profiler/ | |
def profile_func(follow=[]): | |
from line_profiler import LineProfiler | |
# simply decorate the function you want profiled | |
# add any functions called you want followed to [] | |
def inner(func): | |
def profiled_func(*args, **kwargs): | |
profiler = LineProfiler() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_775_dir(dir_fp: str): | |
original_umask = os.umask(0) | |
try: | |
os.makedirs(dir_fp, mode=0o775, exist_ok=True) | |
except IOError: | |
# weird folder permission issues | |
pass | |
finally: | |
os.umask(original_umask) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from typing import List as L | |
def pdf_to_text(fp: str, strip: bool = True) -> L[str]: | |
proc = subprocess.Popen(['pdftotext', '-layout', fp, '-'], stdout=subprocess.PIPE) | |
raw_output = proc.communicate()[0].decode() | |
if strip: | |
res = [i.strip() for i in raw_output.split('\n') if i] | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Avoid 'D = decimal.Decimal' crud | |
from decimal import Decimal | |
from typing import Union as U | |
def decimalize(num: float, digits_str: str) -> Decimal: | |
return Decimal(num).quantize(Decimal(digits_str)) | |
NewerOlder