Skip to content

Instantly share code, notes, and snippets.

View simonwhitaker's full-sized avatar

Simon Whitaker simonwhitaker

View GitHub Profile
@simonwhitaker
simonwhitaker / save-dated-pdf.sh
Created February 2, 2012 08:37
A PDF Action menu item for OS X that saves to a folder hierarchy incorporating the current date
#!/bin/bash
#
# save-dated-pdf.sh
#
# Save PDFs from the OS X PDF menu to a folder
# named according to the current date, of the
# form /path/YYYY/MM/
#
# For example, you could use this to export receipts
# you receive via email during February 2012 to
@simonwhitaker
simonwhitaker / git-version.sh
Created February 8, 2012 16:37
A shell script for setting the CFBundleVersion of an Xcode build based on the current git revision
# A script for generating pseudo-version numbers for a git repository
# and updating the BundleVersion of an Xcode app build with this version
alias git=$(which git)
git_version()
{
# The cornerstone of this hack is "git describe", which
# relies on there being at least one "real" tag (i.e. not
# a lightweight tag) somewhere in the current code's commit
@simonwhitaker
simonwhitaker / version.sh
Created February 26, 2012 19:52 — forked from osteslag/version.sh
Script for managing build and version numbers using git and agvtool. See link in comments below.
#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
version() {
echo "version.sh 1.0 by Joachim Bondo <osteslag@gmail.com> http://osteslag.tumblr.com"
}
@simonwhitaker
simonwhitaker / convert-ext-to-uti.m
Created March 22, 2012 09:48
Lists the UTIs for a given list of file extensions
#import <Foundation/Foundation.h>
#import <CoreServices/CoreServices.h>
#import <libgen.h>
/*
convert-ext-to-uti
Shows the Uniform Type Identifier(s) (UTI) for a
file type based on its file extension. Output is
a tab-separated tuple of (extension, UTI) per
@simonwhitaker
simonwhitaker / generate-settings-strings.sh
Created April 5, 2012 11:23
Generate a basic .strings file for each .plist of an iOS Settings.bundle
#!/bin/bash
# NB: next line assumes that this script is in the root
# of your Settings.bundle directory. Feel free to adapt
# accordingly.
base_dir=$(dirname $0)
for plist in *.plist; do
# Generate the name of the matching .strings file
outfile=en.lproj/${plist%.*}.strings
@simonwhitaker
simonwhitaker / snippet.m
Created April 18, 2012 14:30
Suppress deprecated-declarations warning when calling uniqueIndentifier, e.g. for TestFlight API
#ifdef TESTING
/*
Disable deprecated-declarations warning.
See http://clang.llvm.org/docs/UsersManual.html#diagnostics_pragmas
Basic workflow:
1. push current warnings onto stack
2. ignore warning we know will get thrown
3. do dodgy thing that causes warning
/*
* === Routine for toggling @replies ===
*
* Step 1: Using jQuery (which Twitter already loads), select the div
* elements of class stream-item that contain tweets where the
* data-is-reply-to attribute is true.
*/
var tweets = $('div.tweet[data-is-reply-to=true]').parents('div.stream-item');
/*
@simonwhitaker
simonwhitaker / com.yourcompany.py
Created April 25, 2012 21:13
Find top-selling apps with com.yourcompany.* bundle IDs.
# A simple Python script to find top-selling iOS apps with bundle IDs
# starting with the default 'com.yourcompany'. Guaranteed lulz!
from xml.dom.minidom import parse
from urllib2 import urlopen
# Substitute topfreeapplications for toppaidapplications to query paid apps
# Substitute gb for other country codes (us, ca, fr, etc...)
url = 'http://itunes.apple.com/gb/rss/topfreeapplications/limit=300/xml'
@simonwhitaker
simonwhitaker / gist:2923856
Created June 13, 2012 12:46
One-liner to see most contested new gTLDs as revealed by ICANN on 13th June 2012 (http://newgtlds.icann.org/en/program-status/application-results/strings-1200utc-13jun12-en)
curl -s http://newgtlds-cloudfront.icann.org/sites/default/files/reveal/strings-1200utc-13jun12-en.csv \
| tr '\015' '\012' | cut -d, -f1 | sort | uniq -c | sort -nr | head
@simonwhitaker
simonwhitaker / migrate-to-sublime-text.sh
Created July 1, 2012 12:46
Flip your TextMate file type associations to use Sublime Text 2 instead
#!/bin/sh
# Quick and dirty script to flip all the file type currently
# associated with TextMate to be associated with Sublime Text 2
# instead.
#
# DISCLAIMER: worked for me, might not work for you. Use at your
# own risk. I accept no responsibility if you trash your system.
# Specify the plist file we need to tweak