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/env python | |
import memcache | |
HOST = '127.0.0.1' | |
PORT = 11211 | |
class QueueDoesNotExist(Exception): | |
pass | |
def application(environ, start_response): |
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/env python | |
# Convert a mysql dump into a sqlite-compatible format. | |
# I wrote this for just one script... no guarantess that it will work with others... | |
# python fsql.py < mysqldump.sql > readyforsqlite.sql | |
import re | |
import sys | |
content = sys.stdin.read() |
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/env python | |
# Copyright (c) 2009, Jeremy Carbaugh | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. |
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
# Copyright (c) 2009, Sunlight Foundation | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# * Redistributions in binary form must reproduce the above copyright notice, | |
# this list of conditions and the following disclaimer in the documentation |
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.contrib.auth.models import User | |
import base64 | |
class HTTPBasicAuthMiddleware(object): | |
def process_request(self, request): | |
authorization = request.META.get('HTTP_AUTHORIZATION', None) | |
if authorization: |
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
-- Get a URL from the clipboard | |
set longURL to the clipboard | |
-- The command to get the shortened URL from the Internets (choose 1 method) | |
set cmd to "curl http://colossalurl.com/api/colossify/?url=" & longURL | |
-- Run the curl command and set the new URL to the clipboard | |
set shortURL to do shell script cmd | |
set the clipboard to shortURL as text |
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
MEDIA_STATIC_ROOT = os.path.join(PROJECT_PATH, '..', 'site_media', 'static') | |
MEDIA_STATIC_URL = '/site_media/static/' | |
MEDIA_ROOT = os.path.join(PROJECT_PATH, os.pardir, '..', 'site_media', 'dynamic') | |
MEDIA_URL = '/site_media/dynamic/' | |
MEDIASYNC = { | |
'MEDIA_ROOT': MEDIA_STATIC_ROOT, | |
'MEDIA_URL': MEDIA_STATIC_URL, | |
'BACKEND':'mediasync.backends.s3', |
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
def create_post(**message): | |
author = User.objects.get(email=message['from']) | |
title = message['subject'] | |
content = message['plain'] | |
p = Post.objects.create( | |
author=author, | |
title=title, |
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
handler = MailHandler() | |
handler.register_address( | |
address="[email protected]", | |
secret="secret-key-from-cloudmailin", | |
callback=create_post, | |
) | |
urlpatterns = patterns('', | |
url(r'^postbymail/$', mail_handler), | |
) |
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 lxml.html import parse | |
import re | |
import subprocess | |
import urllib2 | |
_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+') | |
def slugify(text, delim=u'-'): | |
result = [] | |
for word in _punct_re.split(text.lower()): |
OlderNewer