Skip to content

Instantly share code, notes, and snippets.

int pin = 13;
void setup()
{
pinMode(pin, OUTPUT);
}
void loop()
{
// SOS
@baojie
baojie / hello_xmlrpc_server.py
Created January 6, 2013 06:56
XMLRPC server
from SimpleXMLRPCServer import SimpleXMLRPCServer
def file_reader(file_name):
with open(file_name, 'r') as f:
return f.read()
server = SimpleXMLRPCServer(('localhost', 5800))
server.register_introspection_functions()
@baojie
baojie / hello_xmlrpc_client.py
Created January 6, 2013 06:57
XMLRPC client
import os
import xmlrpclib
proxy = xmlrpclib.ServerProxy('http://localhost:5800/')
print proxy.file_reader(os.path.abspath( __file__ ))
@baojie
baojie / traffic_lights
Created January 9, 2013 04:40
Arduino traffic lights
int red = 13;
int yellow = 12;
int green = 11;
int ON=HIGH;
int OFF=LOW;
void setup(){
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
@baojie
baojie / temp2json
Last active December 11, 2015 01:09
Arduino: read temperature and write the data in a json object
#include <OneWire.h>
//2012-01-12: Jie Bao adapt from below
// read data stream and write to json
// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
@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)"