Skip to content

Instantly share code, notes, and snippets.

# 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):
@gvangool
gvangool / vipy.sh
Created March 3, 2010 06:53 — forked from mmalone/vipy.sh
Simple shell script that locates a Python module and opens it in vi.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: vipy <python module>"
exit 1
fi
MODULE_LOCATION=`python -c "import $1; print $1.__file__.rstrip('c')"`
if [ -z $MODULE_LOCATION ]; then
@gvangool
gvangool / daterange.py
Created August 11, 2009 13:17 — forked from zacharyvoase/daterange.py
Like xrange() for datetime objects.
# -*- coding: utf-8 -*-
"""
Example Usage
=============
>>> import datetime
>>> start = datetime.date(2009, 6, 21)
>>> g1 = daterange(start)
@gvangool
gvangool / daemonextension.py
Created July 13, 2009 13:51 — forked from screeley/daemonextension.py
Django Management Command for starting a daemon.
"""
Copyright (c) 2009, Sean Creeley
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
@gvangool
gvangool / storage.py
Created June 15, 2009 06:27 — forked from leah/storage.py
An S3 storage backend
from mimetypes import guess_type
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import Storage
from django.utils.encoding import iri_to_uri
import re
try:
import S3
except ImportError:
raise ImproperlyConfigured, "Could not load amazon's S3 bindings.\
@gvangool
gvangool / CouchObject.py
Created June 15, 2009 06:12 — forked from leah/CouchObject.py
Convert between a CouchDB document and Python object.
class CouchObject(object):
'''
Convert between a CouchDB document and Python object.
Create Python objects while maintaining a schema-free database.
Define object properties without storing null fields.
'''
@property
def id(self):
return self._id
@gvangool
gvangool / gist:129962
Created June 15, 2009 06:11 — forked from simonw/gist:127850
Validate that an uploaded file is a PDF
# Django: validate that an uploaded file is a valid PDF
import pyPdf # from http://pybrary.net/pyPdf/
from pyPdf.utils import PdfReadError
class DocumentForm(forms.ModelForm):
pdf = forms.FileField()
class Meta:
model = Document
@gvangool
gvangool / ericflopsy.py
Created June 11, 2009 13:08 — forked from ericflo/ericflopsy.py
A simple way to interact with AMQPlib
"""
Copyright (c) 2008-2009, Nathan Borror, and modified heavily by Eric Florenzano
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this