Skip to content

Instantly share code, notes, and snippets.

View jdriscoll's full-sized avatar

Justin Driscoll jdriscoll

View GitHub Profile
# 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
@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 = {}
@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 / 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 / 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 / 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
});