Skip to content

Instantly share code, notes, and snippets.

View incanus's full-sized avatar
always building

Justin Miller incanus

always building
View GitHub Profile
@incanus
incanus / gist:1435907
Created December 5, 2011 23:31
Script to scrape outage data from Connecticut Light & Power data site at http://outage.cl-p.com/outage/mobile.aspx for use in maps at http://tiles.mapbox.com/justin during November 2011 mass outages. Maps made with http://mapbox.com/tilemill/
#!/bin/sh
DATEFILE=/tmp/`date +"%s"`.html
curl -s http://outage.cl-p.com/outage/mobile.aspx > $DATEFILE
rm outages.csv 2>/dev/null
#cat $DATEFILE | grep '<table' | sed -e 's/.*<thead><tr><th>//g' -e 's/<\/th><\/tr><\/thead>.*//g' -e 's/<\/th><th>/,/g' >> outages.csv
cat $DATEFILE | grep '<table' | sed -e 's/.*<\/thead>//g' -e 's/<tfoot>.*//g' -e 's/<tr><td>//g' -e 's/<\/td><td>/|/g' -e 's/<\/td><\/tr>/@/g' -e 's/@$//g' | tr '@' "\n" >> outages.csv
@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) ¬
@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: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 / 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"
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 / 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>
@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: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: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