Skip to content

Instantly share code, notes, and snippets.

View cloverstd's full-sized avatar
🀄
Working for living

cloverstd cloverstd

🀄
Working for living
View GitHub Profile
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
#!/usr/bin/env python
# encoding: utf-8
"""
Usage:
fab deploy:appname
"""
from fabric.api import env, run, cd, local, put
env.hosts = ['myserver.com']
env.user = 'eric'
"""
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:
@chuangbo
chuangbo / README.md
Last active June 19, 2023 04:48
Python dynamic DNSPod DNS Script

替换上你的 API Token,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获取 API Token 的方式

获得 domain_id 可以用 curl

curl -k https://dnsapi.cn/Domain.List -d "login_token=TOKEN"`
@didip
didip / tornado-static-file.py
Created April 5, 2011 02:49
Tornado StaticFileHandler
class StaticFileHandler(RequestHandler):
"""A simple handler that can serve static content from a directory.
To map a path to this handler for a static data directory /var/www,
you would add a line to your application like:
application = web.Application([
(r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
])
@kkung
kkung / app.py
Created May 27, 2011 09:34
Flask, session store in memcached
from flask import Flask, request, session, url_for, redirect, \
render_template, abort, g, flash
from werkzeug.contrib.sessions import Session, SessionStore
from cPickle import HIGHEST_PROTOCOL
from random import random
from flask import json
class MemcachedSessionStore(SessionStore):
def __init__(self, servers=None, key_prefix=None, default_timeout=300):
@lxneng
lxneng / gist:1031014
Created June 17, 2011 07:30
Exception: `curl-config' not found -- please install the libcurl development files
(env)~/env pip install pycurl
Downloading/unpacking pycurl
Downloading pycurl-7.19.0.tar.gz (71Kb): 71Kb downloaded
Running setup.py egg_info for package pycurl
sh: curl-config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/eric/env/build/pycurl/setup.py", line 90, in <module>
raise Exception, ("`%s' not found -- please install the libcurl development files" % CURL_CONFIG)
Exception: `curl-config' not found -- please install the libcurl development files
@lucifr
lucifr / gist:1208100
Created September 10, 2011 08:16
Sublime Text 2 - 实用快捷键 (Mac OS X)
@xianyunwuxin
xianyunwuxin / simple_websocket.py
Created December 7, 2011 01:54
Make Flask work with Tornado.websocket
from flask import Flask
app=Flask(__name__)
@app.route('/')
def index():
return """
<span id="now">loading<span>
<script type="text/javascript">
window.WebSocket=window.WebSocket || window.MozWebSocket || false;
@ayang
ayang / app.py
Created February 4, 2012 03:47
Tornado session manager use redis
class Application(tornado.web.Application):
def __init__(self):
tornado.web.Application.__init__(self, handlers, **settings)
self.db_session = db_session
self.redis = redis.StrictRedis()
self.session_store = RedisSessionStore(self.redis)
class BaseHandler(tornado.web.RequestHandler):