Skip to content

Instantly share code, notes, and snippets.

View abyx's full-sized avatar

Aviv Ben-Yosef abyx

View GitHub Profile
commentor.should_receive(:add).with(anonymous_comment)
@abyx
abyx / gol.rb
Created January 31, 2012 06:36
Final exercise at Corey Haines' Improving Your TDD workshop
class Board
def initialize
@living = []
end
def evolve_dead_cells
end
def add_living_cell(location)
# When doing this:
class SomeError < Exception
def initialize(some, args); end
end
describe 'bad message' do
it 'raises an exception' do
obj = stub
obj.should_receive(:dude!).and_raise(SomeError)
Object.const_defined? :Integer
#=> true
// Why write this..
public static <T, V> Map<T, List<V>> defaultdict_list() {
return new MapMaker().makeComputingMap(new Function<T, List<V>>() {
@Override public List<V> apply(T unusedCrap) {
return Lists.newArrayList();
}
});
}
# When you just want this (Python)
@abyx
abyx / 0001-Fix-SortedSet-to-ensure-objects-comparable-with.patch
Created June 8, 2011 08:24
Fix SortedSet to ensure objects comparable with <=>
From 9c168445300c6fda62173d37fbbbffa1a2136e03 Mon Sep 17 00:00:00 2001
From: Aviv Ben-Yosef <aviv.by@gmail.com>
Date: Wed, 8 Jun 2011 11:10:11 +0300
Subject: [PATCH] Fix SortedSet to ensure objects comparable with <=>
Fixes 2 failing specs for SortedSet:
- SortedSet#add takes only values which responds <=>
- SortedSet#initialize takes only values which respond to <=>
---
lib/set.rb | 1 +
@abyx
abyx / cart_dsl.rb
Created March 23, 2011 05:18
Start of DSL for shopping cart and sales from SCIL #7 by @TzipiZnavot, @eladsof & @AvivBY
describe 'cart' do
it 'allows discount after purchasing certain amount' do
product = Product.new('Snickers', 3)
cart = Cart.new
6.times { cart << product }
cart.when_buying(product).times(5).get(1).free()
cart.total.should == 5*3
name "appserver"
description "An application server"
run_list(%w{
recipe[apache2]
})
class default_node {
package { 'apache2':
ensure => installed
}
service { 'apache2':
ensure => true,
enable => true,
require => Package['apache2'],
}
}
@abyx
abyx / gist:746606
Created December 18, 2010 15:46
Original MVP code
public void bind() {
display.getSaveButton().addClickHandler(
new ClickHandler() {
@Override public void click(ClickEvent e) {
// Magic happens here
}
});
}