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
hhh@sparkfly-rails3 ~/work/sparkfly/benchmarks/metaprogramming $ uname -a | |
Linux sparkfly-rails3 2.6.31-gentoo-r10 #1 SMP Fri Mar 26 23:55:26 Local time zone must be set--see zic x86_64 Intel(R) Core(TM)2 Duo CPU P8800 @ 2.66GHz GenuineIntel GNU/Linux | |
hhh@sparkfly-rails3 ~/work/sparkfly/benchmarks/metaprogramming $ ruby -v | |
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] | |
hhh@sparkfly-rails3 ~/work/sparkfly/benchmarks/metaprogramming $ ruby bench_meta.rb | |
user system total real | |
instance_eval/str 68.230000 0.070000 68.300000 ( 88.718078) | |
class_eval/str 69.370000 0.050000 69.420000 ( 93.801272) | |
eval/str 70.800000 0.020000 70.820000 (100.582867) | |
define_method/class 48.570000 0.100000 48.670000 ( 65.632684) |
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
# NOOP | |
# | |
# Place in RAILS_ROOT/lib/csv.rb | |
# | |
# Short Description: I dare you to remove this file. | |
# | |
# Long Description: | |
# This file is needed so that active_record/fixtures.rb (for AR3) can load 'csv' library. Since this file | |
# comes before the standard library load path, this gets loaded instead. Otherwise, Ruby will | |
# complain because FasterCSV has changed the class signature of CSV::Row |
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
#http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/ | |
describe User do | |
subject { user } | |
let(:user) { User.new } | |
context "when name empty" do | |
it { should_not be_valid } | |
specify { user.save.should be_false } | |
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
# Ugly hack until PostgreSQL 9.1 comes out. | |
module Models | |
module GroupByHelper | |
extend ActiveSupport::Concern | |
included do | |
scope :group_by_all, lambda { group(self.column_names.map { |c| "#{self.table_name}.#{c}" }.join(',')) } | |
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
def explain! | |
puts 'Want to embed this Gist?' | |
puts 'Use this: <script src="http://gist.github.com/2059.js"></script>' | |
end | |
explain! |
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
Devops is for people who want to get their product out to their customers. | |
Devops is... | |
1. Software Eats Infrastructure. | |
http://online.wsj.com/article/SB10001424053111903480904576512250915629460.html | |
2. Disposable Resources. |
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
# Add this snippet at the bottom of your Gemfile | |
# This allows you to add gems for debugging that you may not want to | |
# version. | |
# If you want to load debugging tools into the bundle exec sandbox, | |
# add these additional dependencies into Gemfile.local | |
eval(IO.read(__FILE__ + '.local'), binding) if File.exists?(__FILE__ + '.local') |
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
Migrating from Chef 10 to Chef 11 | |
Strategy | |
We stand up a new Chef 11 server. We then download all the artifacts and data from Chef 10 using knife download, and then upload them to the Chef 11 server using knife upload. Since the data is saved into a repo before uploading, we can verify the data and modify it as needed. | |
Considerations | |
Chef 10 uses CouchDB. Chef 11 uses PostgreSQL. There are also changes in the underlying data. However, the data from the API are communicated in JSON and knife knows how to handle the differences between Chef 10 and 11. `knife upload` and `knife download` in knife-essentials will take us most of the way there. |
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
-- Copyright 2013 Opscode, Inc. All Rights Reserved. | |
-- | |
-- This file is provided to you under the Apache License, | |
-- Version 2.0 (the "License"); you may not use this file | |
-- except in compliance with the License. You may obtain | |
-- a copy of the License at | |
-- | |
-- http://www.apache.org/licenses/LICENSE-2.0 | |
-- | |
-- Unless required by applicable law or agreed to in writing, |
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
Failures: | |
1) Search API endpoint /search/node POST targeted toward many nodes with body of {"possibly_nested"=>["top", "middle", "bottom"], "the_name"=>["name"], "not_found"=>["foo", "bar", "baz", "totally_not | |
_a_real_field"], "empty"=>[]} should succeed, and return multiple nodes | |
Failure/Error: r.should look_like search_success_response | |
Expected a full match of the result | |
{"total"=>4, | |
"start"=>0, |