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
""" | |
multiprocesscallback.py, by Peter Sobot (psobot.com), May 13, 2012 | |
Handles callback functions in classes that have member functions that | |
are executed in a different process. A crazy experiment in Python | |
magic that breaks a lot of rules. | |
Do not use in production, for any reason. (Although I do.) | |
If your class takes in a callback, like so: |
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
""" | |
1. Record an Off-Beat Jazz rehearsal session with an Sony A7C camera | |
2. Plug in an SD card to your Mac | |
3. Run this script, which will automatically segment the rehearsal session and render | |
to lower-quality, shareable, Google Drive-able H265-encoded video files | |
4. Upload to Google Drive | |
5. Get better at playing Jazz | |
Requirements: | |
python3 -m pip install tqdm ffmpeg-python numpy ffmpeg matplotlib |
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
""" | |
Kurzweil K2500/K2600 KOS operating system update file packer/repacker | |
by Peter Sobot, Nov 6, 2021 | |
@psobot / github@petersobot.com | |
Requirements: none! Pure Python. Just use Python 3.2+. | |
""" | |
import os | |
import math |
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 | |
import time | |
import atomac | |
import subprocess | |
if len(sys.argv) < 2: | |
print "Usage: bouncer.py <path_to_logic_project> (<path_to_logic_project>)" | |
os.exit(1) |
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
from Queue import Queue | |
import subprocess | |
import threading | |
import traceback | |
import logging | |
import time | |
log = logging.getLogger(__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
import sys | |
import re | |
output = sys.stdin.readlines() | |
r = re.compile(r'write\(2, "(.+?)", \d+\)\s+= \d+') | |
print "".join([x.replace(r'\n', "\n").replace(r'\t', "\t") for x in sum([r.findall(o) for o in output], [])]) |
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 inspect | |
from typing import Tuple, Any | |
def search_stack_for_variable(variable_name: str, frame=None) -> Tuple[str, Any]: | |
if frame is None: | |
frame = inspect.currentframe() | |
if variable_name not in frame.f_locals: | |
if frame.f_back is None: | |
raise ValueError(f"No variable named \"{variable_name}\" found in callstack.") |
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 atexit | |
import ctypes | |
import inspect | |
import threading | |
""" | |
Any instances of TerminatableThread that are running when the program exits | |
(due to normal interpreter shutdown, KeyboardInterrupt, SystemExit, etc.) | |
will have SystemExit raised within their next 100 Python bytecode executions, | |
allowing them to possibly catch the SystemExit and clean up as necessary. |
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
""" | |
Super hacky script to parse compiled Protobuf definitions out of one or more binary files. | |
Very useful if, say, you want to pull the internal data structures out of a compiled App Store app. | |
Requires `pip install 'protobuf>=3.20.0rc1'`. | |
Example usage: | |
python3 protodump.py /Applications/SomeAppBundle.app ./proto_files_go_here/ | |
(c) Peter Sobot (@psobot), March 13, 2022 |
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
{ | |
"+1": [[63.004759, -99.392855], "Canada"], | |
"+1242": [[26.215829, -98.187851], "Bahamas"], | |
"+1246": [[13.186666, -59.55727], "Barbados"], | |
"+1264": [[18.217056, -63.050923], "Anguilla"], | |
"+1268": [[17.08682, -61.796431], "Antigua and Barbuda"], | |
"+1284": [[18.719042, -64.326495], "British Virgin Islands"], | |
"+1340": [[33.282206, -117.185162], "US Virgin Islands"], | |
"+1345": [[19.323764, -81.195721], "Cayman Islands"], | |
"+1441": [[32.301277, -64.77506], "Bermuda"], |
NewerOlder