Skip to content

Instantly share code, notes, and snippets.

View simonwhitaker's full-sized avatar

Simon Whitaker simonwhitaker

View GitHub Profile
@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
*/
@simonwhitaker
simonwhitaker / gist:506429
Created August 3, 2010 14:11
Append the current SVN revision to an iPhone app's version number at build time
# Get location of unparsed Info.plist
GS_INFO_PLIST_INPUT=$(basename "$INFOPLIST_FILE" .plist)
# Get location of parsed Info.plist
GS_INFO_PLIST_PATH="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/Info"
# Get version number from unparsed Info.plist
GS_VERSION=$(defaults read "$PROJECT_DIR/$GS_INFO_PLIST_INPUT" CFBundleVersion)
# Append local SVN revision number
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (UIInterfaceOrientationIsLandscape(fromInterfaceOrientation)) {
// Fade in instructions
[self setInstructionsOpacity:1.0 overTime:0.5];
}
}
@simonwhitaker
simonwhitaker / index.yaml
Created October 20, 2010 12:26
nanoc config for the Goo Software website homepage
apps:
- name: RSA Vision
slogan: Enlightenment to go
itunes_url: http://itunes.apple.com/gb/app/rsa-vision/id397348011?mt=8
image: /images/apps/rsa-vision.png
description:
- > The RSA Vision app brings to you the latest videos from the
RSA's free public events programme. You can browse by category,
search for videos and compile a playlist of your favourite
videos to watch later.
@simonwhitaker
simonwhitaker / index.rhtml
Created October 20, 2010 12:29
RHTML snippet showing use of nanoc to construct config-driven website for Goo Software Ltd
<% for app in @item[:apps]%>
<div class="app" id="<%= app[:name].downcase.gsub(' ','-') %>">
<h2>
<a href="<%= app[:itunes_link] %>"><%= app[:name] %></a>
<span class="appslogan"><%= app[:slogan]%></span>
</h2>
<a href="<%= app[:itunes_link] %>"><img src="<%= app[:image] %>" class="screenshot" alt="app screenshot" border="0"></a>
<div class="description">
<% for desc in app[:description]%>
<p><%= desc %></p>
@simonwhitaker
simonwhitaker / gist:784652
Created January 18, 2011 16:09
Example of a simple Objective-C-compatible file that won't run under CMD+R in TextMate
#import <Foundation/Foundation.h>
int main (int argc, char const *argv[])
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
for(size_t i = 0; i < 2; ++i)
{
NSLog(@"Hello world");
}
#!/bin/bash
# A simple shell script for helping you do code reviews on patch files. Feed
# in the SHA1 for the commit the patch builds on and the path to the patch
# file and it'll spin up a new branch for you, check it out and apply the
# patch. You can now use your favourite diff tool to review the patch.
usage() {
printf "usage: %s <sha> <patchfile>\n" $(basename $0)
echo
@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 / UIColor+GSAdditions.h
Created September 15, 2011 11:19
A category on UIColor adding +(UIColor*)colorWithHexValue:(NSString*)hexValue;
//
//
// UIColor+GSAdditions.h
//
// Created by Simon Whitaker at Goo Software Ltd on 15/09/2011.
//
#import <UIKit/UIKit.h>
@interface UIColor (GSAdditions)
@simonwhitaker
simonwhitaker / gist:1493422
Created December 18, 2011 13:29
Diffs between TBXML as downloaded from tbxml.co.uk and the initial commit on https://github.com/steipete/TBXML/
$ diff -r TBXML-orig/ TBXML-github-fc2db6c/
Only in TBXML-github-fc2db6c/: .git
diff -r TBXML-orig/TBXML.m TBXML-github-fc2db6c/TBXML.m
258c258
< while (elementStart = strstr(elementStart,"<")) {
---
> while ((elementStart = strstr(elementStart,"<"))) {
311c311
< while (elementEnd = strpbrk(elementEnd, "<>")) {
---