Skip to content

Instantly share code, notes, and snippets.

@liuliu
liuliu / cmov.c
Created September 18, 2014 04:38
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <zlib.h>
#include <assert.h>
static size_t get_atom_size(uint8_t* atom)
{
return (atom[0] << 24) | (atom[1] << 16) | (atom[2] << 8) | atom[3];
}
@liuliu
liuliu / Titan setup.txt
Last active August 29, 2015 14:08
4 GPU Titan Steup
My 4-GPU Titan / Titan Black Setup is like this:
PSU: www.newegg.com/Product/Product.aspx?Item=N82E16817182251
Motherboard: http://www.newegg.com/Product/Product.aspx?Item=N82E16813132262 (You have to switch the PCI-e port to at x8 speed and change boot parameter to include "pci=nomsi irqpoll" to get stable performance).
CPU: http://www.newegg.com/Product/Product.aspx?Item=N82E16819117402
Memory: http://www.newegg.com/Product/Product.aspx?Item=N82E16820231793
@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