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
# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details. | |
"""UDP/SSL server""" | |
import sys | |
import errno | |
import traceback | |
from gevent import socket | |
from gevent import core | |
from gevent.baseserver import BaseServer | |
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 sys | |
import gevent | |
from gevent.monkey import patch_all; patch_all() | |
from gevent import server, event, socket | |
from multiprocessing import Process, current_process, cpu_count | |
""" | |
Simple multiprocess StreamServer that proxies messages between clients. | |
Avoids using a multiprocessing.Event since it blocks on a semaphore. |
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 com.lmax.disruptor.RingBuffer; | |
import com.lmax.disruptor.dsl.Disruptor; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
public class BackgroundLogger | |
{ | |
private static final int ENTRIES = 64; |
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 | |
import math, os.path, re, json, hyperclient | |
from os import urandom | |
from base64 import b32encode | |
from hashlib import md5 | |
from pprint import pprint | |
__all__ = 'HyperBayes' |
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
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; | |
DROP DATABASE template1; | |
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE'; | |
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; | |
\c template1 | |
VACUUM FREEZE; | |
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1'; |
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
var http = require('http') | |
, request = http.IncomingMessage.prototype; | |
/** | |
* Add a uniform interface for remote address in Node.js | |
* | |
* @api private | |
*/ | |
request.__defineGetter__('remote', function remote () { |
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 gevent | |
from gevent import monkey, queue | |
monkey.patch_all() | |
import urllib2 | |
from time import sleep | |
import traceback | |
import logging |
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 time | |
from werkzeug.serving import BaseRequestHandler | |
class MyFancyRequestHandler(BaseRequestHandler): | |
"""Extend werkzeug request handler to suit our needs.""" | |
def handle(self): | |
self.fancyStarted = time.time() | |
rv = super(MyFancyRequestHandler, self).handle() | |
return rv |
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 | |
import select | |
import time | |
import psycopg2 | |
import psycopg2.extensions | |
import sys | |
def get_cursor(): | |
conn = psycopg2.connect("dbname=pgpubsub") |
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 redis | |
import binascii | |
import md5 | |
s0 = redis.Redis(port=6379) | |
s1 = redis.Redis(port=6380) | |
s2 = redis.Redis(port=6381) | |
s3 = redis.Redis(port=6382) | |