Skip to content

Instantly share code, notes, and snippets.

View mlissner's full-sized avatar

Mike Lissner mlissner

View GitHub Profile
@mlissner
mlissner / queryset_generators.py
Created March 10, 2012 04:13 — forked from dbrgn/queryset_generators.py
Adds a date-based queryset generator
from datetime import datetime
from datetime import timedelta
def queryset_generator(queryset, chunksize=1000):
"""
Iterate over a Django Queryset ordered by the primary key
This method loads a maximum of chunksize (default: 1000) rows in its
memory at the same time while django normally would load all rows in its
memory. Using the iterator() method only causes it to not preload all the
@mlissner
mlissner / test.txt
Created September 2, 2014 15:32
Testing Gist Ownership Transfer
asdf
count | count
---------+--------
2590457 | 395389
@mlissner
mlissner / __init__.py
Created November 21, 2014 19:45
An attempt at nuking strftime in Django. Alas it also breaks Django.
import datetime
print "Now killing strftime."
class CleanDateTime(datetime.datetime):
def strftime(self, format):
raise NotImplemented(
"Strftime doesn't support dates prior to 1900 and as a "
"consequence CourtListener nukes them from the standard library. "
@mlissner
mlissner / __init__.py
Created November 24, 2014 18:40
Another attempt at nuking stftime.
import datetime
import warnings
class CleanDateTime(datetime.datetime):
def strftime(self, *args, **kwargs):
# warnings.warn('strftime is deprecated', DeprecationWarning,
# stacklevel=2)
return super(CleanDateTime, self).strftime(*args, **kwargs)
@mlissner
mlissner / keybase.md
Created December 4, 2014 22:03
Verifying my github for keybase.io

Keybase proof

I hereby claim:

  • I am mlissner on github.
  • I am mlissner (https://keybase.io/mlissner) on keybase.
  • I have a public key whose fingerprint is E64F 32B9 B2CE 993E 6D2A 60A5 DE79 459C D047 ACFE

To claim this, I am signing this object:

@mlissner
mlissner / celeryd
Created December 22, 2014 05:34
Mine.
start_workers () {
echo "Starting workers with command: "
echo " $CELERYD_MULTI start $CELERYD_NODES $DAEMON_OPTS \
--pidfile=\"$CELERYD_PID_FILE\" \
--logfile=\"$CELERYD_LOG_FILE\" \
--loglevel=\"$CELERYD_LOG_LEVEL\" \
--cmd=\"$CELERYD\" $CELERYD_OPTS"
$CELERYD_MULTI start $CELERYD_NODES $DAEMON_OPTS \
--pidfile="$CELERYD_PID_FILE" \
--logfile="$CELERYD_LOG_FILE" \
@mlissner
mlissner / admin.py
Created December 30, 2014 18:49
How do I make line 9 work?
from django.contrib import admin
from alert.donate.models import Donation
from alert.userHandling.models import UserProfile
class DonorInline(admin.TabularInline):
model = UserProfile.donation.through
max_num = 1
raw_id_fields = ('donation',)
@mlissner
mlissner / dwolla.py
Created December 30, 2014 19:24
GAH! time.sleep(1)
def process_dwolla_transaction_status_callback(request):
if request.method == 'POST':
data = simplejson.loads(request.body)
logger.info('Dwolla transaction status callback triggered with '
'data: %s' % data)
if check_dwolla_signature(
request.META['HTTP_X_DWOLLA_SIGNATURE'],
request.body):
# Statuses can be found at:
# https://developers.dwolla.com/dev/pages/statuses
@mlissner
mlissner / filters.js
Created March 7, 2019 23:09
Regular expressions for parsing law citations from the U.S., Canada, Europe, and Australia (and probably more). Originally from the Jureeka project.
// ==UserScript==
// @name Jureeka
// @namespace http://www.jureeka.org
// @description Turns legal citations in webpages into hyperlinks that direct you to online legal source material.
// ==/UserScript==
// $Id: jureeka.js 1256 2012-02-13 19:06:16Z imad $
/*
Warnings: