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
@lukeredpath
lukeredpath / GenericMatchers.swift
Last active August 29, 2015 14:02
A more generic approach to expectations
import Cocoa
protocol Matcher {
typealias Matchable
func matches(object: Matchable) -> Bool
}
class EqualMatcher<T:Equatable>: Matcher {
typealias Matchable = T
@lukeredpath
lukeredpath / SwiftExpectations.swift
Last active August 29, 2015 14:02
My first experiments with Swift
// Playground - noun: a place where people can play
import Cocoa
protocol Matcher {
func matches(object: AnyObject) -> Bool
}
class EqualMatcher: Matcher {
let testObject: AnyObject
@lukeredpath
lukeredpath / gist:10637096
Created April 14, 2014 10:47
git ci -m "Got married"
From 84ce1471f76b84bb5bfa369dab19f4d920096e4f Mon Sep 17 00:00:00 2001
From: Luke Redpath <[email protected]>
Date: Mon, 14 Apr 2014 11:46:21 +0100
Subject: [PATCH] Got married
---
_includes/about.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/_includes/about.html b/_includes/about.html
extern const struct DomainRelationships {
__unsafe_unretained NSString *records;
__unsafe_unretained NSString *registrant;
__unsafe_unretained NSString *user;
} DomainRelationships;
extern const struct DomainRelationships {
__unsafe_unretained NSString *records;
__unsafe_unretained NSString *registrant;
__unsafe_unretained NSString *user;
} DomainRelationships;
@lukeredpath
lukeredpath / UITextField+RACKeyboardSupport.m
Last active April 19, 2017 10:36
ReactiveCocoa signal for keyboard done button taps
#import "UITextField+RACKeyboardSupport.h"
#import <ReactiveCocoa/RACEXTScope.h>
#import <ReactiveCocoa/NSObject+RACDescription.h>
@implementation UITextField (RACKeyboardSupport)
- (RACSignal *)rac_keyboardReturnSignal {
@weakify(self);
return [[[[RACSignal
defer:^{
@lukeredpath
lukeredpath / TestCase.m
Created December 5, 2013 15:14
A typical Objective-C test case...
#import <XCTest/XCTest.h>
@interface Tests : XCTestCase
@end
@implementation Tests
- (void)setUp
{
@lukeredpath
lukeredpath / gist:7605370
Created November 22, 2013 19:22
UIColor from hex
#define UIColorFromRGBHexValue(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define UIColorFromRGBHexValueWithAlpha(rgbValue,a) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]
@lukeredpath
lukeredpath / UIAlertView+BlockSupport.h
Created August 14, 2013 08:56
I wanted a block-based API for UIAlertView on my current project, but didn't want to import a whole Pod/library just for that, so I wrote a quick and simple implementation myself. Licensed under the WTFPL license. (http://www.wtfpl.net).
//
// UIAlertView+BlockSupport.h
//
// Created by Luke Redpath on 08/08/2013.
//
#import <UIKit/UIKit.h>
/* Called when the user taps a button in the alert view or the alert
* is cancelled.
@lukeredpath
lukeredpath / ISO8601DateFormatter.podspec
Last active December 20, 2015 04:28
Custom podspec pointing to my ISO8601DateFormatter fork
Pod::Spec.new do |s|
s.name = 'ISO8601DateFormatter'
s.version = '0.6'
s.license = 'BSD'
s.summary = 'A Cocoa NSFormatter subclass to convert dates to and from ISO-8601-formatted strings. Supports calendar, week, and ordinal formats.'
s.homepage = 'https://bitbucket.org/boredzo/iso-8601-parser-unparser/'
s.author = 'Peter Hosey'
s.source = { :git => 'https://github.com/lukeredpath/iso-8601-date-formatter.git', :branch => "support-millisecond-precision" }
s.source_files = 'ISO8601DateFormatter.{h,m}'