Skip to content

Instantly share code, notes, and snippets.

Christopher Bowns cbowns

Block or report user

Report or block cbowns

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cbowns / UIImage+MPImageNamedNilCheck.h
Created May 7, 2012
A nil-checking [UIImage imageNamed:] category. Uses thrown and caught exceptions to break into the debugger if you have exception breakpoints turned on. Use #define UIIMAGE_IMAGENAMED_NILCHECK 0 to turn off the throw-and-catch.
View UIImage+MPImageNamedNilCheck.h
// UIImage+MPImageNamedNilCheck.h
// Created by Christopher Bowns on 5/6/12.
// Copyright (c) 2012 Mechanical Pants Software. All rights reserved.
#import <UIKit/UIKit.h>
@interface UIImage (MPImageNamedNilCheck)
cbowns / UIApplication+NetworkActivity.h
Created Sep 19, 2012
View UIApplication+NetworkActivity.h
// UIApplication+NetworkActivity.h
// Created by Christopher Bowns on 4/11/12.
// Original implementation:
// Copyright (c) 2012 Mechanical Pants Software
#import <UIKit/UIKit.h>
cbowns / gist:2992390
Created Jun 26, 2012
Helper function for moving UIView/CALayer centers when changing anchorPoints
View gist:2992390
- (CGPoint)center:(CGPoint)oldCenter movedFromAnchorPoint:(CGPoint)oldAnchorPoint toAnchorPoint:(CGPoint)newAnchorPoint withFrame:(CGRect)frame;
CGPoint anchorPointDiff = CGPointMake(newAnchorPoint.x - oldAnchorPoint.x, newAnchorPoint.y - oldAnchorPoint.y);
CGPoint newCenter = CGPointMake(oldCenter.x + (anchorPointDiff.x * frame.size.width),
oldCenter.y + (anchorPointDiff.y * frame.size.height));
return newCenter;
cbowns / gist:2963045
Created Jun 21, 2012
UIDevice System Version Preprocessor Macros
View gist:2963045
System Versioning Preprocessor Macros via
if (UIDeviceSystemVersionLessThan(@"4.0")) {
// code for pre-4.0 devices.
if (UIDeviceSystemVersionGreaterThanOrEqualTo(@"3.1.1")) {
// Code for 3.1.1.
cbowns / IPInsetLabel.h
Created May 25, 2012 — forked from marcoarment/IPInsetLabel.h
IPInsetLabel: a simple UILabel subclass that adds padding insets and auto-height-resizing
View IPInsetLabel.h
// IPInsetLabel.h
// Instapaper
// Created by Marco Arment on 7/23/11.
// Copyright 2011 Instapaper LLC, released to the public domain.
#import <UIKit/UIKit.h>
cbowns / gist:2706112
Created May 15, 2012
Nil-guarded dictionary key-value retrieval for JSON responses
View gist:2706112
// JSON is dangerous, take one of these!
+ (id)nullGuardedDict:(NSDictionary *)dict valueForKey:(NSString *)key;
id obj = nil;
obj = [dict valueForKey:key];
if (obj == [NSNull null]) {
obj = nil;
return obj;
cbowns / backup_growl.rb
Created May 15, 2012 — forked from bewebste/backup_growl.rb
Script to display Time Machine progress messages as Growl notifications
View backup_growl.rb
#Just run this script in a terminal window, leaving the window open in the
#background so it can continue to process messages.
IO.popen("syslog -F \'$(Sender): $Message\' -w -k Sender") { |syslogIO|
while (inputString = syslogIO.gets) do
escapedString = inputString.gsub("'", "\\'")
`/usr/local/bin/growlnotify -a 'Time Machine' -t 'Time Machine' -m '#{escapedString}'`
View gist:2588474
// Please don’t do this.
// Need to change UISearchBar’s cancel button text?
// Well, there’s no API for that.
// (Sorry UIKit.)
UISearchBar *searchBar = [self.searchDisplayController searchBar];
for (UIView *view in [searchBar subviews]) { … <left as an exercise to the adventurous> }
cbowns / gist:2491479
Created Apr 25, 2012
Public Spaces near Moscone West
View gist:2491479

WWDC 2012 sold out in a matter of hours. San Francisco has lots of privately owned public open spaces during business hours. WWDC Spaces is a place for us to organize a list of good ones near Moscone so developers looking to escape Moscone and non-attendees alike can gather. Leave a comment here and I'll add them to the wiki with links.

SPUR has a list of public spaces downtown. Have you been to one? Leave a comment with info about it! (I can’t visit all of these, though I’m going to try.)

  • 101 Second Street. Yelp.
  • NoiseBridge, 2169 Mission St (Mission between 17th and 18th).
cbowns / api_keys.rb
Created Feb 21, 2012
A script for Xcode 4.x to use API keys stored in ~/.api_keys and insert them into your app bundle’s Info.plist (instead of committing them to a repository)
View api_keys.rb
# An API keys script written by Patrick Gibson (@patr1ck) and Christopher Bowns (@cbowns)
# This script sets API keys in your app's Info.plist from an .api_keys file you keep in your home directory (~/.api_keys)
# This allows you to not check API keys into your source control system,
# or for different developers to use different keys without needing to patch their working copies.
# Installation directions:
1. Create a Run Script build phase in your Xcode project before Compile Sources
2. Copy and paste this whole script in.
3. Create or modify your .api_keys file to hold your API keys
You can’t perform that action at this time.