Skip to content

Instantly share code, notes, and snippets.

View jdriscoll's full-sized avatar

Justin Driscoll jdriscoll

View GitHub Profile
@jdriscoll
jdriscoll / keybase.md
Last active August 29, 2015 13:58
Proof!

Keybase proof

I hereby claim:

  • I am jdriscoll on github.
  • I am jdriscoll (https://keybase.io/jdriscoll) on keybase.
  • I have a public key whose fingerprint is AFDB 03DF A37F 194A B15B FEB6 A478 146D 9D51 5207

To claim this, I am signing this object:

@jdriscoll
jdriscoll / MutableObjInSet.m
Last active August 29, 2015 14:00
Mutable objects in set
#import <Foundation/Foundation.h>
void logIt(NSSet *set) {
NSLog(@"set: %@", set);
for (id object in set) {
NSLog(@"element with hash: %lu", (unsigned long)[object hash]);
}
}
int main(int argc, char *argv[]) {
@jdriscoll
jdriscoll / arrayDiff.m
Last active August 29, 2015 14:01
Get differences between two NSArrays (for animating table view changes)
void arrayDiff(NSArray *array1, NSArray *array2, NSSet **objectsToAdd, NSSet **objectsToRemove, NSSet **objectsInBoth) {
if (array1 == nil) {
*objectsToAdd = [NSSet setWithArray:array2];
*objectsToRemove = [NSSet set];
*objectsInBoth = [NSSet set];
}
else if (array2 == nil) {
*objectsToAdd = [NSSet set];
*objectsToRemove = [NSSet setWithArray:array1];
@jdriscoll
jdriscoll / build.sh
Created July 25, 2014 14:10
AGVTool wrapper for Xcode projects
#!/usr/bin/env sh
if git diff-index --quiet HEAD --; then
agvtool next-version -all
if [ $# -eq 1 ]
then
agvtool new-marketing-version "$1"
fi
@jdriscoll
jdriscoll / Queries.sql
Last active August 29, 2015 14:22
Load SQL queries from text file
-- all_things
SELECT * FROM things
-- thing_with_id
SELECT * FROM things WHERE id = :id
# Unit testing for AppEngine
import os
import sys
import unittest
# Path to AppEngine library (platform specific)
SDK_PATH = os.path.realpath('/usr/local/google_appengine/')
EXTRA_PATHS = [
SDK_PATH,
from django.contrib.sites.models import Site
from django.core.urlresolvers import set_script_prefix
class ScriptPrefixMiddleware(object):
""" Sets up url resolvers to return absolute urls
"""
def process_request(self, request):
set_script_prefix("http://%s" % Site.objects.get_current().domain)
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)
*.pbxproj -crlf -diff -merge
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