Skip to content

Instantly share code, notes, and snippets.

@mtigas
mtigas / gist:976939
Created May 17, 2011 17:39
Census Fields (May 2011 release)
Under 5 years,under_5_yrs,dpsf0010002
5 to 9 years,5_to_9_yrs,dpsf0010003
10 to 14 yrs,10_to_14_yrs,dpsf0010004
15 to 19 yrs,15_to_19_yrs,dpsf0010005
20 to 24 yrs,20_to_24_yrs,dpsf0010006
25 to 29 yrs,25_to_29_yrs,dpsf0010007
30 to 34 yrs,30_to_34_yrs,dpsf0010008
35 to 39 yrs,35_to_39_yrs,dpsf0010009
40 to 44 yrs,40_to_44_yrs,dpsf0010010
45 to 49 yrs,45_to_49_yrs,dpsf0010011
class A(object):
def __init__(self):
print "A init"
class B(A):
def __init__(self):
print "B init"
super(B, self).__init__()
class C(B):
@mtigas
mtigas / gist:1007030
Created June 3, 2011 19:45 — forked from n0nick/gist:1006549
wget-1.12-subjectAltNames.diff
diff --git a/src/openssl.c b/src/openssl.c
index b55ca8b..b036a3b 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -39,7 +39,7 @@ as that of the covered work. */
#include <string.h>
#include <openssl/ssl.h>
-#include <openssl/x509.h>
+#include <openssl/x509v3.h>
@mtigas
mtigas / install_homebrew.rb
Created July 15, 2011 22:27 — forked from mxcl/install_homebrew.markdown
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
#
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
#
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
# versions of OS X. I cannot verify that for sure, and it was tested on
#!/bin/bash
while true; do; if [ -z "`curl -s http://store.apple.com/| grep backsoon1`" ]; then; open http://store.apple.com/; say -v cellos "go go gadget iphone"; break; fi; done;
@mtigas
mtigas / gist:1304751
Created October 21, 2011 19:44 — forked from ryanpitts/gist:1304725
GROUP BY and Select MAX from each group in Django, 2 queries
'''
given a Model with:
category = models.CharField(max_length=32, choices=CATEGORY_CHOICES)
pubdate = models.DateTimeField(default=datetime.now)
<other fields>
Fetch the item from each category with the latest pubdate.
'''
@mtigas
mtigas / gist:1335214
Created November 2, 2011 22:57
Because you've always wanted a terminal screen tracking a live stream of "bieber" tweets.
from django.utils.encoding import smart_str
from django.utils.hashcompat import md5_constructor
def short_key(key, key_prefix, version):
"""
Like the default `KEY_FUNCTION`, but hashes strings longer
than 250 characters for safety with memcached. Uses python hash()
only when key is too long for memcached. Does not do anything
about memcached's restricted character set, only the key
class once(object):
"""
only allows the decorated function to run once (per unique args; can change
this behavior in __call__ as necessary)
based on http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
"""
def __init__(self, func):
self.func = func
self.cache = {}
def __call__(self, *args):
@mtigas
mtigas / pylibmc_backend.py
Created January 27, 2012 00:08
Subclass of `django.core.cache.backends.memcached.PyLibMCCache` that uses the binary protocol.
from django.core.cache.backends.memcached import PyLibMCCache
class PyLibMCBinaryCache(PyLibMCCache):
"""
Someday, they will accept my patch in
https://code.djangoproject.com/ticket/15815
Until then, this works.