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
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'
# 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
require 'pp'
class HeighwayDragon
class Turtle
attr_accessor :x, :y, :direction, :dragon, :step
def initialize
@x = 0
@y = 0
@direction = :N
@step = 0
end
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?
# 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
}
#!/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.
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'pp'
pp JSON.parse(STDIN.read)
@hosh
hosh / gist:183912
Created September 9, 2009 17:32
Useful git aliases
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"
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
# 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