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 / swiftFunctionsForms
Last active November 19, 2015 21:22
THE MANY FORMS OF SWIFT FUNCTIONS – A CHEATSHEET
THE MANY FORMS OF SWIFT FUNCTIONS – A CHEATSHEET
================================================
No parameters, no return value
func foo()
called with
foo()
@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 / 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];
}
}
@timd
timd / swipeCell.m
Created February 15, 2012 12:41
initWithStyle:reuseidentifier:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
// Create the top view
_topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, 80)];
[_topView setBackgroundColor:[UIColor whiteColor]];
@timd
timd / didSwipeLeftInCell.m
Created February 15, 2012 12:39
didSwipeLeftInCell:
-(IBAction)didSwipeLeftInCell:(id)sender {
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView animateWithDuration:1.0 animations:^{
[_topView setFrame:CGRectMake(-10, 0, 320, 80)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 animations:^{
[_topView setFrame:CGRectMake(0, 0, 320, 80)];
}];
}];
}