Skip to content

Instantly share code, notes, and snippets.

View jdunck's full-sized avatar

Jeremy Dunck jdunck

View GitHub Profile
@jdunck
jdunck / redis_leaky_bucket.py
Created November 17, 2012 08:16
leaky bucket queue - redis 2.6 + lua + python
#cribbed from http://vimeo.com/52569901 (Twilio carrier call origination moderation)
# The idea is that many fan-in queues can enqueue at any rate, but
# dequeue needs to happen in a rate-controlled manner without allowing
# any individual input queue to starve other queues.
# http://en.wikipedia.org/wiki/Leaky_bucket (second sense, "This version is referred to here as the leaky bucket as a queue.")
#
# requires:
# redis 2.6+
# redis-py>=2.7.0
# anyjson
@jdunck
jdunck / s3_multipart.py
Last active May 15, 2019 13:55 — forked from BradWhittington/s3_multipart.py
upload to s3 with streaming, multi-part, threaded upload, with key rollover as you pass the 4gb limit, with adjustable buffering and pooling. Don't forget to call uploader.close() when you're done.
from multiprocessing.pool import ThreadPool
import logging, os, threading
from StringIO import StringIO
import boto.s3
logger = logging.getLogger('s3upload')
class MultiPartUploader:
upload_part = 0
@jdunck
jdunck / gist:4617846
Created January 24, 2013 05:14
dirty groping for required module versions of an arbitrary python codebase.
find . -iname '*.py' -type f | xargs grep 'import' | awk -F':' '{print $2}' | sed -E 's/ +$//g' | sed -E 's/^[ :tab:]+//g' | sort| uniq | python -c '
import sys
for line in sys.stdin.readlines():
try:
exec line
except:
print >> sys.stderr, "failed to exec %s" % line
def ver(mod):
for attempt in ["__version__", "VERSION", "__VERSION__"]:
Baloo.methods._one_time_conditions_valid_1063?
Baloo.methods._one_time_conditions_valid_1065?
Baloo.methods._one_time_conditions_valid_1069?
Baloo.methods._one_time_conditions_valid_106?
Baloo.methods._one_time_conditions_valid_1073?
Baloo.methods._one_time_conditions_valid_1075?
Baloo.methods._one_time_conditions_valid_1077?
Baloo.methods._one_time_conditions_valid_1081?
Baloo.methods._one_time_conditions_valid_1085?
Baloo.methods._one_time_conditions_valid_1087?
irb(main):001:0> def x()
irb(main):002:1> return 2
irb(main):003:1> end
=> nil
irb(main):004:0> x = 1
=> 1
irb(main):005:0> x
=> 1
irb(main):006:0> x()
=> 2
def x()
with(:category_id).any_of([210]) # defined only within the below block.. I think.
end
Sunspot.search(Frob) do
with(:frob_id, 1)
x()
end
@jdunck
jdunck / gist:4963232
Created February 15, 2013 20:19
ruby wat #2
hotsoup:causes jdunck$ irb
irb(main):001:0> def x()
irb(main):002:1> return 1
irb(main):003:1> end
=> nil
irb(main):004:0> h = {}
=> {}
irb(main):005:0> h[:a] = x
=> 1
irb(main):006:0> h
@jdunck
jdunck / 1
Created March 19, 2013 23:49
Malcolm
Date: Fri, 20 Oct 2006
From: Jeremy
To: Malcolm
Subject: (Off-list) Django internals
Hey Malcolm,
I'm a user of and (minor) contributor to Django. I want to improve
my understanding of Dj's internals so I can contribute more easily. I
know you got up to speed on it without too much hand-holding or being
an original contrib. Any tips?
@jdunck
jdunck / accomplishments
Created March 22, 2013 22:30
Aaron Swartz for the Citizens Medal
SOPA/PIPA threatened First Amendment rights on the web and he was instrumental in its defeat.
His work with Wikipedia was material and instrumental in its early growth.
His work with archive.org gave birth to the Open Library, which offers public domain text to the world.
His foundational work on creativecommons.org gave rise to an outlet for creators to collaborate easily by expressing which, not all, rights they reserve.
His work on RSS, a web exchange format, gave rise to Podcasts and news reader software.
@jdunck
jdunck / gist:5925600
Last active December 19, 2015 08:29
Why I am protesting on July 4, 2013

If you would like to get involved, http://www.restorethefourth.net/ is the starting point.

Reasons I, personally, am joining this movement:

Guantanamo (though undoubtedly many dangerous people are there, it is a clear violation of human rights to hold people without trial, and not all held are guilty)

Extraordinary Rendition (the habit of sending people to politically allied states for the purpose of torture, since we "don't do that" here)

No-fly lists (not subject to review, based on low evidence, with many false-positive examples)