Skip to content

Instantly share code, notes, and snippets.

Oliver Foggin oliverfoggin

Block or report user

Report or block oliverfoggin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@oliverfoggin
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;
@end
@interface MyImageDownloader : NSObject
@oliverfoggin
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 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.

View Neo4j MRDWC.adoc

MRDWC Neo4j gist

I’ve been watching the Men’s Roller Derby World Cup today so thought I’d get some info out of what’s going on.

Still ne to Neo4j so still learning and playing around with it to see what I can do with it.

Node Types

  • (Group {name:""})

  • (Team {name:""})

  • (Game {day:1, time:1000})

@oliverfoggin
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.
//hide
//setup
[source, cypher]
----
//publishers
@oliverfoggin
oliverfoggin / gist:10024117
Last active Aug 29, 2015
Failing UISearchDisplayController
View gist:10024117
#import "UserSearchViewController.h"
@interface UserSearchViewController () <UISearchBarDelegate, UISearchDisplayDelegate>
@end
@implementation UserSearchViewController
- (void)viewDidLoad
{
@oliverfoggin
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]
View gist:e22aa20675e68f17a163
// Challenge set here...
// https://blog.svpino.com/2015/06/07/programming-challenge-towers-of-hanoi
import UIKit
// convenience for printing
func moveRing(ring : Int, currentPole: Int, targetPole: Int) {
println("Move ring \(ring) from pole \(currentPole) to pole \(targetPole)")
}
View Router.swift
enum Router: URLRequestConvertible {
static let baseURLString = "http://someURL.co.uk"
static var OAuthToken: String? {
didSet {
// save token to keychain
}
}
case AuthCheck
@oliverfoggin
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
You can’t perform that action at this time.