Skip to content

Instantly share code, notes, and snippets.

Avatar

Serge Shirokov kurokikaze

View GitHub Profile
@kurokikaze
kurokikaze / process.py
Last active Aug 29, 2015
Переработка текстовых экспортированных кубов с CubeTutor в формат, подходящий для SPMF
View process.py
import re, os
from random import shuffle
r_unwanted = re.compile("[\n\t\r]")
r_file = re.compile("cube([\d]+).txt") # шаблон имени файла
dic = dict()
num = 1000 # с чего начинаем нумерацию карт
censored = ["Temple Garden",
"Blood Crypt",
@kurokikaze
kurokikaze / togif.py
Created Apr 4, 2014
Получает с togif.me гифки с кол-вом просмотров и выдает в stdout в виде csv
View togif.py
from bs4 import BeautifulSoup
from urllib2 import urlopen
from urlparse import urljoin
import re
for num in range(1, 150):
url = "http://togif.me/catalog/" + str(num)
res = urlopen(url)
soup = BeautifulSoup(res.read())
links = soup.select('td a')
View md5_lcs.py
#!/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):
View nerve-test.js
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;
View crash-tyrant.js
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 / ref.js
Created May 28, 2010
Creating reference in node-mongodb-native
View ref.js
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) {
View mapreduce.js
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)
}
};
View transactions.js
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) {
View betainv.inc
<?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 Nov 18, 2010
Minecraft chunk file reader
View read_chunk.py
from struct import unpack
tag_types = { 0 : 'End',
1 : 'Byte',
2 : 'Short',
3 : 'Int',
4 : 'Long',
5 : 'Float',
6 : 'Double',
7 : 'Byte array',
You can’t perform that action at this time.