Skip to content

Instantly share code, notes, and snippets.

View subdigital's full-sized avatar

Ben Scheirman subdigital

View GitHub Profile
@subdigital
subdigital / test.rb
Created October 22, 2012 13:05
Running objective-c tests from the command line (with color)
# based on https://gist.github.com/3349345
# Thanks, @alloy!
#
# To get your project ready for this, you'll have to create a scheme for your unit test project, make sure run is checked in
# the build step, and then delete the Test Host setting.
# Also, make sure you have the colored and open4 gems installed.
require 'rubygems'
require 'colored'
require 'pathname'
@subdigital
subdigital / gist:3139633
Created July 18, 2012 23:18
Wisdom of the ages
Scott Burton Blows Goats.
@subdigital
subdigital / gist:2766667
Created May 22, 2012 04:50
Appending ?token=<auth_token> to the query params in AFNetworking for every request
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
path:(NSString *)path
parameters:(NSDictionary *)parameters {
NSString *token = [[PSCredentialRepository sharedRepository] authenticationToken];
if ([method isEqualToString:@"POST"] || [method isEqualToString:@"PUT"]) {
if ([path rangeOfString:@"token="].location == NSNotFound) {
NSString *separator = @"&";
if ([path rangeOfString:@"?"].location == NSNotFound) {
separator = @"?";
}
@subdigital
subdigital / gist:2627542
Created May 7, 2012 12:40
Formatting JSON on the command line
#! /bin/sh
# Usage: curl http://some_url/that_returns.json | format_json
python -c "import sys, json; print json.dumps(
json.load(sys.stdin), sort_keys=True, indent=4)"
@subdigital
subdigital / Bookmarkserialization.m
Created March 11, 2012 19:01
Property List Serialization
// Bookmark.h
@interface Bookmark : NSObject <NSCoding>
@property (nonatomic, copy) NSString *label;
@property (nonatomic, copy) NSString *url;
@end
// Bookmark.m
@subdigital
subdigital / gist:1988704
Created March 6, 2012 20:10
My less wordy version of www.fixradarorgtfo.com

Radar needs some serious love. I'd really like it if you could spend some time improving:

  • Making radars publicly visible (or at least to developers)
  • Make it so I can easily dupe or "vote" for a bug
  • See more discussion from other users, engineers
  • Updated interface that isn't so 2001-ish.

The fact openradar even exists is reason enough to be fixing this stuff.

Love your software, but Radar needs some love!

@subdigital
subdigital / nested_factories.m
Created February 21, 2012 18:17
factories for an inheritance tree
@interface Person : NSObject
@property (copy) NSString *name;
@end
@interface Customer : Person
@property (copy) NSString *status;
@end
[MFFactory defineFactoryForClass:[Person class] withBlock:^(id p){
@subdigital
subdigital / factories.m
Created February 21, 2012 14:56
A test object factory potential implementation
// Given class Customer
//defining factories
[MFFactory defineFactoryForClass:[Customer class] withBlock:^(MFFactory *customer) {
[customer sequenceFor:@"name" do:^(int i) {
return @"Test Customer %d";
}];
customer.status = @"active";
@subdigital
subdigital / UIButtonCHButtonFlip.h
Created October 4, 2011 14:41
Flipping UIButton
@interface UIButton (CHFlipButton)
+ (UIView *)flipButtonWithFirstImage:(UIImage *)firstImage
secondImage:(UIImage *)secondImage
firstTransition:(UIViewAnimationTransition)firstTransition
secondTransition:(UIViewAnimationTransition)secondTransition
animationCurve:(UIViewAnimationCurve)curve
duration:(NSTimeInterval)duration
target:(id)target
selector:(SEL)selector;
@subdigital
subdigital / UIButtonCHButtonFlip.h
Created October 4, 2011 14:34
Flipping UIButton
@interface UIButton (CHFlipButton)
+ (UIView *)flipButtonWithFirstImage:(UIImage *)firstImage
secondImage:(UIImage *)secondImage
firstTransition:(UIViewAnimationTransition)firstTransition
secondTransition:(UIViewAnimationTransition)secondTransition
animationCurve:(UIViewAnimationCurve)curve
duration:(NSTimeInterval)duration
target:(id)target
selector:(SEL)selector;