Skip to content

Instantly share code, notes, and snippets.

View jdriscoll's full-sized avatar

Justin Driscoll jdriscoll

View GitHub Profile
@jdriscoll
jdriscoll / NSString+Inflections.m
Created October 3, 2012 18:07
NSString+Inflections
// Inspired by suggestion to use NSScanner: http://stackoverflow.com/questions/1918972/camelcase-to-underscores-and-back-in-objective-c
#import "NSString+Inflections.h"
@implementation NSString (Inflections)
- (NSString *)underscore
{
NSScanner *scanner = [NSScanner scannerWithString:self];
scanner.caseSensitive = YES;
@jdriscoll
jdriscoll / NSString+UUID.m
Created September 26, 2012 13:53
NSString+UUID
#import "NSString+UUID.h"
@implementation NSString (UUID)
+ (NSString *)UUIDString
{
CFUUIDRef UUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, UUID);
CFRelease(UUID);
return (__bridge_transfer NSString *)string;
@jdriscoll
jdriscoll / gist:3743534
Created September 18, 2012 14:48
Repeating work on background thread with GCD and blocks
- (void)doStuff
// Do stuff on main thread
dispatch_async(self.queue, ^{
// Do stuff on background thread
// self.queue is a serial queue stored as a property on this object
dispatch_async(dispatch_get_main_queue(), ^{
// Do stuff on main thread
});
@jdriscoll
jdriscoll / gist:3612221
Created September 3, 2012 18:52
Sublime Text 2 User Prefs
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
@jdriscoll
jdriscoll / iA Writer.css
Created December 2, 2011 17:04
Modified iA Writer style for Marked
body { color: #222; font: normal normal 400 100%/1.5em georgia,serif; margin: 3em auto; padding: 0 3em; max-width: 46em }
a:link { color: #3366CC }
a:visited { color: #224488 }
blockquote,ol,p,ul { display: block; margin: 0 0 1.5em }
blockquote { border-left: solid .1em #E4E4E4; color: #919191; padding: 0 1.5em 0 1.4em }
code { font: normal normal 87.5%/1.71428571em monospace,sans-serif }
img { display: block; margin: 1.5em auto }
pre { display: block; font: normal normal 87.5%/1.71428571em monospace,sans-serif; margin: 1.71428571em }
h1,h2,h3,h4,h5,h6 { font-weight: 400 }
h1 { font-size: 225%; line-height: 1.3334em; margin: 0 0 .1666em }
@jdriscoll
jdriscoll / build.sh
Created October 28, 2011 19:17
Xcode build script (Apple generic versioning tool)
#!/usr/bin/env sh
if git diff-index --quiet HEAD --; then
agvtool next-version -all
agvtool new-marketing-version "$1"
buildnum=`agvtool vers -terse`
git add .
git commit -m "New build: $1 ($buildnum)"
if [ "$2" = "--release" ]; then
@jdriscoll
jdriscoll / price_watcher.rb
Created August 13, 2011 14:21
Silly-simple Amazon price watching script in Ruby
require 'open-uri'
require 'hpricot'
MINUTES_BETWEEN_CHECKS = 15
URLS = ['http://www.amazon.com/Programming-Ruby-1-9-Pragmatic-Programmers/dp/1934356085/',
'http://www.amazon.com/Ultimate-Hitchhikers-Guide-Galaxy/dp/0345453743/']
HISTORY_COUNT = 50
CURRENT_PRICE_ELEMENT = '.priceLarge'
prices = {}
from django.db import models
from imagekit.models import ImageModel
class Photo(ImageModel):
name = models.CharField(max_length=100)
original_image = models.ImageField(upload_to='photos')
num_views = models.PositiveIntegerField(editable=False, default=0)
class IKOptions:
# This inner class is where we define the ImageKit options for the model
*.pbxproj -crlf -diff -merge
import sys
import time
import urllib
import urllib2
from django.core.management import setup_environ
# Make we're actually importing and activating the correct settings file here
import settings
setup_environ(settings)