Skip to content

Instantly share code, notes, and snippets.

View mmalone's full-sized avatar

Michael Malone mmalone

View GitHub Profile
"""
Copyright (c) 2008-2009, Nathan Borror
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
import socket
def sockrecv(sock):
d = ''
while not d or d[-1] != '\n':
d += sock.recv(8192)
return d
import operator
from django import http
def parse_etags(etag_str):
"""
Parses a string with one or several etags passed in If-None-Match and
If-Match headers by the rules in RFC 2616. Returns a list of etags
without surrounding double quotes (") and unescaped from \<CHAR>.
"""
"""
Copyright (c) 2008-2009, Nathan Borror, and modified heavily by Eric Florenzano
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
- simple
- public over private
- personal vanity
- internet is global
- permalinks
- one important item per page
- don't break the browser
- don't wanker in technology
- a medium is not a grande
- break convention for your users
class AssetTagDescriptor(object):
"""
A descriptor which provides access to an asset's tags.
"""
pre_save_manager_name = '__asset_tag_pre_save_manager_descriptor'
def __get__(self, instance, cls=None):
if not instance:
raise AttributeError('Manager must be accessed via instance')
from app.models import Tag
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $url = "http://www.reversehttp.net/reversehttp";
my $label = int rand 100000;
warn "Open http://demo$label.www.reversehttp.net/\n";
my $ua = LWP::UserAgent->new;
from django.views import debug
view_settings = dict(((k.lower(), v) for (k, v) in
debug.get_safe_settings().iteritems()))
def settings(request):
"""
Provides a 'settings' context variable that is a subset of the
Django settings module (the 'safe' settings).
"""
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
import csv
import sys
def csv_to_openstv(filename):
reader = csv.reader(open(filename))
candidates = reader.next()
stv = []
stv.append('%s __seats__' % len(candidates))
for line, row in enumerate(reader):
row = [i for i in row if i]