Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / constant_loader.py
Created May 25, 2017 20:49
Load arbitrary non-symbol Framework constants from macOS pyobjc .bridgesupport files in python
# This code leverages the pre-existing XML parser in objc but takes just the constant values
# without any deeper parsing of classes, structs, etc.
# Useful for when objc.loadBundleVariables as used here https://gist.github.com/pudquick/ac8f22326f095ed2690e
# is not possible because the constant isn't defined as a framework symbol, only in a header
# (which the System .bridgesupport files helpfully included entries for)
import objc
def constant_loader(framework_bridgesupport_path, target_dict, values = None):
@pudquick
pudquick / xcode_markdown.py
Last active September 5, 2020 04:16
Abuse Xcode's embedded CommonMark framework to generate HTML from markdown
# hax hax hax hax hax
import ctypes, os, sys
newstderr = os.dup(2) # This is to mute dyld LC_RPATH warnings
os.dup2(os.open('/dev/null', os.O_WRONLY), 2) # because we're loading Xcode frameworks from python
CM = ctypes.CDLL('/Applications/Xcode.app/Contents/SharedFrameworks/DVTMarkup.framework/Versions/A/Frameworks/CommonMark.framework/CommonMark')
sys.stderr = os.fdopen(newstderr, 'w') # This restores stderr
cmark_markdown_to_html = CM.cmark_markdown_to_html
cmark_markdown_to_html.restype = ctypes.c_char_p
#!/bin/sh
# Reload program and label definitions into a running x64sc session
# Send command to emulator's remote monitor
send () {
echo "$1" | nc -N localhost 6510 >/dev/null
}
# Verify command line parameters