Skip to content

Instantly share code, notes, and snippets.

View itsthejb's full-sized avatar

Jonathan Crooke itsthejb

View GitHub Profile
@itsthejb
itsthejb / EXPMatchers+containObject.h
Created January 28, 2014 16:47
Expecta matcher for collection containing an instance of a given class
//
// EXPMatchers+containObject.h
// Created by Jonathan Crooke on 28/01/2014.
//
#import "Expecta.h"
/**
* Match a collection that contains at least one object that is
* an instance of expected
@itsthejb
itsthejb / Foundation+NSUTType.h
Created January 28, 2014 23:41
Obj-C wrapper and categories for NSString and NSURL for Cocoa UTTypes
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, NSUTType) {
NSUTTypeImage,
NSUTTypeMovie,
NSUTTypeAudio,
NSUTTypeUnknown
};
@interface NSURL (UTType)
-- This script automatically `cd`s to the directory of the current document.
-- You can use $f to represent the file for the current document.
-- This is nowhere near perfect, just a quick and dirty script.
-- NOTE: you need to have "Enable access for assistive devices" checked...
-- in the Accessibility preference pane.
-- Example: select a file in Finder, and type: echo The filename is $f
on getCurrentDocument()
@itsthejb
itsthejb / SuppressLeakWarning.m
Last active August 29, 2015 13:56
Macro to suppress performSelector leak warning while executing an arbitrary block. Can yield a value.
#define SuppressPerformSelectorLeakWarningForExpression(expression) ({ \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
expression; \
_Pragma("clang diagnostic pop") })
import UIKit
public extension UIColor {
public struct Flat {
public static var turquoise: UIColor {
return UIColor(red: 026.0/255, green: 188.0/255, blue: 156.0/255, alpha: 1.0)
}
public static var emerald: UIColor {
@itsthejb
itsthejb / archive.sh
Created March 2, 2014 01:26
XCTool Workflow for Archive
cd $WORKSPACE
rm -rf Build
security unlock-keychain -p '<password>' ~/Library/Keychains/login.keychain
agvtool -noscm new-version -all "$BUILD_NUMBER"
/usr/local/bin/xctool -workspace <workspace>.xcworkspace -scheme <scheme> -sdk 'iphoneos' clean archive -archivePath Build/<target-name>
/usr/bin/xcodebuild -exportArchive -exportProvisioningProfile <profile-name> -archivePath Build/<target-name>.xcarchive/ -exportPath Build/<target-name>.ipa > /dev/null
@itsthejb
itsthejb / EXPMatches+match.h
Created March 25, 2014 13:41
Expecta match string with regular expression
//
// EXPMatches+match.h
// Created by Jonathan Crooke on 25/03/2014.
//
#import "Expecta.h"
/**
* Expect string to match regular expression
*/
@itsthejb
itsthejb / gist:9917732
Last active August 29, 2015 13:57
Obj-C "Safe" object equality, whereby IS_EQUAL(nil,nil) == YES
#define IS_EQUAL(x,y) ((x && [x isEqual:y]) || (!x && !y))
@itsthejb
itsthejb / UIPageViewControllerEndlessDataSource.h
Created April 2, 2014 20:45
UIPageViewControllerEndlessDataSource: provides an 'endlessly' scrolling wrapper for `UIPageViewControllerDataSource`. Is also rather simpler to set up.
//
// UIPageViewControllerEndlessDataSource.h
// Created by Jonathan Crooke on 02/04/2014.
//
#import <UIKit/UIKit.h>
/**
* This data source protocol provides a wrapper for `UIPageViewControllerDataSource`
*/
@itsthejb
itsthejb / check-focus-expecta.sh
Created April 7, 2014 14:15
Pre-commit hook Grep for focussed Specta tests
#!/bin/bash
GREP_OUTPUT=`grep -R 'fdescribe(\|fcontext(\|fexample(\|fspecify(' Tests`
if [ ! -z "$GREP_OUTPUT" ]; then
echo "Remove focussed specs before commiting."
echo $GREP_OUTPUT
exit 1
fi