Skip to content

Instantly share code, notes, and snippets.

View itsthejb's full-sized avatar

Jonathan Crooke itsthejb

View GitHub Profile
@itsthejb
itsthejb / Decorator.m
Last active November 8, 2015 10:33
ObjC Simple Decorator
@interface Decorator : NSProxy
@property (strong, readonly) id decoratedObject;
- (id)initWithDecoratedObject:(id)decoratedObject;
@end
@interface Decorator ()
@property (strong, readwrite) id decoratedObject;
@end
@implementation Decorator
@itsthejb
itsthejb / Forward.h
Created July 2, 2015 10:54
Child property forwarding
/**
* Forward any unimplemented methods to a particular object property
*/
#define FORWARD_TO_PROPERTY(PROPERTY) \
- (void)forwardInvocation:(NSInvocation *)anInvocation { \
if ([super respondsToSelector:anInvocation.selector]) { \
[super forwardInvocation:anInvocation]; \
} else { \
[anInvocation invokeWithTarget:PROPERTY]; \
} \
@itsthejb
itsthejb / ComponentKitTestLib.podpsec
Last active August 29, 2015 14:19
Edit of ComponentKitTestLib.podpsec
Pod::Spec.new do |s|
s.name = "ComponentKitTestLib"
s.version = "0.10"
s.summary = "A React-inspired view framework for iOS"
s.homepage = "https://componentkit.com"
s.license = 'BSD'
s.source = { :git => "https://github.com/facebook/ComponentKit.git", :tag => s.version.to_s }
s.platform = :ios, '7.0'
s.requires_arc = true
s.source_files = 'ComponentKitTestLib/*.h', 'ComponentKitTestLib/*.m', 'ComponentKitTestLib/*.mm'
@itsthejb
itsthejb / gist:dd416bed8500d7803054
Created March 18, 2015 15:39
Conditional breakpoint for particular system NSLog() call
1: name = 'NSLog', locations = 2, resolved = 2, hit count = 18
Condition: [(NSString*) $arg1 hasPrefix:@"Unbalanced calls"]
2.1: where = CFNetwork`NSLog, address = 0x0000000106341372, resolved, hit count = 17
2.2: where = Foundation`NSLog, address = 0x0000000106d312d3, resolved, hit count = 1
@itsthejb
itsthejb / gist:c4e7a41d0d8c290190ad
Last active August 29, 2015 14:17
-[UIViewController _setViewAppearState:isAnimating:] Reverse Engineer Arguments
-[UIViewController _setViewAppearState:(state) isAnimating:(BOOL)]
print (int) $arg3
state:
0: did disappear
1: will appear
2: did appear
3: will disappear
@itsthejb
itsthejb / pixel.h
Created December 17, 2014 10:16
Pixel boundary Quartz drawing macros
#define pixel_points(pixelWidth, scale) (pixelWidth / scale)
#define pixel_offset(pixelWidth, scale) (fmod(pixelWidth, 2) ? 0.5 : 0)
#define pixel_round(pos, offset) (lround(pos) + (lround(pos) > pos ? -offset : +offset))
@itsthejb
itsthejb / Flat UI.clr
Last active August 29, 2015 14:09
http://flatuicolors.com/ as an OS X Colour Palette
@itsthejb
itsthejb / Forward.m
Created July 4, 2014 13:29
DataSource / Delegate generic message forwarding
#pragma mark Delegate / data source message forwarding
- (BOOL)respondsToSelector:(SEL)aSelector {
return ([super respondsToSelector:aSelector] ||
[self.dataSource respondsToSelector:aSelector] ||
[self.delegate respondsToSelector:aSelector]);
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
@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
@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`
*/