Skip to content

Instantly share code, notes, and snippets.

@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 / 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: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 / 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:4138639
Created November 24, 2012 06:21
Install numpy/scipy on mountain lion

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.

Prerequisite

$ brew install python
$ brew install gfortran swig

Scipy/Numpy

@edwardw
edwardw / gist:5036535
Created February 26, 2013 06:59
Install octave-forge miscellaneous package in homebrew octave

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
edwardw / rust_tasks_and_macros.md
Last active December 15, 2015 00:59
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
edwardw / gist:7587876
Created November 21, 2013 19:20
Boot to Rust in OS X

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 http://ftpmirror.gnu.org/binutils/binutils-2.23.2.tar.gz
$ tar xvzf binutils-2.23.2.tar.gz
$ cd binutils-2.23.2
$ mkdir dist
@edwardw
edwardw / issue22077.patch
Last active August 29, 2015 14:15
A fix for #22077 on top of #22338
diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs
index 2f3bd5d..5a319a6 100644
--- a/src/librustc_typeck/check/assoc.rs
+++ b/src/librustc_typeck/check/assoc.rs
@@ -9,31 +9,35 @@
// except according to those terms.
use middle::infer::InferCtxt;
-use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation,
- SelectionContext, ObligationCause};
@edwardw
edwardw / ClassHierarchy.java
Last active December 21, 2016 02:56
Determine java class hierarchies programmatically
import java.io.File;
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;