Skip to content

Instantly share code, notes, and snippets.

View phatblat's full-sized avatar

Ben Chatelain phatblat

View GitHub Profile
@phatblat
phatblat / gist:1185469
Created September 1, 2011 04:41 — forked from shazron/gist:1167362
auto-ingest
import java.io.*;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.net.ssl.HttpsURLConnection;
public class Autoingestion
{
@phatblat
phatblat / heroku-node-init.sh
Created January 31, 2012 22:28
Bash script to initialize an OS X box for local development of node app on heroku
#!/bin/bash
NODE_VERSION=0.4.7
NPM_VERSION=1.0.94
# Save script's current directory
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#cd "${DIR}"
#

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

/*
* Bookmarklet for viewing source in iPad Safari
*/
javascript:(function(){
var w = window.open('about:blank'),
s = w.document;
s.write('<!DOCTYPE html><html><head><title>Source of ' + location.href + '</title><meta name="viewport" content="width=device-width" /></head><body></body></html>');
s.close();
@phatblat
phatblat / UIDeviceHardware.h
Created September 27, 2012 02:43 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@phatblat
phatblat / AFHTTPClient.patch
Created November 19, 2012 21:03
A path for AFNetworking to prevent repeated query string parameters from having the "name" changed
diff --git a/ios/KPServiceTests/Library/AFNetworking/AFHTTPClient.m b/ios/KPServiceTests/Library/AFNetworking/AFHTTPClient.m
index 96a70609f198d7549497cbb37f777e3076ac898a..ad8df8f13e2dd3e4c9c9cef5eee7eadfa1809754 100755
--- a/ios/KPServiceTests/Library/AFNetworking/AFHTTPClient.m
+++ b/ios/KPServiceTests/Library/AFNetworking/AFHTTPClient.m
@@ -156,7 +156,7 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
}];
} else if([value isKindOfClass:[NSArray class]]) {
[value enumerateObjectsUsingBlock:^(id nestedValue, NSUInteger idx, BOOL *stop) {
- [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
+ [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, nestedValue)];
@phatblat
phatblat / gist:4119062
Created November 20, 2012 16:33
Sqlite command to generate Date in RFC 1123 format
select
case cast (strftime('%w', datetime()) as integer)
when 0 then 'Sun'
when 1 then 'Mon'
when 2 then 'Tue'
when 3 then 'Wed'
when 4 then 'Thu'
when 5 then 'Fri'
else 'Sat' end ||
strftime(', %d ', datetime()) ||
@phatblat
phatblat / Prefix.pch
Created December 4, 2012 04:06
Convert Xcode build setting to runtime ObjC string
// Pass Xcode build-time CONFIGURATION variable to runtime as an Objective-C string
#define QUOTE(name) #name
#define STR(macro) QUOTE(macro)
#define CONFIG_NAME_CSTR STR(CONFIGURATION)
#define CONFIG_NAME [NSString stringWithCString:CONFIG_NAME_CSTR encoding:NSUTF8StringEncoding]
@phatblat
phatblat / gist:5432046
Created April 22, 2013 02:21
Bash script to extract the repo name out of a URL
#!/bin/bash
repo_url=git@github.com:phatblat/dotfiles.git
repo=${repo_url##*/}
echo ${repo%%.*}