Skip to content

Instantly share code, notes, and snippets.

View lukeredpath's full-sized avatar
🏠
Working from home

Luke Redpath lukeredpath

🏠
Working from home
View GitHub Profile
@implementation NSObject (Identity)
- (BOOL)LR_isClass
{
return [self class] == self;
}
- (BOOL)LR_isProtocol
{
return [self class] == NSClassFromString(@"Protocol");
@lukeredpath
lukeredpath / MockyExpectations.mm
Last active December 10, 2015 16:09 — forked from anonymous/Expectations.mm
Quick preview of the new Mocky syntax. The previous syntax required passing an explicit builder object into the checking block. I tried to work around this with some macros to make it more readable but this seemed generally like a bad idea. The new version keeps macros to a minimum. I also felt the jMock syntax - verbatim - didn't feel quite rig…
- (void)testCanExpectSingleMethodCallAndPass
{
id<SomeProtocol> testObject = [context protocolMock:@protocol(SomeProtocol)];
[context check:^{
[[expectThat(testObject) receives] doSomething];
}];
[testObject doSomething];
@lukeredpath
lukeredpath / jetbrains.teamcity.BuildAgent.plist
Created November 14, 2012 17:22
Launcher for TeamCity OSX Build Agent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WorkingDirectory</key>
<string>/Users/teamcity/TeamCity/buildAgent</string>
<key>Debug</key>
<false/>
<key>Label</key>
<string>jetbrains.teamcity.BuildAgent</string>
{
"user": {
"id": 999,
"name": "Joe Bloggs"
},
"stream": [
{
"link": {
"url": "http://www.example.com",
"id": 123
//
// RKObjectMapping+TransformationMapping.h
// OtherScreen
//
// Created by Luke Redpath on 05/10/2012.
// Copyright (c) 2012 Mark Rickert. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <RestKit/RestKit.h>
// we want to map foo_bar -> fooBar, baz_qux -> bazQux
[mapping addPropertyMappingsFromArray:@["foo_bar", @"baz_qux"] transformSourceToDestinationKeysUsingBlock:^(NSString *sourceKey) {
return [sourceKey someMethodThatTransformsSnakeCaseToCamelCase];
}];
@lukeredpath
lukeredpath / appearance.m
Created October 2, 2012 13:12
Customise table section headers
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setFont:<whatever>]
@lukeredpath
lukeredpath / gist:3758007
Created September 20, 2012 20:00
BBQ Chilli Pork recipe
1. Slow cook 2 lb / 1 KG of boneless pork shoulder on low for at least 8 hours, seasoned with salt and pepper and add half a cup of water.
2. Remove pork, drain cooking juices and set aside. Remove skin/fat layer and throw it in the oven on 200 C for half hour until you have crackling!
3. Shred pork, return to slow cooker with half the cooking juices, enough to keep it moist.
4. Slice one medium onion, fry over medium heat until golden, add to pork.
5. Add 1 tbsp of barbecue spice/seasoning, 1tsp cayenne pepper, 1tsp chilli powder, lots of black pepper, 1 tbsp of garlic powder...be creative, maybe some cumin and smoked paprika? I added a tsp of cinnamon.
@lukeredpath
lukeredpath / hsbc.rb
Created September 17, 2012 12:38
Automated HSBC business banking statement downloads
require 'rubygems'
require 'mechanize'
require 'keychain'
class Scraper
def initialize(url)
@url = url
@flows = []
end
@lukeredpath
lukeredpath / mocky.m
Created September 7, 2012 20:15
New mocky syntax
[context checking:^{
// simple expectation
[expectThat(testObject).receives doSomething];
// with arguments
[expectThat(testObject).receives doSomethingWithArgument:@"arg"];
// expectation with cardinality
[[expectThat(testObject).receives doSomething] times:1];
[[expectThat(testObject).receives doSomething] atLeast:1];