Monday, September 26, 2011

Simulate event with closing a channel

rog had showed me a nice way to synchronise several goroutines (something like an event) by closing a channel. Here's a code example:

Friday, September 16, 2011

Copy Directory Tree

filepath.Walk is a very useful function. Here's how you can use it to copy a directory tree:

Tuesday, September 13, 2011

Go on Hadoop

It's easy to use Go (or any other language) with Hadoop streaming. Here's a little "word count" example.

System Setup:
  • Hadoop running locally (Cloudera cdh3u0)
  • A copy of hadoop-streaming-0.20.2-cdh3u0.jar in local directory
  • Copy of "Alice In Wonderland" under /user/miki/alice.txt on HDFS


After the job has ran, you can view the output and check the most common words:

hadoop fs -cat /user/miki/words-out/part-00000 | sort -k 2 -n -r | head
the	1686
and	869
to	799
a	672
of	606
I	545
it	540
she	509
said	456
in	414

Sunday, September 4, 2011

A Selenium Client

Just released a new client for Selenium (remote WebDriver to be exact). Still work in progress but usable.


Example usage (you'll need a running Selenium server):

Thursday, September 1, 2011

Using ctags with Go

I'm a Vim user, and using ctags with it help me quickly navigate through code. ctags does not come with support for Go (yet?). But it's easy to add new language support to it using custom regular expressions. The below code will detect function definition in Go files. Then after running ctags -R in your project root you can hit CTRL-[ in Vim to jump to function definition.

Add the following to ~/.ctags:

Oh, and you should check out gocode as well.
/* MIKI: Analytics */