Skip to content

Instantly share code, notes, and snippets.

edwardw / gist:1622529
Created Jan 16, 2012
Launch programs at login in Mac OS X
View gist:1622529

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 /
Created Jan 29, 2012
Build OpenJDK Zero VM on Mac OS X


  • A bootstrap JDK. I used 6u29.

  • LLVM 3.0 installed.

Build it

$ hg clone
edwardw / gist:3411110
Created Aug 21, 2012
Build and install erlang on mountain lion
View gist:3411110

...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.


$ brew install stow
$ mkdir -p /usr/local/stow
$ export STOW_DIR=/usr/local/stow
edwardw / gist:3780436
Created Sep 25, 2012
Double negation in gitignore
View gist:3780436

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

# Include js directory
edwardw / gist:4138639
Created Nov 24, 2012
Install numpy/scipy on mountain lion
View gist:4138639

Scipy Superpack is kind nice, but it seems to be inactive for a while and I want every thing under my complete control. So I went on installing them myself under homebrew-ed python.


$ brew install python
$ brew install gfortran swig


edwardw / gist:5036535
Created Feb 26, 2013
Install octave-forge miscellaneous package in homebrew octave
View gist:5036535

There are some mysterious errors when trying to install miscellaneous package from octave-forge:

error: variable length array of non-POD element type 'Array<octave_idx_type>'

etc. This happens to homebrew-ed octave 3.6.4.

The issue seems to have something to do with clang, the default compiler homebrew uses to install octave. The solution for now is to use gcc instead:

$ export CXX=llvm-g++-4.2 
edwardw /
Last active Dec 15, 2015
Go Concurrency Challenge in Rust

An adaption of Leah Hanson's solution using Rust macros. The original go challenge goes here.

Compiled with Rust 0.5.

use core::task::spawn;
use core::pipes::{stream,Port,Chan,SharedChan};

macro_rules! compute_and_send(
    ($inp:expr, $port:ident) => (
edwardw / gist:7587876
Created Nov 21, 2013
Boot to Rust in OS X
View gist:7587876

Booting to Rust by Eric Holk! It is just mind-bogglingly cool. What else can I say? His enhancement to Rust has been landed so it is time for me to try that out, in OS X. The setup of the toolchain could be a little bit challenging.

First and foremost, check out the latest Rust with win64 calling convention contributed by Eric Holk and build it.

Then prepare the cross linker.

$ wget
$ tar xvzf binutils-2.23.2.tar.gz
$ cd binutils-2.23.2
$ mkdir dist
edwardw / issue22077.patch
Last active Aug 29, 2015
A fix for #22077 on top of #22338
View issue22077.patch
diff --git a/src/librustc_typeck/check/ b/src/librustc_typeck/check/
index 2f3bd5d..5a319a6 100644
--- a/src/librustc_typeck/check/
+++ b/src/librustc_typeck/check/
@@ -9,31 +9,35 @@
// except according to those terms.
use middle::infer::InferCtxt;
-use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation,
- SelectionContext, ObligationCause};
edwardw /
Last active Dec 21, 2016
Determine java class hierarchies programmatically
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;