Skip to content

Instantly share code, notes, and snippets.

View timd's full-sized avatar
💭
Typing all the right things, not necessarily in the right order

Tim Duckett timd

💭
Typing all the right things, not necessarily in the right order
View GitHub Profile
@timd
timd / gist:4953078
Last active December 13, 2015 18:08
Example of Kiwi test involving Magical Record and view controllers
#import "Kiwi.h"
#import "MyController.h"
#import "Record.h"
#import "MyModel.h"
// Category on class under test to expose private properties / methods
@interface MyController(MyTest)
@property (nonatomic, strong) NSDictionary *aDictionary;
@property (weak, nonatomic) IBOutlet UIButton *aButton;
@timd
timd / gist:4953071
Created February 14, 2013 14:11
Example of Kiwi test involving Magical Record managed objects and view controllers
#import "Kiwi.h"
#import "MyController.h"
#import "Record.h"
#import "MyModel.h"
// Category on class under test to expose private properties / methods
@interface MyController(MyTest)
@property (nonatomic, strong) NSDictionary *aDictionary;
@property (weak, nonatomic) IBOutlet UIButton *aButton;
@timd
timd / randomDataCreator.rb
Created December 11, 2012 17:45
An example random data creator
#!/bin/env ruby
# encoding: utf-8
require "faker"
require 'random_data'
require 'json'
randomPostcode = Random.uk_post_code
randomAddress = Random.address_line_1 + " " + Random.address_line_2 + " " + randomPostcode
@timd
timd / gist:3498514
Created August 28, 2012 14:31
Update build number
# Assumes that you tag versions with the version number (e.g., "1.1") and then the build number is
# that plus the number of commits since the tag (e.g., "1.1.17")
echo "Updating version/build number from git..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
# increment the build number (ie 115 to 116)
versionnum=`git describe | awk '{split($0,a,"-"); print a[1]}'`
buildnum=`git describe | awk '{split($0,a,"-"); print a[1] "." a[2]}'`
@timd
timd / gist:3498466
Created August 28, 2012 14:24
Provide build number for source code
# build data file that is included in the source
# so we can automatically report Git repo information
# in the application.
cd ${PROJECT_DIR}
gitDataFile="gitDataAutoGenerated.h"
buildDate=`date "+%F %H:%M:%S"`
currentBranch=`git rev-parse --abbrev-ref HEAD`
lastCommitHash=`git log --pretty=format:"%h" -1`
lastCommitDate=`git log --pretty=format:"%ad" --date=short -1`
@timd
timd / gist:3293993
Created August 8, 2012 10:12
Adding UIGestureRecognizer to UIWebView
Add gesture recognizer to UIWebView:
UITapGestureRecognizer *tapCatcher = [[UITapGestureRecognizer alloc] init];
[tapCatcher setNumberOfTapsRequired:1];
[tapCatcher setNumberOfTouchesRequired:1];
[tapCatcher setDelegate:self];
[tapCatcher addTarget:self action:@selector(didTapOnView)];
[self.webView addGestureRecognizer:tapCatcher];
@timd
timd / ios-font-list
Created August 3, 2012 10:17
List of onboard iOS fonts in iOS5.1 / Xcode 4.4
Thonburi
"Thonburi-Bold",
Thonburi
Snell Roundhand
"SnellRoundhand-Bold",
"SnellRoundhand-Black",
SnellRoundhand
Academy Engraved LET
@timd
timd / .gitignore
Created August 2, 2012 07:34 — forked from Abizern/.gitignore
Global git ignore file
# Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
@timd
timd / gist:2317906
Created April 6, 2012 07:24
Simulator-safe method for using the hardware camera on iOS Simulators
-(void)takeSimulatorSafePhotoWithPopoverFrame:(GCRect)popoverFrame {
// Prerequisites:
//
// Class requires two properties to be defined:
//
// @property (nonatomic, strong) UIImagePickerController *imagePicker;
// @property (nonatomic) BOOL usingPopover;
// Load the imagePicker
@timd
timd / scrollViewDidEndDragging.m
Created February 16, 2012 10:02
scrollViewDidEndDragging:willDecelerate:
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
CGFloat contentOffsetY = scrollView.contentOffset.y;
if (contentOffsetY < -60.0) {
[self displayActivitySpinner];
}
}