Skip to content

Instantly share code, notes, and snippets.

@edwardw
edwardw / gist:3780436
Created September 25, 2012 07:21
Double negation in gitignore

Usually .gitignore is used to exempt certain files and directories from being reported by git status. The name .gitignore itself also suggests such usage. But when one does some experiments in sandbox directory, only a small portion of files are worth being version controlled. Instead of telling git what to exclude, it is more convenient to tell it what to include. Spotted such a .gitignore pattern today and it goes like this:

# Ignore all
*

# Except
.gitignore

# Include js directory
@edwardw
edwardw / gist:3411110
Created August 21, 2012 03:02
Build and install erlang on mountain lion

...with GNU stow. Also, Xcode is assumed already being installed here.

Yes, there is a much smaller command line version of Xcode. And it is officially supported. But an error arose when I tried to execute, say, brew install python --framework. Full version of Xcode has no such issue though.

Anyway:

$ brew install stow
$ mkdir -p /usr/local/stow
$ export STOW_DIR=/usr/local/stow
@edwardw
edwardw / zero_env.sh
Created January 29, 2012 02:39
Build OpenJDK Zero VM on Mac OS X

Prerequisites

  • A bootstrap JDK. I used 6u29.

  • LLVM 3.0 installed.

Build it

$ hg clone http://hg.openjdk.java.net/jdk7u/jdk7u-osx/
@edwardw
edwardw / gist:1622529
Created January 16, 2012 19:32
Launch programs at login in Mac OS X

Three ways to launch a program automatically when Mac OS X starts up: Login items, Startup items and launchd daemons (nicely summarized here).

Login items is very convenient but seems to be only for GUI program. For shell script, it will run but leaves user a visible default editor with script in it! By creating a .plist file and putting it in user's own ~/Library/LaunchAgents directory instead of system-wide /Library/LaunchDaemons, problem solved. This post helped.

@edwardw
edwardw / gist:1609770
Created January 14, 2012 01:31
OpenIndiana Miscellaneous

Tunnel both TCP and DNS traffic over SSH

$ ssh -D 1080 -fN user@server

autossh seems to be more suitable for this task:

$ autossh -M 20000 -fN -D 1080 -i /path/to/key user@server
@edwardw
edwardw / gist:1540780
Created December 30, 2011 17:49
Hush, not Harsh

HBase: The Definitive Guide has a sample application called hush. But it can't run as is. As this writing, the latest release of HBase is 0.90.5, which lacks certain features the book needs, such as coprocessor. So hush even can't compile against 0.90.5 HBase jar. It requires HBase 0.91.0-SNAPSHOT. Revision 1130916, to be precise, according to the book's website. Lars George, the author, kindly provides such a distribution in his apache site. But hush still need some minor tweaks to function properly as advertised.

That's a lot of rough edges. The book should've done better in regard to explain how to run its own sample application. Or it might not be the book's fault. I read somewhere that a team picked another NoSQL database over HBase because they felt HBase has 'too many moving parts'. This is probably still true. Since Hadoop reaches 1.0 several days ago, HBase should be able to impr

@edwardw
edwardw / gist:1528044
Created December 28, 2011 14:07
Index wikipedia using ElasticSearch
$ bin/plugin -install elasticsearch/elasticsearch-river-wikipedia/1.0.0
$ bin/elasticsearch
$ curl -XPUT 192.168.1.6:9200/_river/
$ curl -XPUT 192.168.1.6:9200/_river/wikipedia/_meta -d '
{
    "type" : "wikipedia"
}'
@edwardw
edwardw / gist:1518437
Created December 24, 2011 22:00
Run a storm topology
$ mkdir ~/.storm
$ cp conf/storm.yaml ~/.storm
$ ...
$ bin/storm jar word-count.jar WordCountTopology

Storm is designed to be robust, e.g. being able to survive nimbus or supervisor restart. It does accomplish that, except one caveat. Say, I kill nimbus process and alter the content of storm.local.dir, in where nimbus has stored some states. Then I restart nimbus but it can't run! I guess it's because nimbus' state dir doesn't match those in zookeeper server's. By restarting zookeeper server process, everything works again.

@edwardw
edwardw / gist:1518116
Last active June 8, 2016 15:52
Install and start storm nimbus and supervisor

First, install storm dependencies. How do I compile jzmq for ZeroMQ on OSX? helps.

$ brew install zeromq
$ git clone https://github.com/nathanmarz/jzmq.git
$ cd jzmq
$ sudo vim /usr/share/aclocal/dirlist (sudo cat > /usr/share/aclocal/dirlist permission denied?)
/usr/local/share/aclocal
/usr/local/Cellar/pkg-config/0.25/share/aclocal/
$ export JAVA_HOME=/Library/Java/Home
@edwardw
edwardw / gist:1517994
Last active September 29, 2015 00:17
Install zookeeper on illumos and supervise it using SMF

Two interesting findings:

  • A utility called manifold that helps creating SMF manifest;
  • An annoying platform compatibility issue in zookeeper startup script.

Fist, install zookeeper:

$ wget -c http://www.takeyellow.com/apachemirror//zookeeper/stable/zookeeper-3.3.4.tar.gz
$ tar xvzf zookeeper-3.3.4.tar.gz