Moved to https://github.com/mtigas/dotfiles/blob/master/bin/twittersearch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.http import HttpResponsePermanentRedirect, get_host | |
class ForceSSLMiddleware(object): | |
""" | |
Redirects all (non-DEBUG) requests to go through SSL. | |
Picks up the `HTTP_X_FORWARDED_PROTO` proxy header set by Heroku. | |
Also sets the "Strict-Transport-Security" header for 600 seconds so that |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A decent default .gitignore | |
# Same as GitHub's at https://github.com/github/gitignore/blob/master/Python.gitignore | |
# except keeps /bin directory. | |
*.py[co] | |
# Packages | |
*.egg | |
*.egg-info | |
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |