Skip to content

Instantly share code, notes, and snippets.

View irace's full-sized avatar

Bryan Irace irace

View GitHub Profile
@irace
irace / BITwitterAuthenticator.h
Created August 9, 2012 21:09
Objective-C Twitter three-legged authorization flow
//
// BITwitterAuthenticator.h
//
// Created by Bryan Irace on 8/9/12.
// http://bryan.mit-license.org
//
@interface BITwitterAuthenticator : NSObject
@property (nonatomic, copy) NSString *OAuthConsumerToken;
@irace
irace / gist:3349415
Created August 14, 2012 13:51
Micro-templating for iOS
// https://github.com/jasonmoo/t.js, http://news.ycombinator.com/item?id=4378578
static inline NSString *F(NSString *string, id object) {
NSMutableString *result = [[string mutableCopy] autorelease];
void (^replace)(NSMutableString *, NSString *, id) =
^ (NSMutableString *string, NSString *key, id value) {
NSString *stringValue = [value isKindOfClass:[NSNumber class]]
? [NSString stringWithFormat:@"%@", (NSNumber *)value] : value;
@irace
irace / gist:3363569
Created August 15, 2012 20:54
Generate iOS Localizable.strings format from PO file
#!/usr/bin/python
import sys
if __name__ == '__main__':
filename = sys.argv[1];
input = open(filename)
output = open(filename + '.out', 'w')
for line in input:
@irace
irace / gist:3366283
Last active October 8, 2015 17:38
Git cheat sheet
# Checkout remote branch
git checkout -t origin/<branch>
# Delete branch (local, remote)
git branch -d <branch>
git push origin --delete <branch>
# Tagging
git fetch --tags git@github.com:jstn/JXHTTP.git
git tag -f 1.0.0 # Move a tag to the latest commit
@irace
irace / gist:3366301
Created August 16, 2012 03:28
NPM cheat sheet
# Update NPM version
sudo npm update npm -g
@irace
irace / gist:3366303
Created August 16, 2012 03:29
Virtualenv cheat sheet
# Install
sudo easy_install virtualenv
# Create a new environment:
cd ~/project
virtualenv env
# Activate
. env/bin/activate
@irace
irace / gist:3506126
Created August 29, 2012 02:12
Why develop a native mobile application?

Published May 17, 2011 based on experiences building GS Research for iPad. Updates will be additive as the original article will be kept intact for posterity.

UPDATE (9/22/2012): Facebook developer Tobie Langel has posted some interesting feedback to a W3C mailing list in the aftermath of rewriting Facebook's failed web-based iOS application.

UPDATE 2 (11/28/2012): And now my app (Tumblr) is fully native as well.


Audience

Interested in building a mobile application but not sure where to start? There are a dizzying number of frameworks and platforms all currently vying to be your answer. In order to decide which is right for you, it’s important to understand the pros and cons of the different mobile development and deployment strategies available today.

@irace
irace / gist:3660804
Created September 6, 2012 22:16
Symbolicate iOS crash logs
mdimport ~/Library/Developer/Xcode/Archives/
/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash ~/Desktop/Tumblr_2012-09-06-172029_.crash
@irace
irace / BIWebViewDelegate.m
Created September 10, 2012 02:51
JavaScript/native bridge for iOS's UIWebView
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSString *urlString = [[request URL] absoluteString];
if ([urlString hasPrefix:@"js:"]) {
NSString *jsonString = [[[urlString componentsSeparatedByString:@"js:"] lastObject]
stringByReplacingPercentEscapes];
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
@irace
irace / gist:3828834
Created October 3, 2012 18:29
Basic Node.js screen-scraping
var express = require('express')
, app = express()
, jsdom = require('jsdom');
app.set('views', __dirname);
app.get('/', function(request, response) {
jsdom.env({
html: 'http://bryanirace.com',
scripts: ['http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js'],