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
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>
#!/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]
@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)
@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 / symlink_localizations.sh
Created February 12, 2012 06:27
relative symlinks
@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 / 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 / git-send-pull-request
Created April 16, 2011 14:50
Pushes the local branch up to the origin and opens the github pull request form in the browser
#!/bin/sh
ORIGIN=$1
if [ -e $1 ] ; then
ORIGIN=origin
fi
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
PROJECT=`git config --get remote.$ORIGIN.url | cut -f 2- -d : | cut -f 1 -d.`
git push $ORIGIN $BRANCH && open "https://github.com/$PROJECT/pull/new/$BRANCH"
@rpetrich
rpetrich / ssh-colored
Created April 7, 2011 13:02
Changes the terminal settings when calling SSH
#!/bin/sh
function tabc {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi
osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\""
}
function ctrl_c() {
tabc "Visor"
exit -1
}
@rpetrich
rpetrich / .bash_profile
Created March 19, 2011 06:45
Battery/charging indicator for OS X
# Change prompt to include battery indicator
# Use some funky escapes so bash determines the proper prompt length
PS1='\w \[$(~/bin/battery.sh)\] \[\033[1D\] '