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
Fixture.class_eval do | |
def find | |
if model_class | |
if model_class.respond_to?(:find_with_deleted) | |
model_class.find_with_deleted(self[model_class.primary_key]) | |
else | |
model_class.find(self[model_class.primary_key]) | |
end | |
else | |
raise FixtureClassNotFound, "No class attached to find." |
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
class ThreadFactory | |
if ENV['RAILS_ENV'] == 'development' | |
class FakeThread | |
def initialize(&block) | |
block.call | |
end | |
end | |
def initialize(&block) | |
FakeThread.new(&block) |
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
# A fast, clean grep for code in a rails directory | |
function g { | |
grep -nwrsI --color $1 app/ config/ vendor/ script/ test/ db/ public/ | |
# The version below shows two lines of context around the match | |
# grep -nwrsIC1 --color $1 app/ config/ vendor/ script/ test/ db/ public/ | |
} | |
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
# Prerequisites | |
# 1. Your commit messages contain ticket numbers such as "Ticket #1234" | |
# 2. Your collaborators create branches named exactly for the ticket number. So for example, bob/1234 | |
# | |
# Usage: merged_branches [remote_name] | |
# Output: A list of branches (tickets) that have already been merged (can be found in your log) | |
# | |
function merged_branches { | |
for branch in `git branch -a | grep $1 | awk '{ print $1 }' | awk -F"/" '{print $2}'` | |
do |
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
# Creates the ability to lazily initialize | |
# a class. This means the instance will not | |
# be created until a method is called on it. | |
# Useful for objects that create connections or | |
# use other expensive resources. | |
# | |
# example: | |
# | |
# class ExpensiveObject | |
# def initialize |
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/bash | |
cvs -z3 -d:pserver:[email protected]:/cvsroot/tidy co -P tidy | |
cd tidy | |
sh build/gnuauto/setup.sh | |
./configure --prefix=/usr | |
make && sudo make install |
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
[user] | |
name = yan | |
email = [email protected] | |
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
interactive = auto | |
ui = auto | |
log = auto |
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
# debugging from console...parse calendar | |
# note the #first call at the end, because the calendar seems to come | |
# in a one element array (not sure why) | |
cal = RiCal.parse_string(File.read("tmp/feeds/1_revolution_cafe/1f66991912759009fd90a29331e4a3f1")).first | |
# grab the first event | |
event = cal.events.first |
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
# load your libs | |
Dir[File.join(File.dirname(__FILE__),"../gems/*/lib")].each { |f| $LOAD_PATH << f } | |
# add all my app files to the load path so I can require 'app_file_name' | |
# note that this assumes all your code lives in dirs one level up from test | |
# if you have many subdirectories you can use a glob like "../**/*" to get all subdirs | |
Dir[File.join(File.dirname(__FILE__),"../*")].each {|f| $LOAD_PATH << f } | |
require 'test/unit' |
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
# Load gems so we can load the shoulda tasks | |
Dir[File.join(File.dirname(__FILE__),"gems/*/lib")].each { |f| $LOAD_PATH << f } | |
require 'rake' | |
require 'rake/testtask' | |
require 'shoulda/tasks' | |
task :default => [:test_units] | |
desc "Run basic tests" |
OlderNewer