Skip to content

Instantly share code, notes, and snippets.

View simonwhitaker's full-sized avatar

Simon Whitaker simonwhitaker

View GitHub Profile
@simonwhitaker
simonwhitaker / passwords.md
Created November 15, 2012 16:23
Passwords: Of MD5 and Mistresses

By Simon Whitaker

Errata Security have an interesting post on the hacking of a general's mistress. In it, Robert David Graham looks at how long it would take someone to discover Paula Broadwell's Yahoo! email password based on the hashed copy leaked in an email hack last year. He states:

it'll take 17 hours to crack her password using a GPU accelerator trying 3.5-billion password attempts per second, trying all combinations of upper/lower case and digits.

(My emphasis)

I read that and thought: clearly he's making an assumption here about the (maximum) length of the password. I wonder what the assumption was?

$ grep "\.project" .gitignore
.project
$ git bisect bad
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[85547ec7aa1e9087ed84f09d0f8c603b88377978] Added MIT license text to top of apns.py
$ grep "\.project" .gitignore
$ git bisect good
Bisecting: 11 revisions left to test after this (roughly 4 steps)
[9d17aa48641e3540fbc6a54c26776b45c865887b] unset badge by passing badge=0
$ grep "\.project" .gitignore
@simonwhitaker
simonwhitaker / show-url.md
Created August 1, 2012 13:00
A Javascript bookmarklet to show the URL for a search results page in Safari 6

Show search results URL in Safari 6

Here's a bookmarklet that'll pop the current search results page's URL open in one of those annoying little JS prompt dialogs.

Show URL

Drag it to your bookmarks bar and click when needed.

The code in a nutshell:

@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
@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 / 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'
/*
* === 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 / 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
@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 / 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