Skip to content

Instantly share code, notes, and snippets.

@jpwatts
jpwatts / scraper.py
Created May 26, 2011 21:15
Scraper for Houston's active incident report
#!/usr/bin/env python
"""Scraper for Houston's active incident report"""
import collections
import csv
import operator
import sys
@jpwatts
jpwatts / xcode-git-version.sh
Created May 11, 2011 16:42
This Xcode 4 build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository.
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode 4, add the contents to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset
@jpwatts
jpwatts / mac-homebrew-pyexiv2.sh
Created February 10, 2011 00:33
In which I finally get pyexiv2 working on my Mac using Homebrew and a series of disgusting hacks
#!/bin/sh
brew install python boost exiv2
curl -O http://launchpadlibrarian.net/61465005/pyexiv2-0.3.0.tar.bz2
tar xjvf pyexiv2-0.3.0.tar.bz2
cd pyexiv2-0.3.0
# https://answers.launchpad.net/pyexiv2/+question/140742
echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript
@jpwatts
jpwatts / shorturl.js
Created May 30, 2010 02:24
A bookmarklet for finding a short URL for a page
// javascript:(function(){var l=(document.querySelector('[rev~="canonical"]')||document.querySelector('[rel~="alternate"][rel~="short"]')||document.querySelector('[rel~="shortlink"]')||document.querySelector('[rel~="shorturl"]')||document.querySelector('[rel~="alternate"][rel~="shorter"]'));if(l){prompt("Short URL:",l.getAttribute('href'));}else{window.shortUrlBookmarkletCallback=function(bitly){if(bitly.status_code===200){prompt("Bit.ly URL:",bitly.data.url);}else{alert("Bit.ly error:"+bitly.status_txt);}};var s=document.createElement('script');s.type='text/javascript';s.src=('http://api.bit.ly/v3/shorten'+'?longURL='+encodeURIComponent(window.location.href)+'&domain=j.mp'+'&format=json'+'&callback=shortUrlBookmarkletCallback'+'&login=BITLY_USERNAME'+'&apiKey=BITLY_API_KEY');document.querySelector('head').appendChild(s);}})();
(function() {
var l = (document.querySelector('[rev~="canonical"]')
|| document.querySelector('[rel~="alternate"][rel~="short"]')
|| document.querySelecto
#!/bin/sh
APP_PATH=/Applications
APP_NAME=${APP_PATH}/Chromium.app
TMP_PATH=/tmp/update-chromium-$$
TMP_NAME=${TMP_PATH}/chrome-mac.zip
BASE_URL=http://build.chromium.org/buildbot/snapshots/chromium-rel-mac
REVISION=$(curl -s ${BASE_URL}/LATEST)
# I tested these instructions on Ubuntu 9.04 Server 64-bit running on
# VMware Fusion 2.0.4.
# I'm assuming you're doing this all from $HOME.
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install build-essential curl
# Either (Ubuntu 9.04 Server)