Skip to content

Instantly share code, notes, and snippets.

@didip
didip / model-tests-in-tornado.py
Created March 12, 2011 23:24
Example on how to tests your model classes in Tornado
import unittest, os, os.path, sys
import tornado.database
import tornado.options
from tornado.options import options
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
# import your model module
import your.model as model
@didip
didip / request_handler_test.py
Created March 12, 2011 21:46
Testing Tornado RequestHandlers
import unittest, os, os.path, sys, urllib
import tornado.database
import tornado.options
from tornado.options import options
from tornado.testing import AsyncHTTPTestCase
# add application root to sys.path
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
@didip
didip / some-basic-iptables-preroute-rules
Created March 12, 2011 08:47
some-basic-iptables-preroute-rules
# accept traffic to the normal ssh port
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
# accept traffic on the port kippo is listening on
iptables -A INPUT -i eth0 -p tcp --dport 2222 -j ACCEPT
# direct traffic inbound on port 22 to port 2222
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 22 -j REDIRECT --to-port 2222
@didip
didip / where-are-the-eggs-ubuntu-10-04-lts
Created February 22, 2011 01:12
Where are the systems location for Python eggs on Ubuntu 10.04 LTS
/usr/local/lib/python2.6/
dist-packages/
site-packages/
@didip
didip / dpkg-s-ubuntu-lts-python-pycurl
Created February 21, 2011 01:46
dpkg -s ubuntu python-pycurl
dpkg -s python-pycurl
Package: python-pycurl
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 272
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Source: pycurl
@didip
didip / tornado-install-failure.txt
Created February 21, 2011 01:28
Tornado install failure from master branch
Downloading http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz
Processing pycurl-7.19.0.tar.gz
Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tCrOeg/pycurl-7.19.0/egg-dist-tmp-99Bjyg
sh: curl-config: not found
Traceback (most recent call last):
File "setup.py", line 57, in <module>
description="Tornado is an open source version of the scalable, non-blocking web server and and tools that power FriendFeed",
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
@didip
didip / tornado_cookie_secret_generator.py
Created February 12, 2011 17:20
Generates secure cookie secret for Tornado Web Framework
@didip
didip / tornado-nginx-example.conf
Created January 30, 2011 05:19
Nginx config example for Tornado
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@didip
didip / supervisord-example.conf
Created January 30, 2011 05:10
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@didip
didip / supervisord-example.conf
Created December 31, 2010 01:44
Example for supervisord conf file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default