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 / KBThemer.m
Created August 24, 2011 14:31
Keyboard Themer
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import <substrate.h>
extern CGColorRef UIKBGetNamedColor(CFStringRef gradientName);
#define kColorSettingsPath @"/var/mobile/Library/Preferences/com.rpetrich.kbthemer.colors.plist"
static NSMutableDictionary *colorSettings;
static CFMutableDictionaryRef namedColors;
@rpetrich
rpetrich / Sidewalk Chalk.dvtcolortheme
Created January 30, 2012 20:53
My Xcode Colour Theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>PragmataPro - 13.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@rpetrich
rpetrich / symlink_localizations.sh
Created February 12, 2012 06:27
relative symlinks
@rpetrich
rpetrich / class-dump-d-ff
Created March 6, 2012 23:09
diff class-dump-z outputs with highlighting
#!/bin/bash
diff -u --show-function-line=^@interface --label="$1" --label="$2" <( class-dump-z -RbSz "$1" ) <( class-dump-z -RbSz "$2" ) | GREP_COLOR='1;32' grep --color=always -e '^\(\+.*$\)\?' | GREP_COLOR='1;31' grep --color=always -e '^\(\-.*$\)\?' | less -FRSX
@rpetrich
rpetrich / UIScale.h
Created March 9, 2012 00:37
Convenience functions for getting the screen scale and rounding metrics relative to it.
#import <UIKit/UIKit.h>
#define UI_MAIN_SCREEN_SCALE() ([UIScreen instancesRespondToSelector:@selector(scale)] ? [UIScreen mainScreen].scale : 1.0f)
static inline CGFloat CGFloatRoundToScale(CGFloat value, CGFloat scale)
{
return roundf(value * scale) / scale;
}
static inline CGFloat CGFloatRoundToMainScreen(CGFloat value)
#!/bin/bash
MobileSafari_PID=$(ps x | grep "MobileSafari" | grep -v grep | awk '{ print $1 }')
if [ "$MobileSafari_PID" == "" ]; then
echo "Mobile Safari.app must be running in the Simulator to enable the remote inspector."
else
cat <<EOM | gdb -quiet > /dev/null
attach $MobileSafari_PID
p (void *)[WebView _enableRemoteInspector]
nic 1
prompt TARGET "BulletinBoard Provider Display Identifier" "com.apple.mobilesafari"
dir BulletinBoard
dir layout
dir layout/Library
dir layout/Library/WeeLoader
dir layout/Library/WeeLoader/BulletinBoardPlugins
dir layout/Library/WeeLoader/BulletinBoardPlugins/@@PROJECTNAME@@.bundle
file 366 BulletinBoard/BulletinBoard.h
#import <Foundation/Foundation.h>
function makePair(left, right) {
return { left: left, right: right };
}
window["add"] = function(a, b) {
var pair = makePair(a, b);
return t.left + t.right;
}
#!/bin/sh
if [[ $# == 0 ]]; then
SYM_PATH="/var/mobile/Library/Logs/CrashReporter/LatestCrash.plist"
else
if [[ $1 == /* ]]; then
SYM_PATH="$1"
else
SYM_PATH="/var/mobile/Library/Logs/CrashReporter/LatestCrash-$1.plist"
fi
fi
@rpetrich
rpetrich / make_char_array.rb
Created April 21, 2013 07:44
Convert binaries to character arrays
#!/usr/bin/env ruby
ARGV.each do |filename|
puts "// #{filename}"
myfile = File.open(filename, "r")
result = ""
myfile.each_byte { |byte| result = result + "," + byte.to_s }
myfile.close
safename = filename.gsub(".", "_").gsub("/","$").gsub("@","$")
puts "static const char #{safename}[] = { " + result[1..-1] +" };";
# puts "const size_t #{safename}_size = sizeof(#{safename});";