Skip to content

Instantly share code, notes, and snippets.

View bryanhunter's full-sized avatar

Bryan Hunter bryanhunter

View GitHub Profile
@bryanhunter
bryanhunter / CastleBootstrapper.cs
Created August 5, 2011 16:29
Castle bootstrapper for Caliburn.Micro
// Hooks up Castle Windsor as the container for your Caliburn.Micro application.
// Turns on support for delegate factory methods (e.g. passing the factory "Func<XyzEditViewModel>" as a constructor arg)
// Dependencies: In addition to Caliburn.Micro you will need to reference Castle.Core and Castle.Windsor
public class CastleBootstrapper<TRootViewModel> : Bootstrapper<TRootViewModel>
{
private ApplicationContainer _container;
protected override void Configure()
{
@bryanhunter
bryanhunter / gist:1118609
Created August 1, 2011 17:42
LINQ partition (specialization of GroupBy)
// @hammett: "Linq doesn't have a Partition operation that returns two sets? (filtered/complement).. sad!"
// GroupBy can be seen as a partition. We specialize it to have exactly two groups:
public static class PartitionExtension
{
public static Tuple<IEnumerable<T>, IEnumerable<T>> Partition<T>(this IEnumerable<T> enumeration, Func<T, bool> criteria)
{
var whole = enumeration.GroupBy(criteria);
@bryanhunter
bryanhunter / fizzbizz.erl
Created June 6, 2011 21:04
Erlang FizzBuzz with an eunit test
-module(fizzbuzz).
-export([playto/1]).
-include_lib("eunit/include/eunit.hrl").
playto(Upper) ->
[case
{X rem 3, X rem 5} of
{0, 0} -> fizzBuzz;
{0, _} -> fizz;
@bryanhunter
bryanhunter / install-r14b03.sh
Created May 25, 2011 19:28
Script to install Erlang 14B03 (tested on a fresh Ubuntu 11.04 install)
# You will need to make this file executable (chmod u+x) and run it with sudo
apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk
mkdir -p /src/erlang
cd /src/erlang
wget http://www.erlang.org/download/otp_src_R14B03.tar.gz
tar -xvzf otp_src_R14B03.tar.gz
chmod -R 777 otp_src_R14B03
cd otp_src_R14B03
./configure
make
@bryanhunter
bryanhunter / install-r14b02-on-11.04.sh
Created May 24, 2011 05:41
Install Erlang/OTP 14B02 on a clean Ubuntu 11.04 box
sudo apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk
sudo mkdir -p /src/erlang
cd /src/erlang
sudo wget http://www.erlang.org/download/otp_src_R14B02.tar.gz
sudo tar -xvzf otp_src_R14B02.tar.gz
sudo chmod -R 777 otp_src_R14B02
cd otp_src_R14B02
sudo ./configure
sudo make
sudo make install