This file contains hidden or 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
# http://bit.ly/10e2Jy | |
# Advances in Agent communication (Proceedings, 2003) | |
# Datastructure per agent | |
@name = 'Pete' | |
@knowledge = { | |
'a' => [['f', 'b'], ['c', 'd']], | |
'd' => [['e', 'b'], ['c']], | |
'p' => TRUE | |
} |
This file contains hidden or 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
def blah(x) | |
return 1 if x == 1 # Special case | |
return nil unless x > 1 | |
y = x.to_i/10.0 | |
z = 10**(Math.log10(y).ceil) | |
return (z/2).ceil if y <= z/2 | |
return z | |
end | |
# Does this work? |
This file contains hidden or 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
require 'pp' | |
class HeighwayDragon | |
class Turtle | |
attr_accessor :x, :y, :direction, :dragon, :step | |
def initialize | |
@x = 0 | |
@y = 0 | |
@direction = :N | |
@step = 0 | |
end |
This file contains hidden or 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
# Monkey-patch for Ruby Datamapper 0.9.11 to add index support | |
# Load this after gems have been loaded | |
# Ho-Sheng Hsiao <twitter:hosheng> | |
# | |
# index :user_id | |
# index :user_id, :forum_id | |
# This monkeypatch does not have support for something like index :user_index, [ :user_id, :forum_id ] | |
module DataMapper |
This file contains hidden or 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
The following is an example set of User Stories for a typical user registration: | |
Scenario: Unregistered User should see a link to user signup | |
GIVEN as an unregistered user | |
WHEN I go to the main site | |
THEN I should see a link to signup as a user | |
Scenario: Unregistered User should see a registration form | |
GIVEN as an unregistered user | |
WHEN I go click on 'signup' |
NewerOlder