Skip to content

Instantly share code, notes, and snippets.

@liuliu
liuliu / parallable.sum.js
Created December 8, 2010 00:20
sum with parallable
var sum = parallable("sum.js", function (list) {
if (this.shared !== undefined) {
this.shared.list = list;
}
var pre = function (worker_num) {
var list = this.shared.list;
var part = new Array(worker_num);
var i;
var len = Math.ceil(list.length / worker_num);
for (i = 0; i < worker_num; i++)
def alphabet_range(start_with, limit):
alphabet = '$abcdefghijklmnopqrstuvwxyz' # alphabet set, don't modify it
i = 0
n = 0
while n < limit: # from 1 to some number
w = []
k = i
while k > 0:
w.append(alphabet[k % 27]) # shortcut for enumeration, covert to 27-ary number
k = k / 27
import random;
def alphabet_range(start_with, limit):
alphabet = '$abcdefghijklmnopqrstuvwxyz' # alphabet set, don't modify it
i = 0
n = 0
while n < limit: # from 1 to some number
w = []
k = i
while k > 0:
@liuliu
liuliu / model.php
Created December 28, 2010 10:11
model.php
<?php
require_once 'odm.php';
require_once 'util.php';
class Atomic
{
private $identifier;
public function get($pipe)
{
@liuliu
liuliu / case.c
Created January 29, 2011 03:31
test case file
#include "case.h"
TEST_CASE("fail test")
{
REQUIRE_EQ(1, 2, "should fail %d", 1024);
}
TEST_CASE("fail array test")
{
int a[3] = {1,2,3};
public static class Map extends
Mapper<ImageHeader, FloatImage, IntWritable, FloatImage> {
public void map(ImageHeader key, FloatImage value, Context context)
throws IOException, InterruptedException {
if (value != null && value.getWidth() > 100 && value.getHeight() > 100) {
float[][] tp = new float[100][32 * 32];
for (int i = 0; i < 10; i++) {
int x = (value.getWidth() - 32) * i / 10;
for (int j = 0; j < 10; j++) {
@liuliu
liuliu / a.rb
Created September 22, 2012 06:35
extract annotations of VOC dataset into ccv understandable format
#!/usr/bin/env ruby
require "rexml/document"
prng = Random.new Random.new_seed
objfiles = Hash.new
objtrainfiles = Hash.new
objvalfiles = Hash.new
#!/usr/bin/env ruby
exit unless ARGV.length == 1
file = File.new ARGV[0]
residual = 0
filename = nil
file.each do |line|
case residual
when 0 then
@liuliu
liuliu / gist:5369039
Created April 12, 2013 03:15
Ground Truth of CMU dataset
voyager.png 122.0 43.0 137.0 47.0 129.0 54.0 123.0 59.0 128.0 60.0 133.0 62.0
voyager.png 191.0 54.0 204.0 56.0 197.0 63.0 192.0 69.0 197.0 69.0 201.0 70.0
voyager.png 302.0 64.0 314.0 60.0 307.0 67.0 306.0 74.0 310.0 73.0 314.0 72.0
voyager.png 390.0 31.0 405.0 28.0 398.0 39.0 393.0 46.0 399.0 44.0 404.0 44.0
voyager.png 257.0 196.0 271.0 198.0 264.0 204.0 257.0 211.0 263.0 210.0 269.0 212.0
voyager.png 306.0 181.0 320.0 180.0 314.0 187.0 309.0 193.0 313.0 192.0 317.0 193.0
voyager.png 144.0 439.0 161.0 440.0 153.0 450.0 146.0 458.0 152.0 458.0 158.0 459.0
voyager.png 252.0 464.0 270.0 463.0 262.0 473.0 256.0 481.0 262.0 479.0 267.0 479.0
voyager.png 345.0 439.0 363.0 437.0 356.0 449.0 351.0 456.0 356.0 455.0 362.0 455.0
puneet.png 59.0 136.0 74.0 136.0 68.0 146.0 62.0 150.0 67.0 150.0 73.0 151.0
@liuliu
liuliu / gist:5369041
Created April 12, 2013 03:15
ccv output on CMU
addams-family.png 81 505 45 45 7.843119
addams-family.png 328 174 50 50 12.569483
addams-family.png 736 552 49 49 8.898903
addams-family.png 659 387 46 46 6.503688
addams-family.png 423 144 55 55 0.090923
addams-family.png 711 87 53 53 6.657643
addams-family.png 138 405 51 51 5.100987
aeon1a.png 161 86 142 142 -0.815429
aerosmith-double.png 272 110 39 39 6.868231
aerosmith-double.png 103 16 42 42 5.516684