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
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' |
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
# 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 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 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 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 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 | |
# README: | |
# Having had to use MacOSX, I still prefer using Visor + MacVIM. However, Visor uses Terminal.app. | |
# Unlike iTerm, Terminal does not support changing the name of the tab. There are two hacks out in | |
# the wild: | |
# (1) Run a background process with the name you want to use | |
# (2) Hardlink ssh, then call that hardlinked ssh | |
# | |
# This script automates the method (2), however, instead of using ssh, we use screen. This has the | |
# additional bonus of being able to access screen's ability to detach sessions. |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'json' | |
require 'pp' | |
pp JSON.parse(STDIN.read) |
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
Some useful git aliases | |
[alias] | |
co = checkout | |
info = config --list | |
last = log -n 1 | |
rollback = reset HEAD~1 | |
unindex = reset HEAD | |
ready = "!git add -u . ; git diff --cached" |
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
task :after_update_code, :roles => [:db] do | |
run <<-EOF | |
cd #{release_path} && | |
rm -fr db && ln -ns #{shared_path}/db db && | |
cp config/database.yml.production config/database.yml && | |
git submodule update --init | |
EOF | |
end |
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 for inspecting descendents of ActiveRecord and ActionMailer in a simple tree form. | |
# Works with Rails 2.3.5 | |
# INSTALL | |
# Drop this into lib/tasks | |
# USAGE | |
# rake stats:models | |
# rake stats:mailers |
OlderNewer