Skip to content

Instantly share code, notes, and snippets.

~$ gem uninstall bundler
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d bundler`
~$ gem list -d bundler
*** LOCAL GEMS ***
bundler (1.0.0.rc.5)
Authors: Carl Lerche, Yehuda Katz, André Arko
Rubyforge: http://rubyforge.org/projects/bundler
@another_query = connection.execute "SELECT * FROM table_of_love"
current_id = connection.select_value("SELECT MAX(id) FROM #{table_name}").to_i
pg_conn = connection.raw_connection
pg_conn.exec("COPY #{table_name} (#{column_names.join(',')}) FROM STDIN WITH CSV QUOTE AS '\"'")
pg_conn.put_copy_data ::FasterCSV.generate(csv_opts) { |csv|
@another_query.all_hashes.each do |hash|
csv << column_names.inject([]) { |row,col| row << (col == 'id' ? current_id+=1 : hash[col].kind_of?(String) ? Iconv.conv('UTF8//IGNORE','LATIN1',hash[col].to_s) : hash[col]); row }
end
}
--- /usr/lib/ruby/gems/1.8/gems/analogger-0.5.0/src/swiftcore/Analogger.rb 2009-04-14 16:52:11.000000000 -0500
+++ Analogger.rb 2009-04-14 16:50:16.000000000 -0500
@@ -65,12 +65,63 @@
}
end
- def daemonize
- if (child_pid = fork)
- puts "PID #{child_pid}" unless @config[Cpidfile]
- exit!
/usr/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/handler/mongrel.rb:74:in `process': undefined method `flush' for #<Mongrel::MongrelProtocol:0xb73f1274> (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/response.rb:110:in `each'
from /usr/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/response.rb:110:in `each'
from /usr/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/handler/mongrel.rb:72:in `process'
from /usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.4/src/swiftcore/evented_mongrel.rb:170:in `dispatch_to_handlers'
from /usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.4/src/swiftcore/evented_mongrel.rb:169:in `each'
from /usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.4/src/swiftcore/evented_mongrel.rb:169:in `dispatch_to_handlers'
from /usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.4/src/swiftcore/evented_mongrel.rb:153:in `process_http_request'
from /usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.4/src/swiftcore/evented_mongrel.rb:65:in `receive_data'
fro
310 # This all happens inside a transaction, _if_ the Transactions module is included into
311 # ActiveRecord::Base after the AutosaveAssociation module, which it does by default.
312 def save_has_one_association(reflection)
313 if association = association_instance_get(reflection.name)
314 debugger unless association.respond_to?(:new_record?)
=> 315 if reflection.options[:autosave] && association.marked_for_destruction?
316 association.destroy
317 elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || reflection.options[:autosave]
318 association[reflection.primary_key_name] = id
319 association.save(false)
Scenario: obtaining details about widget parts
Given I have a widget named "larry"
And widget "larry" has the following parts:
|name|
|foo|
|bar|
|baz|
And I am logged in
When I go to the widget page for "larry"
Then I should see the following parts:
class Foo
has_many :bars
has_many :bazs
end
class Bar
belongs_to :foo
has_many :bazs, :through => :foo
end

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

#!/usr/bin/env ruby
# Complete rake tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default rake
# to your ~/.bashrc
# Nicholas Seckar <nseckar@gmail.com>
exit 0 unless File.file?(File.join(Dir.pwd, 'Rakefile'))
exit 0 unless /^rake(?:\s+([-\w]+))?\s*$/ =~ ENV["COMP_LINE"]
#! /bin/bash
DIR=`dirname $0`
progname=`basename $0`
PRG=`cd $DIR; pwd `/$progname
if [ -r /etc/default/backup_etc ]
then
. /etc/default/backup_etc
fi