Skip to content

Instantly share code, notes, and snippets.

@kachayev
kachayev / tic-tac-toe.py
Created November 22, 2011 23:50
Tornado demo application: TCP server to tic-tac-toe multiplayer game
"""Simple TCP server for playing Tic-Tac-Toe game.
Use Player-to-Player game mode based on naming auth.
No thoughts about distribution or pub/sub mode
(for monitoring or something like this). Just
basic functionality.
"""
import time
import logging
@border
border / stock5Min.c
Created January 8, 2012 15:15
通达信股票天和5分钟数据格式分析, 参考: http://alantop.5166.info/gpdatasoft/gpformat/gpformat.htm
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
struct stock5Min
{
unsigned short monthDay; // 月日
unsigned short hourMin; // 小时, 分钟
@ehazlett
ehazlett / mongodb.conf
Created February 13, 2012 15:32
MongoDB supervisor config
[program:mongodb]
command=/opt/mongodb/bin/mongod --dbpath /storage/mongodb_data --rest
directory=/opt/mongodb
user=root
autostart=false

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@programus
programus / data-table.css
Created March 7, 2012 13:12
CSS & head to set data table format in Octopress
* + table {
border-style:solid;
border-width:1px;
border-color:#e7e3e7;
}
* + table th, * + table td {
border-style:dashed;
border-width:1px;
border-color:#e7e3e7;
@methane
methane / gist:2185380
Created March 24, 2012 17:28
Tornado Example: Delegating an blocking task to a worker thread pool from an asynchronous request handler
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
@jholster
jholster / gist:2290574
Created April 3, 2012 09:06
Tornado multiprocess example
import tornado.web
import tornado.httpserver
import tornado.ioloop
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Greetings from the instance %s!" % tornado.process.task_id())
app = tornado.web.Application([
(r"/", MainHandler),
@futuremill-ltd
futuremill-ltd / gist:2318876
Created April 6, 2012 11:00
Building Ruby 1.9.3 package for Debian Squeeze
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@anekos
anekos / evernote-webclipper-methods.js
Created May 6, 2012 04:45
evernote web clipper のメソッド一覧
evernote_doAction( document.popupNode, 'CLIP_ACTION_FULL_PAGE' );
evernote_doAction( document.popupNode, 'CLIP_ACTION_IMAGE' );
evernote_doAction( document.popupNode, 'CLIP_ACTION_SELECTION' );
evernote_doAction( document.popupNode, 'CLIP_ACTION_URL' );
evernote_doAction( document.popupNode, 'NEW_NOTE_ACTION' );