Skip to content

Instantly share code, notes, and snippets.

View rpetrich's full-sized avatar
Out with time lord dragon

Ryan Petrich rpetrich

Out with time lord dragon
View GitHub Profile
@rpetrich
rpetrich / Rename .plt.sec stubs.py
Created June 6, 2022 12:13
Hopper Disassembler script to assign names to CET-enabled PLT stubs
doc = Document.getCurrentDocument()
for i in range(0, doc.getSegmentCount()):
segment = doc.getSegment(i)
for j in range(0, segment.getSectionCount()):
section = segment.getSection(j)
if section.getName() == ".plt.sec":
address = section.getStartingAddress()
length = section.getLength()
off = 0
@rpetrich
rpetrich / spinner.sh
Created March 24, 2019 22:08
Moon loading spinner
#!/bin/bash
while :; do
for c in 🌕 🌖 🌗 🌘 🌑 🌑 🌑 🌒 🌓 🌔 🌕 🌕; do
echo -en "\r" "$c"
sleep 0.1
done
done
@rpetrich
rpetrich / kubeselect
Created February 23, 2019 19:02
Simple kube config selector
#!/bin/bash
mkdir -p ~/.kube/
if [ -z "$1" ]; then
CURRENT=$(readlink ~/.kube/config | cut -d - -f 2-)
ls ~/Dropbox/kube* | cut -d - -f 2- | sed "s/$CURRENT\$/$CURRENT (current)/"
else
[[ -L ~/.kube/config ]] && rm ~/.kube/config
ln -s "$HOME/Dropbox/kubeconfig-$1" ~/.kube/config
rm -rf ~/.kube/cache ~/.kube/http-cache
fi
@rpetrich
rpetrich / Import Symbols.py
Created February 14, 2019 16:39
Hopper script to import symbols that were later stripped (for example, from Symbol.map on linux kernels)
doc = Document.getCurrentDocument()
path = Document.askFile("Symbols file", None, False)
if path != None:
with open(path) as fp:
for i, line in enumerate(fp):
parts = line.split(" ")
if len(parts) > 2:
address = long(parts[0], 16)
name = parts[2]
@rpetrich
rpetrich / coalesce.js
Created October 6, 2018 17:32
Coalesce operator in swift-to-js
export function coalesce$option$(option) {
return option !== null ? option : false;
}
@rpetrich
rpetrich / README.md
Created June 2, 2018 15:15
Preact componentDidCatch performance

Preact componentDidCatch performance

Environment

  • The benchmark was run on a MacBook (Retina, 12-inch, 2015, 1.1 GHz Intel Core M, 8 GB RAM, macOS Sierra 10.12.6, Chrome 66.0.3359.181 (64-bit))
  • Ran npm run selenium -- --count 10 --framework vanillajs-keyed --framework preact-v8.2.7-keyed --framework preact-componentDidCatch-keyed in the webdriver-ts of this js-framework-benchmarks fork against this commit of the componentDidCatch-support preact branch.

Duration in milliseconds ± standard deviation (Slowdown = Duration / Fastest)

@rpetrich
rpetrich / ssh-proxy
Created November 9, 2017 15:46
Script to funnel traffic through SSH port forwarding
#!/bin/bash
if [ -z "$1" ]; then
echo "usage: $0 <ssh-options>"
exit 1
fi
restore_network() {
IFS=$'\n'
for network in `networksetup -listallnetworkservices | grep -v '*'`; do
@rpetrich
rpetrich / userscript.js
Created October 12, 2017 17:48
Kill JIRA Banner and Hover Indentation
// ==UserScript==
// @name No JIRA banner or Hover Indentation
// @namespace http://rpetri.ch/
// @version 0.1
// @description Remove JIRA announcement banners; Remove comment relayout on hover
// @author Ryan Petrich
// @match https://*.atlassian.net/*
// @grant none
// ==/UserScript==
@rpetrich
rpetrich / Makefile
Created August 15, 2017 01:07
rotation
.PHONY: clean all
CPPFLAGS = -std=c++14
LINK.o = $(LINK.cc)
all: rotation
clean:
rm *.o rotation
#!/bin/bash
if [ -z "$GIT_AUTHOR_EMAIL" ]; then
GIT_AUTHOR_EMAIL=`git config --get user.email`
fi
if [[ `uname` != Darwin ]]; then
IDENTITY=`readlink -f ~/.ssh/$GIT_AUTHOR_EMAIL`
elif which -s greadlink; then
IDENTITY=`greadlink -f ~/.ssh/$GIT_AUTHOR_EMAIL`
else
# No modern readlink with -f support, symlinks must be absolute paths :'(