This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cherrypy | |
class Application(object): | |
def index(self): | |
return "Hello World!" | |
index.exposed = True | |
wsgi_app = cherrypy.tree.mount(Application()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
GUNICORN=/usr/local/bin/gunicorn | |
ROOT=/home/thomas/tex2png/ | |
PID=/var/run/gunicorn.pid | |
BIND=unix:/tmp/gunicorn.sock | |
WORKERS=2 | |
APP=app:application | |
if [ -f $PID ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE> | |
<html> | |
<head> | |
<title>My math web page</title> | |
<meta charset="utf-8"> | |
<style type="text/css" media="screen"> | |
eq img { | |
position: relative; | |
top: 4px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: seismic_web | |
# Required-Start: $local_fs $syslog | |
# Required-Stop: $local_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Gunicorn processes for seismic_web | |
### END INIT INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_modules(path): | |
""" | |
Load all Python modules from a directory into a dict. | |
:param path: the path to the living place of the modules to load. | |
:type path: :class:`str` | |
:returns: map between loaded modules name and their content. | |
:rtype: :class:`dict` | |
""" | |
import os, imp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dict_delta(old, new): | |
""" | |
Compute the differences between two versions of a dictionary | |
>>> dict1 = {\ | |
'ipsum': 'ABC',\ | |
'dsqdq': 'sssdqs',\ | |
'opapoaaz': 'dpqsnqsd',\ | |
'pPlolf': 'popoazn',\ | |
'pfkv': 'blah',\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Converts a tuple to a list. | |
% {a, b, c, d} -> [a, b, c, d] | |
tuple_to_list(T) -> | |
tuple_to_list(T, 0). | |
tuple_to_list(_T, -1) -> | |
[]; | |
tuple_to_list(T, Id) -> | |
Max = tuple_size(T) - 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a simple example of WebSocket + Tornado + Redis Pub/Sub usage. | |
Do not forget to replace YOURSERVER by the correct value. | |
Keep in mind that you need the *very latest* version of your web browser. | |
You also need to add Jacob Kristhammar's websocket implementation to Tornado: | |
Grab it here: | |
http://gist.github.com/526746 | |
Or clone my fork of Tornado with websocket included: | |
http://github.com/pelletier/tornado | |
Oh and the Pub/Sub protocol is only available in Redis 2.0.0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# projectfoo/config/__init__.py | |
from os import path | |
ROOT_PATH = path.dirname(path.dirname(path.abspath(__file__))) | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
This is a simple Twitter to email script. | |
You need: | |
- An SMTP server (such as Sendgrid.net). | |
- A Redis server. | |
- Python. | |
Don't forget: |
OlderNewer