Skip to content

Instantly share code, notes, and snippets.

@fabware
fabware / gist:305572
Created February 16, 2010 14:57 — forked from apit/gist:284705
"""
Usage:
import debug
class BaseHandler(tornado.web.RequestHandler):
def get_error_html(self, status_code, **kwargs):
if self.application.settings['debug']:
return debug.display(self, kwargs['exception'])
'''
Copyright 2010 Josiah Carlson
Released into the public domain
copy_redis.py
A convenient utility function for copying data from one redis server to
another.
Requires http://github.com/andymccurdy/redis-py .
@fabware
fabware / gist:1008924
Created June 5, 2011 12:33 — forked from jslatts/gist:1008072
Example of using connect session cookies with socket.io
socket.on('connection', function(client){
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
if (!client.request || !client.request.headers || !client.request.headers.cookie) {
disconnectAndRedirectClient(client,function() {
console.log('Null request/header/cookie!');
});
return;
}
Setup
=====
[stunnel acccept port 443 connect 8443]
||
[haproxy
* accept port 80
default: connect 8080 (nginx)
host: 'push.*' => connect 8090 (node)
* accept port 8443
@fabware
fabware / iprange.cc
Created September 21, 2011 23:08 — forked from chenshuo/iprange.cc
从一组 IP range --> value 的数据中查找单个 IP
#include <assert.h>
#include <stdint.h>
#include <algorithm>
#include <vector>
using namespace std;
struct IPrange
{
@fabware
fabware / zerologger.py
Created July 15, 2012 14:25 — forked from gwik/zerologger.py
Python logger ZeroMQ, Gevent, CouchDB
# encoding: utf-8
"""
A python logging Handler that use ZeroMQ (ØMQ).
+------+ +------+ +-------+
| app1 | | app2 | | app X |
+------+ +------+ +-------+
| PUSH | PUSH | PUSH
| | |
@fabware
fabware / download_video.sh
Created July 22, 2012 02:48 — forked from ftao/download_video.sh
download pycon2012 videos
#!/bin/sh
wget https://github.com/rg3/youtube-dl/zipball/master -O youtube-dl.zip
unzip youtube-dl.zip
cd rg3-youtube-dl-ceba827/
python youtube-dl --batch-file ../pycon2012_video_urls.txt
import gevent
from thrift.server.TServer import TServer
# XXX Hackish, but should be safe: monkey patch gevent socket support into
# Thrift. Overall I think this is cleaner than reimplementing all of TSocket.
from thrift.transport import TSocket; TSocket.socket = gevent.socket
from thrift.transport.TTransport import TTransportException
class TGEventServer(TServer):
"""Gevent socket server."""

Follow these steps to install graphite on OS X Lion.

Prerequisites

  • Python 2.7
  • Brew
  • Git

Install dependencies

Install Cairo

Follow these steps to install graphite on OS X Lion.

Prerequisites

  • Python 2.7
  • Brew
  • Git

Install dependencies

Install Cairo