Skip to content

Instantly share code, notes, and snippets.

@baojie
baojie / index.html
Created February 15, 2013 20:12 — forked from darwin/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<body>
<scene id="scene1">
<label t="translate(0,346)">
<tspan x="0" y="0em">Comix Sample</tspan>
</label>
<actor t="translate(131,49)" pose="-11,9|-5,117|-11,99|-11,89|-11,79|-11,59|-16,34|-21,9|-6,34|-1,9|-18,79|-18,59|-6,79|-1,59">
@baojie
baojie / 002-cheap.html
Created February 17, 2013 01:43
PPT is cheap, show me the code!
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">
CLEARNLP=.
CLASSPATH=$CLEARNLP/lib/args4j-2.0.16.jar:$CLEARNLP/lib/commons-compress-1.4.1.jar:$CLEARNLP/lib/hppc-0.4.1.jar:$CLEARNLP/lib/jregex1.2_01.jar:$CLEARNLP/lib/clearnlp-1.3$
java -classpath $CLASSPATH com.googlecode.clearnlp.run.Version
FILE=iphone5.txt
echo "Test Tokenizer"
java -classpath $CLASSPATH com.googlecode.clearnlp.run.Tokenizer \
-d model/dictionary-1.3.1.zip -i $FILE
@baojie
baojie / install_ncdu.sh
Created March 13, 2013 00:56
Install ncdu from source. ncdu is a powerful to examine disk space usage. Default ubuntu distribute is 1.8. Do the follow will install 1.9 (as of 2013-03-12)
sudo apt-get install perl pkg-config autoconf automake libtool libncurses5-dev
git clone https://github.com/yorhel/ncdu.git
cd ncdu
autoreconf -i
./configure --prefix=/usr
make
sudo make install
# Examples
# scan a directory and export the results for later viewing
@baojie
baojie / fn.example.py
Last active December 14, 2015 22:38
fn.py example. Follow https://github.com/kachayev/fn.py
from fn import _
from fn.op import zipwith
from itertools import repeat
assert list(map(_ * 2, range(5))) == [0,2,4,6,8]
assert list(filter(_ < 10, [9,10,11])) == [9]
assert list(zipwith(_ + _)([0,1,2], repeat(10))) == [10,11,12]
from fn import _
print (_ + 2) # "(x1) => (x1 + 2)"
import os
import time
import boto
import boto.manage.cmdshell
def launch_instance(ami='ami-7341831a',
instance_type='t1.micro',
key_name='paws',
key_extension='.pem',
key_dir='~/.ssh',
#!bin/sh
# USAGE:
# bash <(curl -s https://gist.github.com/baojie/5175293/raw/cba116a7b3dae98626f775d31aef2301ce5e5ee9/tarall.sh)
# files to be excluded
cat > /tmp/exclude.txt << EOL
/dev
/tmp
/proc
#encoding=utf-8
import jieba
seg_list = jieba.cut("我来到北京清华大学",cut_all=True)
print "Full Mode:", "/ ".join(seg_list) #全模式
seg_list = jieba.cut("我来到北京清华大学",cut_all=False)
print "Default Mode:", "/ ".join(seg_list) #精确模式
seg_list = jieba.cut("他来到了网易杭研大厦")
@baojie
baojie / shapely.example.py
Created March 20, 2013 03:48
Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. https://github.com/sgillies/shapely
from shapely.geometry import Point
point = Point(0, 0)
print point.geom_type
# OUT: Point
print point.area
# OUT: 0.0
patch = point.buffer(10)
print patch.bounds
# OUT: (-10.0, -10.0, 10.0, 10.0)
# host
sudo apt-get install virtualbox dkms
# client
sudo apt-get install virtualbox-ose-guest-utils virtualbox-ose-guest-x11 virtualbox-ose-guest-dkms