Skip to content

Instantly share code, notes, and snippets.

View hosh's full-sized avatar

Ho-Sheng Hsiao hosh

  • Remine
  • Phoenix, AZ
View GitHub Profile
# 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
}
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?
require 'pp'
class HeighwayDragon
class Turtle
attr_accessor :x, :y, :direction, :dragon, :step
def initialize
@x = 0
@y = 0
@direction = :N
@step = 0
end
# 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
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'