The current version will be found at https://gist.github.com/mike-bourgeous/2be6c8900bf624887fe5fee4f28552ef
Please make all comments, stars, forks, etc. there.
from os import urandom | |
def random_id(): | |
"""Returns a 20-character random identifier.""" | |
return urandom(15).encode("base64")[:-1] | |
def parse_cookie(environ): | |
"""Returns the cookie from the given WSGI environ as dict.""" | |
s = environ.get('HTTP_COOKIE', '') | |
return dict(map(str.strip, elt.split("=")) for elt in s.split(";")) if s else {} |
import argparse | |
from mock import Mock | |
m = Mock() | |
parser = argparse.ArgumentParser() | |
subparsers = parser.add_subparsers() | |
query_group = subparsers.add_parser('query') | |
add_group = subparsers.add_parser('add') |
The current version will be found at https://gist.github.com/mike-bourgeous/2be6c8900bf624887fe5fee4f28552ef
Please make all comments, stars, forks, etc. there.
digraph models_diagram { | |
graph[overlap=false, splines=true] | |
"Venue" [shape=record, label="{\ | |
Venue|name :string\l\ | |
}"] | |
"User" [shape=record, label="{User|\ | |
email :string\l\ | |
password :string\l\ | |
}"] |
#!/usr/bin/env python | |
# coding: utf-8 | |
import gtk | |
class LoginWindow(gtk.Window): | |
def __init__(self): | |
gtk.Window.__init__(self) | |
self.connect("destroy", gtk.main_quit) |
#!/usr/bin/env python | |
# coding: utf-8 | |
# This little project is hosted at: <https://gist.github.com/1455741> | |
# Copyright 2011-2020 Álvaro Justen [alvarojusten at gmail dot com] | |
# License: GPL <http://www.gnu.org/copyleft/gpl.html> | |
import os | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText |
This article is now published on my website: Prefer Subshells for Context.
from kombu import Exchange | |
from kombu import Queue | |
from kombu import BrokerConnection | |
class ProduceConsume(object): | |
def __init__(self, exchange_name, **options): | |
exchange = Exchange(exchange_name, type='fanout', durable=False) | |
queue_name = options.get('queue', exchange_name+'_queue') | |
self.queue = Queue(queue_name ,exchange) |
#! /bin/sh | |
set +o noclobber | |
# | |
# $1 = scanner device | |
# $2 = friendly name | |
# | |
# | |
# 100,200,300,400,600 | |
# |
""" | |
Example of setting up CORS with Bottle.py. | |
""" | |
from bottle import Bottle, request, response, run | |
app = Bottle() | |
@app.hook('after_request') | |
def enable_cors(): | |
""" |