Skip to content

Instantly share code, notes, and snippets.

View incanus's full-sized avatar

Justin R. Miller incanus

View GitHub Profile
@incanus
incanus / GitTagBundleVersion.sh
Created December 22, 2010 02:23
This is an Xcode build script that will automatically change your app's Info.plist CFBundleVersion string to match the latest git tag for the working copy. If you have commits beyond the last tagged one, it will append a 'd' to the number.
#/bin/sh
INFO=$( echo $PWD )/MyApp-Info
TAG=$( git describe --tags `git rev-list --tags --max-count=1` )
COMMIT=
GITPATH=/usr/bin:/usr/local/bin:/usr/local/git/bin
PATH=$PATH:$GITPATH; export PATH
if [ -z $( which git ) ]; then
echo "Unable to find git binary in \$GITPATH"
@incanus
incanus / gist:808151
Created February 2, 2011 18:41
This is a shell script to open the current Git repository on GitHub in the default browser. Only works at the top level of the working copy and on Mac OS X (for now).
grep github ./.git/config | sed -e 's/^.*\(github.com.*\)\.git$/\1/' -e 's/.*github\.com:*\/*/https:\/\/github.com\//' | xargs open
@incanus
incanus / gist:926686
Created April 19, 2011 02:21
live move of UIPopoverController
// check that popover won't try to move off-screen; dismiss if so
//
CGFloat pX = newAttachPoint.x;
CGFloat pY = newAttachPoint.y;
CGFloat pWidth = balloon.popoverContentSize.width;
CGFloat pHeight = balloon.popoverContentSize.height;
CGFloat mWidth = map.bounds.size.width;
CGFloat mHeight = map.bounds.size.height;
UIPopoverArrowDirection d = balloon.popoverArrowDirection;
@incanus
incanus / gist:1045095
Created June 24, 2011 16:07
constrained override for -[RMMapContents moveBy:] in route-me
- (void)moveBy:(CGSize)delta
{
// Adjust delta as necessary to constrain latitude, but not longitude.
//
// This is largely borrowed from -[RMMapView setConstraintsSW:NE:] and -[RMMapView moveBy:]
//
RMProjectedRect sourceBounds = [self.mercatorToScreenProjection projectedBounds];
RMProjectedSize XYDelta = [self.mercatorToScreenProjection projectScreenSizeToXY:delta];
CGSize sizeRatio = CGSizeMake(((delta.width == 0) ? 0 : XYDelta.width / delta.width),
@incanus
incanus / gist:1108777
Created July 27, 2011 06:09
This is my /etc/apache2/other/svn.conf for making Subversion play with the Mac's system Apache. On Lion, I had to install CollabNet's Subversion package (the 10.6 one) to get stuff into /opt.
LoadModule dav_svn_module /opt/subversion/lib/svn-apache/mod_dav_svn.so
LoadModule authz_svn_module /opt/subversion/lib/svn-apache/mod_authz_svn.so
<Location "/svn">
DAV svn
SVNParentPath /usr/local/svnroot
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/other/htpasswd
Require valid-user
</Location>
NSArray *colorNames = [NSArray arrayWithObjects:@"red", @"blue", @"yellow", @"green", @"brown", @"purple", @"cyan", @"orange", @"magenta", nil];
NSMutableArray *madeColors = [NSMutableArray array];
for (int c = 0; c < [colorNames count]; c++)
[madeColors addObject:[[UIColor class] performSelector:NSSelectorFromString([NSString stringWithFormat:@"%@Color", [colorNames objectAtIndex:c]])]];
@incanus
incanus / Xcode4TestFlightintegration.sh
Created September 1, 2011 19:12
Xcode 4 scheme Archive step Post-script for automatic TestFlight build uploading. See the blog post here: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
#LOG="/tmp/testflight.log"
@incanus
incanus / gist:1227259
Created September 19, 2011 18:51
symbolicate a stack trace snippet from TestFlight crash reports
cat ~/Desktop/crash1.log | awk '{ print $3 }' | xargs atos -arch armv7 -o MapBox.app.dSYM/Contents/Resources/DWARF/MapBox
@incanus
incanus / j
Created October 21, 2011 21:13
Bash script to kill old Jekyll processes, start a new one in the current directly, and open the browser to it.
#!/bin/sh
ps ax | grep jekyll | grep -v grep | awk '{ print $1 }' | xargs kill
jekyll &
sleep 1
open http://localhost:4000
@incanus
incanus / gist:1381351
Created November 21, 2011 01:17
AppleScript to use Display Audio as input & output devices
tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
click menu item "Sound" of menu "View" of menu bar 1
-- set output
click radio button "Output" of tab group 1 of window "Sound"
set theRows to every row of table 1 of scroll area 1 of ¬
tab group 1 of window "Sound"
repeat with aRow in theRows
if (value of text field 1 of aRow as text) ¬