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: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 / 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: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 / 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:4953742
Created February 14, 2013 15:59 — forked from alloy/gist:4952606

Obviously, the simplest solution would be for the client to share their account details or add us as ‘team admin’, but that is not what this is about.

  1. [Add us to your iOS Developer Program as ‘team member’.][1]
  2. [Create a ‘Distribution Certificate’, if you haven’t got one already.][2]
  3. [Create a ‘App Store Distribution Provisioning Profile’.][3]
  4. [Export the ‘Distribution Certificate’ assets and send the export and password to us.][4] (For security sake, it’s a good idea to send us the password via other means than the exported certificate. E.g. by phone/SMS.)
@timd
timd / gist:5124491
Created March 9, 2013 15:23
A Javascript bookmarklet to post links to Pinboard. Adds the currently-selected text on the page in quotes as the bookmark's description.
javascript:q=location.href;if(document.getSelection){d%20=%20'"'%20+%20document.getSelection()%20+%20'"';}else{d='';};p=document.title;void(open('https://pinboard.in/add?showtags=yes&url='+encodeURIComponent(q)+'&description='+encodeURIComponent(d)+'&title='+encodeURIComponent(p),'Pinboard','toolbar=no,scrollbars=yes,width=750,height=700'));
@timd
timd / gist:5141930
Last active December 14, 2015 20:09
Assume Xcode project file structure like:
Project/
- project.xcworkspace
- project.xcodeproj
- Project/
- assets/
- data/
- css/
- html/
@timd
timd / SFOAuthProcess
Created July 1, 2013 10:33
A basic Salesforce OAuth login process using the Salesforce iOS SDK, implemented as a single standalone view controller
//
// SFAuthDemoViewController.m
//
// Created by Tim Duckett on 19/06/2013.
// Copyright (c) 2013 Charismatic Megafauna Ltd. All rights reserved.
//
#import "SFAuthDemoViewController.h"
#import "SFAccountManager.h"
#import "SFRestAPI.h"
@timd
timd / draggableUicvHack
Created July 16, 2014 15:27
A draggable UICollectionViewCell hack
(void)handlePan:(UIPanGestureRecognizer *)panRecognizer {
CGPoint locationPoint = [panRecognizer locationInView:self.collectionView];
if (panRecognizer.state == UIGestureRecognizerStateBegan) {
NSIndexPath indexPathOfMovingCell = [self.collectionView indexPathForItemAtPoint:locationPoint];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPathOfMovingCell];
UIGraphicsBeginImageContext(cell.bounds.size);
@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()