Skip to content

Instantly share code, notes, and snippets.


Oliver Foggin oliverfoggin

View GitHub Profile
oliverfoggin / MyImageDownloader.h
Created Nov 7, 2013
NSURLConnection download with progress callbacks
View MyImageDownloader.h
@protocol MyImageDownloaderDelegate <NSObject>
- (void)downloadFailed;
- (void)imageDownloadFinished:(UIImage *)image;
- (void)progressUpdated:(CGFloat)progress;
@interface MyImageDownloader : NSObject
View gist:9ce9008ddf22974f963a3cfbd565b629
import UIKit
class BuyButton: UIView {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//MARK: - View
backgroundColor = UIColor(red: 180/255, green: 35/255, blue: 115/255, alpha: 1)
layer.cornerRadius = 3
oliverfoggin / GKRuleSystemValidator.swift
Last active Dec 7, 2016
GameplayKit GKRuleSystem Validator
View GKRuleSystemValidator.swift
import Foundation
import GameplayKit
enum ValidationResult<T: Error> {
case valid
case invalid(error: T)
class Fact<T: Error>: NSObject {
let error: T
View Router.swift
enum Router: URLRequestConvertible {
static let baseURLString = ""
static var OAuthToken: String? {
didSet {
// save token to keychain
case AuthCheck
oliverfoggin / viewWithTextIn.m
Last active Mar 9, 2016
How to centre text using drawInRect...
View viewWithTextIn.m
//Create the rect you would like your text to be inside of...
CGRect maxTextRect = CGRectMake(0, 0, 200, 60);
//Create the attributed string
NSAttributedString *theString = //... do all the setup.
//Find the rect that the string will draw into **inside the maxTextRect**
CGRect actualRect = [theString boundingRectWithSize:maxTextRect.size options:NSStringDrawingUsesLineFragmentOrigin context:nil];
//Offset the actual rect inside the maxTextRect
View gist:e22aa20675e68f17a163
// Challenge set here...
import UIKit
// convenience for printing
func moveRing(ring : Int, currentPole: Int, targetPole: Int) {
println("Move ring \(ring) from pole \(currentPole) to pole \(targetPole)")
oliverfoggin / gist:0569e25ec93a0cc38187
Last active Aug 29, 2015
Programmin Challenge: the position of the element (Messing around in Swift)
View gist:0569e25ec93a0cc38187
import UIKit
// binary search function to find position
func findPositionInArray<T: Comparable>(array: [T], value: T) -> Int {
var lowerIndex = 0
var upperIndex = array.count - 1
while lowerIndex < upperIndex {
let currentIndex = lowerIndex + Int(Double(upperIndex - lowerIndex) * 0.5)
let currentValue = array[currentIndex]
oliverfoggin / gist:10024117
Last active Aug 29, 2015
Failing UISearchDisplayController
View gist:10024117
#import "UserSearchViewController.h"
@interface UserSearchViewController () <UISearchBarDelegate, UISearchDisplayDelegate>
@implementation UserSearchViewController
- (void)viewDidLoad
oliverfoggin / gist:9743873
Last active Aug 29, 2015
Search for a book by its cover
View gist:9743873
== Search for a book by its cover
Playing on the saying "Don't judge a book by its cover" I created this so that if you see a book online or in a shop but you forget what it's called you can find it by recalling details about the cover.
[source, cypher]
View Neo4j Roller Derby.adoc

Roller Derby MMR test doc

As a roller derby ref I love looking at the stats.

I put this together to teach myself Neo4j a bit but also to get some decent stats out of a practise game.

Node Types

  • Skater: All of the skaters

    • Properties: Name and number.

You can’t perform that action at this time.