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
class Importer | |
def parse_csv_file(csv_file) | |
File.open(csv_file) do |file| | |
ActiveRecordModel.transaction do | |
import_csv_stream(file) | |
end | |
end | |
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
class ForeignKeyMigration < ActiveRecord::Migration | |
def up | |
add_foreign_key :user_logins, :users, :dependent => :delete | |
end | |
def down | |
drop_foreign_key :user_logins, :users | |
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
string_array = %w( key1=val1 key2=val2 key3=val3 ) | |
some_hash = {} | |
string_array.each do |array_element| | |
key,val = array_element.split('=') | |
some_hash[key.to_sym] = val | |
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
class Float | |
def round(precision=0) | |
if precision == 0 | |
round_up? ? ceil : floor | |
else | |
multiple_of_ten = 10.0 ** Integer(precision).abs | |
if precision > 0 | |
if finite? | |
number = self * multiple_of_ten | |
if number.infinite? |
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
# creating a new feature | |
git flow feature start awesome-new-feature | |
# pushing to origin for other eyes | |
git flow feature publish awesome-new-feature | |
# tracking an existing remote feature branch | |
git flow feature track another-new-feature | |
# finishing a feature |
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
class Buggy | |
# assuming perform_operation and special_options exist... | |
def buggy_method(param=nil, options={}) | |
puts "\n\n\nDEBUG" | |
puts "param: #{param}" | |
puts "options: #{options}" | |
@instance_var = perform_operation(special_options(param, options)) | |
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
namespace :parallel do | |
desc "run all main specs, plugin_name specs and features in parallel with parallel:all[num_cpus]" | |
task :all, :count do |t, args| | |
Rake::Task['parallel:features'].execute(:count => args[:count]) | |
Rake::Task['parallel:spec'].execute(:count => args[:count], :path_prefix => '../vendor/plugins/plugin_name/spec') | |
Rake::Task['parallel:spec'].execute(:count => args[:count]) | |
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
class Array | |
def total(attr_name) | |
collect(&attr_name).compact.sum | |
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
cameron@cam-debian:~/projects/chc/chapp(rbx+*-)$ rake ts:conf --trace | |
(in /home/cameron/projects/chc/chapp) | |
DEPRECATION WARNING: Rake tasks in vendor/plugins/asset_packager/tasks, vendor/plugins/exception_logger/tasks, vendor/plugins/mapit/tasks, vendor/plugins/seed-fu/tasks, and vendor/plugins/state_machine/tasks are deprecated. Use lib/tasks instead. (called from __script__ at /home/cameron/.rvm/gems/rbx-master@chapp/gems/rails-2.3.14/lib/tasks/rails.rb:10) | |
** Invoke ts:conf (first_time) | |
** Invoke thinking_sphinx:configure (first_time) | |
** Invoke thinking_sphinx:app_env (first_time) | |
** Execute thinking_sphinx:app_env | |
** Invoke environment (first_time) | |
** Execute environment | |
rake aborted! |
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
cameron@cam-debian:~/.rvm/gems/jruby-1.6.3/gems/jruby-launcher-1.0.7-java$ cat gem_make.out | |
/home/cameron/.rvm/rubies/jruby-1.6.3/bin/jruby extconf.rb | |
make | |
make -f inc/Makefile-rules.mk CONF=unix SUBPROJECTS= .build-conf | |
make[1]: Entering directory `/home/cameron/.rvm/gems/jruby-1.6.3/gems/jruby-launcher-1.0.7-java' | |
make -f inc/Makefile-rules.mk jruby | |
make[2]: Entering directory `/home/cameron/.rvm/gems/jruby-1.6.3/gems/jruby-launcher-1.0.7-java' | |
mkdir -p build/unix/Linux | |
rm -f build/unix/Linux/argparser.o.d |