Skip to content

Instantly share code, notes, and snippets.

@k1000
k1000 / fabfile.py
Created November 21, 2009 11:55
deploy django fabfile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
@k1000
k1000 / README
Created July 27, 2011 20:36 — forked from nicpottier/README
Basic Django template syntax highlighting support for the codemirror editor.
These two files provide limited syntax highlighting using the most
excellent codemirror syntax highlighter.
See:
http://marijn.haverbeke.nl/codemirror/
Stick the .js and .css files in the appropriate spots for your
codemirror installation.
You can enable it on a textarea using something like:
@k1000
k1000 / gist:2937675
Created June 15, 2012 17:19
A barebones example of Tornado's asynchronous functionality.
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
class BaseHandler(tornado.web.RequestHandler):
pass
class HandlerMixin(object):
listeners = []
@k1000
k1000 / gist:2946017
Created June 17, 2012 23:10 — forked from vgarvardt/gist:1670947
Tornado session decorator
# -*- coding:utf-8 -*-
import os
import functools
import pprint
import base64
import json
from datetime import datetime
from tornado import gen
@k1000
k1000 / gist:2946026
Created June 17, 2012 23:17
Error pretty printer for Tornado
"""
Exception pretty-printer for Tornado-0.2, taken from Django.
The version I forked works with Tornado HEAD but not the 0.2 release.
This one should work with either version.
Usage:
import debug
class BaseHandler(tornado.web.RequestHandler):
@k1000
k1000 / async_test_engine.py
Created June 17, 2012 23:32 — forked from ajdavis/async_test_engine.py
Generator-style Tornado asynchronous test tool
import os, time, functools, types, unittest
from tornado import gen, ioloop
import asyncmongo
import asyncmongo.errors
def async_test_engine(timeout_sec=5):
if not isinstance(timeout_sec, int) and not isinstance(timeout_sec, float):
raise TypeError(
"Expected int or float, got %s\n"
@k1000
k1000 / async_psycopg2.py
Created September 30, 2012 08:50 — forked from andrulik/async_psycopg2.py
A module for asynchronous PostgreSQL queries in Tornado.
#!/usr/bin/env python
__author__ = 'Frank Smit <frank@61924.nl>'
__version__ = '0.1.0'
import functools
import psycopg2
from tornado.ioloop import IOLoop, PeriodicCallback
@k1000
k1000 / zsh.md
Created May 11, 2013 17:21 — forked from tsabat/zsh.md

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

and then you change your shell to zsh

chsh -s `which zsh`

and then restart

"""
Celery base task aimed at longish-running jobs that return a result.
``AwesomeResultTask`` adds thundering herd avoidance, result caching, progress
reporting, error fallback and JSON encoding of results.
"""
from __future__ import division
import logging
import simplejson