Skip to content

Instantly share code, notes, and snippets.

@jacobian
jacobian / gist:95443
Created April 14, 2009 21:33
.screenrc
hardstatus alwayslastline
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"
startup_message off
vbell off
The goal of Summer of Code is to get your project written, reviewed, and
ultimately merged back into Django's trunk. We want your project to
succeed, and we approved it because we think you've got a good chance of
pulling it off.
However, this is easier said than done. You'll need to work hard,
communicate effectively with the community, and pass a rigorous peer
review. Your mentor -- and Django's committer team in general -- will give
you as much support as possible, but ultimately the onus is on your
shoulders to get this done.
# Django: validate that an uploaded file is a valid PDF
import pyPdf # from http://pybrary.net/pyPdf/
from pyPdf.utils import PdfReadError
class DocumentForm(forms.ModelForm):
pdf = forms.FileField()
class Meta:
model = Document
#!/usr/bin/env python
"""
Regex for URIs
These regex are directly derived from the collected ABNF in RFC3986
(except for DIGIT, ALPHA and HEXDIG, defined by RFC2234).
They should be processed with re.VERBOSE.
"""
import logging
class Silence(logging.Handler):
def emit(self, record):
pass
logging.getLogger("jellyroll").addHandler(Silence())
@jacobian
jacobian / echo.c
Created October 7, 2009 19:13 — forked from paulsmith/echo.c
/**
* A simple preforking echo server in C.
*
* Building:
*
* $ gcc -Wall -o echo echo.c
*
* Usage:
*
* $ ./echo
@jacobian
jacobian / unicorn.php
Created October 8, 2009 15:10
This was written by Russell Beattie; I copied it here from a pastebin to give it a permanent home.
<?
/*
Simple preforking echo server in PHP.
Russell Beattie (russellbeattie.com)
PHP port of http://tomayko.com/writings/unicorn-is-unix
*/
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
# Prevent pip from doing anything unless you're inside an activated virtualenv.
PIP=/usr/local/bin/pip
function pip {
if [ "x$VIRTUAL_ENV" = 'x' ]; then
echo "No virtualenv activated; bailing."
else
$PIP -E `basename $VIRTUAL_ENV` "$@"
fi
}
/
GET -> list of projects
/{project}
GET -> project info
PUT -> create new project (not req'd; created if needed)
DELETE -> delete project and all build info
/{project}/builds
GET -> list of recent builds; pagination for all builds
cd /tmp
wget http://codespeak.net/lxml/lxml-2.2.2.tgz
tar -xzvf lxml-2.2.2.tgz
cd lxml-2.2.2
cd libs/
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
cd ..
python setup.py build --static-deps --libxml2-version=2.7.3 --libxslt-version=1.1.24
sudo python setup.py install