View gist:1538
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$logger = Object.new { | |
#now I want to override stuff in here | |
def foo | |
"bar" | |
end | |
} |
View gist:1545
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$s = Time.now | |
$logger = Object.new | |
def $logger.method_missing(sym, *args) | |
puts "[%s, %.3f] %s" % [sym.to_s.upcase, Time.now - $s, args.join(' ')] | |
end | |
View gist:1985
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PedAssignOptions < Struct.new(:links_file, :access_file, :walk_int_file, :output_file); end | |
class ParseFail < Struct.new(:reason); end | |
class ArgvParser | |
def parse argv | |
if argv.size == 1 and ['-h','--help'].include? argv.first then | |
return :help | |
end | |
if argv.length != PedAssignOptions.members.size then | |
return ParseFail.new("Incorrect number of arguments, got #{argv.size} expected #{PedAssignOptions.members.size}") |
View gist:1992
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
BASEDIR=`dirname $0` | |
JAVA_OPTS="-Xmx2048m -Xms2048m -Xmn512m -server" | |
MAIN="start" | |
CP=$BASEDIR/../lib/jruby.jar:$BASEDIR/../lib/jgrapht-jdk1.5.jar:$BASEDIR/../lib/ped-assign.jar | |
java -cp $CP $JAVA_OPTS $MAIN $* |
View gist:2344
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vlc.beach.zoning; | |
import static com.googlecode.instinct.expect.Expect.expect; | |
import com.googlecode.instinct.integrate.junit4.InstinctRunner; | |
import com.googlecode.instinct.marker.annotate.Mock; | |
import com.googlecode.instinct.marker.annotate.Specification; | |
import static com.vlc.beach.zoning.SpecNotWorkingContext.Applicator.applicator; | |
import fj.F; | |
import org.jmock.Expectations; | |
import org.junit.runner.RunWith; |
View gist:3210
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private <A,T> Runnable combine(final Callable<T> c, final Actor<T> a) { | |
return new Runnable() { | |
public void run() { | |
try { | |
a.act(c.call()); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
}; |
View gist:3232
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vlc; | |
import static com.googlecode.instinct.expect.Expect.expect; | |
import com.googlecode.instinct.integrate.junit4.InstinctRunner; | |
import com.googlecode.instinct.marker.annotate.Specification; | |
import org.jmock.Expectations; | |
import org.junit.runner.RunWith; | |
@RunWith(InstinctRunner.class) | |
public final class InstinctFailContext { |
View gist:3993
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Specification | |
public void shouldThrowOnInvalidLines() { | |
expectException(VlcRuntimeException.class, "Invalid dimension definition, expected 3 tokens: 200-12", new Runnable() { | |
public void run() { | |
dimensionCreator.apply(invalidLine1); | |
} | |
}); | |
expectException(VlcRuntimeException.class, "Invalid dimension definition, types incorrect: 200-12-A", new Runnable() { | |
public void run() { | |
dimensionCreator.apply(invalidLine2); |
View gist:4166
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vlc; | |
import static com.googlecode.instinct.expect.Expect.expect; | |
import com.googlecode.instinct.integrate.junit4.InstinctRunner; | |
import com.googlecode.instinct.marker.annotate.Specification; | |
import org.jmock.Expectations; | |
import org.junit.runner.RunWith; | |
@RunWith(InstinctRunner.class) | |
public final class InstinctFailContext { |
View gist:9365
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TreeBuilder | |
def build a | |
root_node = Node.new(a) | |
yield root_node if block_given? | |
root_node.as_tree | |
end | |
class Node | |
def initialize value | |
@value = value |
OlderNewer