Skip to content

Instantly share code, notes, and snippets.

View jemerick's full-sized avatar

Jason Emerick jemerick

View GitHub Profile
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other
# stuff too? No support for SuperColumns, but that should be easy enough to add.
import bisect
import copy
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn
class SSTable(object):
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
"""
Some simple utilities to read the magic bytes from the beginning of a
file and determine whether the file meets certain criteria (e.g., contains
JPEG image data).
"""
import array
from operator import eq
IMAGE_MAGIC_DATA = (
"""
Simple timer class. Example usage:
t = Timer()
for url in ('http://www.google.com/', 'http://www.yahoo.com/'):
t.start('fetch url')
content = urllib.urlopen(url).read()
t.stop('fetch url')
t.start('reorder bytes')
bytes = list(content)
import os, sys
sys.path.append('/var/django/ihome')
# redirect print statements to the apache log
sys.stdout = sys.stderr
os.environ['DJANGO_SETTINGS_MODULE'] = 'ihome.settings'
import django.core.handlers.wsgi
// Provides a device_scale class on iOS devices for scaling user
// interface elements relative to the current zoom factor.
//
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari
// Copyright (c) 2010 37signals.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@jemerick
jemerick / Folder Preferences
Created October 2, 2011 20:07 — forked from chrisyour/Folder Preferences
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@jemerick
jemerick / json-response.py
Created October 6, 2011 18:11 — forked from leah/json-response.py
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
#!/bin/bash
# note: this won't work too well with filenames/directories with spaces in them
compressresource() {
gzip -c9 "$1" > "$1.gz"
touch -c --reference="$1" "$1.gz"
echo "Compressed: $1 > $1.gz"
}
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {
private final Context context;
private final LayoutInflater inflater;