Skip to content

Instantly share code, notes, and snippets.

View maxehmookau's full-sized avatar

Max Woolf maxehmookau

View GitHub Profile
@maxehmookau
maxehmookau / Reachability.h
Created September 10, 2011 08:38 — forked from dhoerl/Reachability.h
Reachability (iOS) ARCified
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 2.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
@maxehmookau
maxehmookau / XMLSchema
Created May 20, 2012 12:08
Simple XML Schema
<xsd:schema xmlns:xsd="http://www.w3.org/2011/XMLSchema">
<xsd:complexType name = "codeFragment">
<xsd:attribute name="language", type ="xsd:string", default="JAVA" />
<xsd:sequence>
<xsd:element name="author" type="xsd:string" minOccurs="1", maxOccurs="1" />
<xsd:element name = "title", type="xsd:string", minOccurs="1", maxOccurs="1" />
<xsd:element name="date", type ="xsd:date", minOccurs="1", maxOccurs="1" />
<xsd:element name="code", type="xsd:string", minOccurs="1", maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
@maxehmookau
maxehmookau / MWButton.h
Created November 25, 2012 18:28
Nice UIButton
//
// SUButton.h
// SussexStudentsUnion
//
// Created by Max Woolf on 02/11/2012.
// Copyright (c) 2012 USSU. All rights reserved.
//
#import <UIKit/UIKit.h>
@maxehmookau
maxehmookau / launch_steps.rb
Created December 1, 2012 20:06
BDD with iOS and testingwithfrank
def app_path
ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
end
Given /^I launch the app using iOS (\d\.\d) and the (iphone|ipad) simulator$/ do |sdk, version|
launch_app app_path, sdk, version
end
@maxehmookau
maxehmookau / Login.mm
Created January 27, 2013 15:30
Initializing a CocoaLibSpotify session the *right* way.
[SPSession initializeSharedSessionWithApplicationKey:[NSData dataWithBytes:&g_appkey length:g_appkey_size] userAgent:@"MaxWoolf.SpotifyRadio" loadingPolicy:SPAsyncLoadingManual error:&mainError]
@maxehmookau
maxehmookau / person.rb
Created February 19, 2013 09:44
@ symbol in Ruby
class Person
def initialize(name)
@name = name
end
def name
puts @name
end
@maxehmookau
maxehmookau / rightTriangles.hs
Last active December 14, 2015 13:28
Find the length of the sides of right-angled triangles with a perimeter of 24 and some other mathy stuff
let rightTriangles = [ (a,b,c) | c <- [1..10], b <- [1..10], a <- [1..10], a^2 + b^2 == c^2, a+b+c == 24 ]
circumference' :: Float -> Float
circumference' r = 2*pi*r
@maxehmookau
maxehmookau / pull_request.rb
Created March 17, 2013 11:56
Make a pull request from your current branch in to the repo's master branch.
def get_current_branch
b = `git branch`.split("\n").delete_if { |i| i[0] != "*" }
current_branch = b.first.split(" ").last
end
def get_origin_remote
`git remote -v`.split("\n").delete_if { |i| i[0..5] != 'origin' }.first
end
def get_github_username
@maxehmookau
maxehmookau / gist:5322387
Created April 5, 2013 20:30
This sucks, but there must be a better way to do it.
def humanised_time
if milliseconds < 60000
"#{ milliseconds / 1000 }sec"
elsif milliseconds > 60000 && milliseconds < 3600000
"#{ ((milliseconds / (1000 * 60)) % 60) }m #{ (milliseconds / 1000) % 60 }s"
else
"#{ ((milliseconds / (1000 * 60 * 60)) % 24) }h #{ ((milliseconds / (1000 * 60)) % 60) }m #{ (milliseconds / 1000) % 60 }s"
end
end
@maxehmookau
maxehmookau / Guardfile
Created May 6, 2013 14:18
Using Guard to run your OCUnit tests automatically.
guard 'shell' do
watch(/(.*).(m|h|mm|hh)/) do
puts "Change detected. Running tests..."
`../xctool/xctool.sh -project XCodeProject.xcodeproj -scheme MainScheme test -reporter plain`
end
end