Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
from random import randint
import hashlib
def LCSubstr_len(S, T):
m = len(S); n = len(T)
L = [[0] * (n+1) for i in xrange(m+1)]
lcs = 0
for i in xrange(m):
for j in xrange(n):
var nerve = require('./nerve/nerve');
var tyrant = require('./tyrant/tyrant');
var querystring = require('./querystring/querystring');
var Mu = require('./mu/mu');
var sys = require('sys');
// combo library
function Combo(callback) {
this.callback = callback;
var sys = require("sys"),
http = require("http"),
tyrant = require("./tyrant/tyrant");
http.createServer(function (request, response) {
response.sendHeader(200, {"Content-Type": "text/plain"});
tyrant.connect();
tyrant.addListener('connect', function() {
var startDate = (new Date()).getTime();
tyrant.search(tyrant.is('type', 'blog'), tyrant.sort('time', 'desc')).addCallback(function(answer) {
@kurokikaze
kurokikaze / server.js
Created May 5, 2010 09:24
Simple work queue implementation for node.js
var net = require('net'),
sys = require('sys');
var messages = [];
var work_in_progress = [];
var host = '192.168.175.128';
var port = 8999;
var server = net.createServer(function(client_stream) {
@kurokikaze
kurokikaze / ref.js
Created May 28, 2010 07:57
Creating reference in node-mongodb-native
var mongo = require('../lib/mongodb'),
sys = require('sys');
var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : mongo.Connection.DEFAULT_PORT;
sys.puts("Connecting to " + host + ":" + port);
var db = new mongo.Db('test', new mongo.Server(host, port, {}), {});
db.open(function(err, db) {
db.collection('players', function(err, collection) {
db.open(function(err, db) {
db.collection('rounds', function(err, collection) {
var name_letter = 'v';
var map = function() {
if (this.score1 > this.score2) {
emit(this.player1, this.score1);
} else {
if (this.score2 > this.score1) emit(this.player2, this.score2)
}
};
var mongo = require('../lib/mongodb'),
sys = require('sys');
var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : mongo.Connection.DEF
AULT_PORT;
sys.puts("Connecting to " + host + ":" + port);
var db = new mongo.Db('test', new mongo.Server(host, port, {}), {});
db.open(function(err, db) {
<?php
/**
* Taken from PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
@kurokikaze
kurokikaze / read_chunk.py
Created November 18, 2010 17:29
Minecraft chunk file reader
from struct import unpack
tag_types = { 0 : 'End',
1 : 'Byte',
2 : 'Short',
3 : 'Int',
4 : 'Long',
5 : 'Float',
6 : 'Double',
7 : 'Byte array',
from struct import unpack
import Image
tag_types = { 0 : 'End',
1 : 'Byte',
2 : 'Short',
3 : 'Int',
4 : 'Long',
5 : 'Float',
6 : 'Double',