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
# 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 |
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
# 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
#!/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
# 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
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
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 ..." |
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
module Animal | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def say | |
"animal" | |
end | |
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
#!/bin/sh | |
# Configuration | |
#CLOUD_ETH="eth0" | |
CLOUD_ETH="eth1" # Standard for Rackspace Cloud | |
CHEFSERVER="10.177.133.40" | |
# Do not edit below |
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
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 |
NewerOlder