Skip to content

Instantly share code, notes, and snippets.

@tetsuok
tetsuok / test_dark_bg.sh
Created May 8, 2012 23:00
Test dark slide background.
#!/bin/bash -x
filename=sinx
epsfile=${filename}.eps
tex_master=main.tex
tex_cmd=pdflatex
color=white # color which you want to change to.
gnuplot <<EOF
set terminal postscript eps enhanced color 30
@tetsuok
tetsuok / test_boost_unit_test.sh
Created May 10, 2012 07:18
Code to test boost test link error.
#!/bin/bash -x
cat << EOF > foo.cc
#define BOOST_TEST_MODULE foo
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(foo_test) {
int a = 0;
BOOST_CHECK_EQUAL(0, a);
}
@tetsuok
tetsuok / type_assertions.go
Created May 26, 2012 17:23
An example of type assertions for empty interface
// An example of type assertions for empty interface (i.e., interface{})
package main
import (
"container/list"
"fmt"
)
type Node struct {
@tetsuok
tetsuok / duck.go
Created May 26, 2012 20:03
A sample of duck typing
// duck typing
package main
import "fmt"
// Virtual duck
type Duck interface {
Quack() string
}
@tetsuok
tetsuok / cat.go
Created May 27, 2012 00:34
An implementation of cat in Go.
// A simple cat(1) implementation in Go.
//
// Build Instructions:
//
// $ go build -o cat
//
// Usage:
//
// Basically, the usage is same as cat(1).
//
@tetsuok
tetsuok / latency.txt
Created May 31, 2012 17:11 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@tetsuok
tetsuok / ls.go
Created June 6, 2012 04:19
ls utility in Go.
// simulates "ls -l"
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
)
@tetsuok
tetsuok / filter.go
Created June 6, 2012 09:01
Grep like filter in Go
// Copyright 2012 Tetsuo Kiso.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@tetsuok
tetsuok / build_rampion.sh
Created June 7, 2012 09:10
Build script for Rampion.
#!/bin/sh -x
# Build script for Rampion (Gimpel & Smith, NAACL 2012).
#
# Tested rampion v0.1 on Mac OS X 10.7 and Linux.
src=rampion-v0.1.tar.gz
url=http://www.ark.cs.cmu.edu/MT/$src
# detect os, and set the number of jobs to run make.
ncpu=
downloader=
@tetsuok
tetsuok / build_moses_with_regtest.sh
Created June 16, 2012 12:04
Build script for Moses with regression tests.
#!/bin/sh -x
num_cpu=32
path_to_moses=`pwd`
path_to_srilm=$HOME/local/src/srilm
test_num=10
path_to_regtest=$path_to_moses/regression-testing/moses-reg-test-data-$test_num
./bjam -j$num_cpu toolset=gcc \
--with-boost=/usr/include \
--with-srilm=$path_to_srilm \