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
@hosh
hosh / person.rb
Created April 20, 2010 14:49
Sample Remarkable Macros
# In app/models/person.rb
class Person < ActiveRecord::Base
belongs_to :organization
validates_presence_of :name
validates_presence of :email
validates_uniqueness_of :email
end
@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"
# 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
}
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'pp'
pp JSON.parse(STDIN.read)
# 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'
require 'machinist/active_record'
require 'sham'
require 'faker'
# The one below is from an older version. In my newer version that works with rspec2,
# blueprints.rb is located in spec/support and the line below matches that. The advantage
# is that the generated spec_helper automatically loads anything under spec/support
require File.expand_path('blueprints.rb', File.dirname(__FILE__) + '/../spec/')
puts '', "Accounts ..."
module Animal
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def say
"animal"
end
end
#!/bin/sh
# Configuration
#CLOUD_ETH="eth0"
CLOUD_ETH="eth1" # Standard for Rackspace Cloud
CHEFSERVER="10.177.133.40"
# Do not edit below
ActionController::Routing::Routes.draw do |map|
map.root :controller => :home, :action => :index
map.resources :servicios
map.resources :nosotros
#map.servicios '/servicios/consultorias', :controller => 'servicios', :action => 'consultoria'
map.connect "/servicios/:action", :controller => "servicios"
end