Skip to content

Instantly share code, notes, and snippets.

View dgouldin's full-sized avatar

David Gouldin dgouldin

  • Clara Labs
  • San Francisco, CA
View GitHub Profile
Monospaced fonts still have plenty of valid uses, so I BEG. TO. DIFFER.
@dgouldin
dgouldin / gist:3836859
Created October 4, 2012 22:24
haproxy logs -> list of python dicts
import datetime
import re
HAPROXY_LOG_PATH = '/path/to/haproxy.log'
haproxy_re = re.compile(
r'haproxy\[(?P<pid>\d+)\]: '
r'(?P<client_ip>(\d{1,3}\.){3}\d{1,3}):(?P<client_port>\d{1,5}) '
r'\[(?P<date>\d{2}/\w{3}/\d{4}(:\d{2}){3}\.\d{3})\] '
r'(?P<listener_name>\S+) (?P<server_name>\S+) '
r'(?P<Tq>(-1|\d+))/(?P<Tw>(-1|\d+))/(?P<Tc>(-1|\d+))/(?P<Tr>(-1|\d+))/'

Tunneling a public URL to your local machine

On the public web server

Sample lighttpd conf:

$HTTP["host"] == "d.gould.in" {
  proxy.server = ( "" => ( ( "host" => "127.0.0.1",
                             "port" => 20020 ) ) )
@dgouldin
dgouldin / gist:3696240
Created September 11, 2012 05:45
Candidates running against supporters of SOPA
https://www.votizen.com/matt-helt-for-us-house/
https://www.votizen.com/phil-jennerjahn-for-us-house-1/
https://www.votizen.com/candace-duval-for-us-house/
https://www.votizen.com/brad-morris-for-us-house/
https://www.votizen.com/robert-estes-for-us-house/
https://www.votizen.com/henry-ross-for-us-house/
https://www.votizen.com/jim-bourland-for-us-house/
https://www.votizen.com/danny-bedwell-for-us-house/
https://www.votizen.com/chris-potts-for-us-house/
https://www.votizen.com/philip-scollo-for-us-house/
@dgouldin
dgouldin / gist:3485236
Created August 27, 2012 03:10
Dead letter exchange based celery countdown implementation
class FrealCountdownTask(task.Task):
abstract = True
@classmethod
def apply_async(self, args=None, kwargs=None,
task_id=None, producer=None, connection=None, router=None,
link=None, link_error=None, publisher=None, add_to_parent=True,
**options):
try:
@dgouldin
dgouldin / gist:3327545
Created August 11, 2012 22:17
librabbitmq misleading connection error message
In [1]: import librabbitmq
In [2]: connection = librabbitmq.Connection(userid='bad', password='bad')
---------------------------------------------------------------------------
ConnectionError Traceback (most recent call last)
<ipython-input-2-23c4e6e59779> in <module>()
----> 1 connection = librabbitmq.Connection(userid='bad', password='bad')
/Users/dgouldin/virtualenv/djangocon2012/lib/python2.7/site-packages/librabbitmq/__init__.pyc in __init__(self, host, userid, password, virtual_host, port, channel_max, frame_max, heartbeat, lazy, **kwargs)
166 self._avail_channel_ids = array('H', xrange(self.channel_max, 0, -1))
@utils.filter_params
def prepare_headers(params, headers=None, realm=None):
"""Prepare the Authorization header.
Per `section 3.5.1`_ of the spec.
Protocol parameters can be transmitted using the HTTP "Authorization"
header field as defined by `RFC2617`_ with the auth-scheme name set to
"OAuth" (case insensitive).
CREATE TABLE `foo` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(255) NOT NULL
);
CREATE TABLE `bar` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`name` varchar(255) NOT NULL,
`foo_id` integer NOT NULL
);
<html>
<body>
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
var scopes = [
'email',
'user_birthday',
'user_likes',
'user_interests',
exclude_params = (
u'realm',
u'oauth_signature',
)
params = filter(lambda i: i[0] not in exclude_params, params)