Skip to content

Instantly share code, notes, and snippets.

View simonwhitaker's full-sized avatar

Simon Whitaker simonwhitaker

View GitHub Profile
MatrixDemo (master|✚1) $ time -l ./build/Release/MatrixDemo 2000 1000 1000 dumb
algorithm: dumb_matrix_multiply
Done! (332833500000.0) 14.05 real 14.00 user 0.04 sys
40906752 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
10001 page reclaims
0 page faults
0 swaps
#include <stdio.h>
#include <Accelerate/Accelerate.h>
int main(int argc, const char * argv[]) {
double A[] = {
1.0, 2.0, 3.0,
4.0, 5.0, 6.0
};
import numpy as np
A = [
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0]
]
B = [
[1.0, 2.0],
[3.0, 4.0],
@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
@simonwhitaker
simonwhitaker / show-constants.m
Created April 5, 2010 20:37
A simple Objective-C program to show the control point values for the constants in the CAMediaTimingFunction class
/*
show-constants.m
Show the control point values for the CAMediaTimingFunction class constants
To compile:
clang -framework QuartzCore -framework Foundation show-constants.m -o show-constants
*/
1. 4086
2. 10/11
3. 36
4. D
5. 11
6. 1
7. 6
8. 336
9. 36
10. 1/12
@simonwhitaker
simonwhitaker / pymod.sh
Created May 18, 2011 20:32
pymod - Python one-liner for finding the location on disk of a given Python module. Stick it in your .bashrc or whatever for instant pymod joy.
# pymod MOD: find file path to implementation for python module called MOD
alias pymod="python -c 'import sys; print(__import__(sys.argv[1]).__file__)'"
@simonwhitaker
simonwhitaker / ssl_expiry.sh
Created November 30, 2012 22:27
Get the expiry date of a secure website's SSL certificate at the command line
#!/bin/sh
ssl_expiry() {
# Show usage info if not called with a hostname
if [ $# -eq 0 ]; then
echo "Usage: ssl_expiry HOSTNAME"
return 0
fi
domain=$1
@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?