This file contains hidden or 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
# Mock, this isn't real | |
$ rake db:schema:version | |
-> saves to db/schema/schema-20100403232.rb | |
# Now you don't have the problem with the timestamp embedded | |
# into the db/schema.rb every time you do a db:schema:dump |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
I don't need this right now but I will need them for this current project over the summer. | |
Here's what I'm thinking: | |
- Build it on top of RESTClient | |
- On the surface, it should be compatible with ActiveResource | |
- Maybe take advantage of .to_model interface with ActiveORM in Rails3 | |
- Use Addressable as Jesse suggests, to construct the URL | |
- Defaults to Yajl, switchable to JSON gem | |
- Defaults to Nokogiri + libxml2 | |
- Pluggable backend: Net::HTTP or EventMachine's HTTP |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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. |