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 MockIO | |
def initialize(receiver = nil) | |
@buffer = "" | |
@receiver = receiver || MockIO.new(self) | |
end | |
def gets | |
1000.times do |n| | |
sleep 0.01 if n > 800 # throttle if it seems to be taking a while | |
unless @buffer.empty? |
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
orders = {} | |
all_orders.group_by(&:ItemCode).each do |item_code, code_orders| | |
orders[item_code] = {} | |
code_orders.group_by(&:year).each do |year, year_orders| | |
orders[item_code][year] = {} | |
year_orders.group_by(&:month).each do |month, month_orders| | |
orders[item_code][year][month] = month_orders.first.quantity | |
end | |
orders[item_code][year]["total"] = orders[item_code][year].values.map(&:to_f).sum | |
end |
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
==> Downloading http://downloads.sourceforge.net/project/ghostscript/GPL%20Ghost | |
File already downloaded and cached to /Users/rbates/Library/Caches/Homebrew | |
==> Downloading http://www.ijg.org/files/jpegsrc.v7.tar.gz | |
File already downloaded and cached to /Users/rbates/Library/Caches/Homebrew | |
==> ./configure --prefix=/usr/local/homebrew/Cellar/ghostscript/8.70 --disable-d | |
==> make install | |
/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 -I/usr/local/homebrew/include -Wall -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after-statement -fno-builtin -fno-common -DHAVE_STDINT_H -DGX_COLOR_INDEX_TYPE="unsigned long int" -mmmx -msse4.2 -w -pipe -fomit-frame-pointer -mmacosx-version-min=10.6 -O3 -I./base -o ./obj/genconf ./base/genconf.c | |
/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 -I/usr/local/homebrew/include -Wall -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after- |
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
# Example of nested resource with CanCan | |
class CommentsController < ApplicationController | |
before_filter :load_and_authorize_resource | |
# ... | |
protected | |
def load_resource | |
@article = Article.find(params[:article_id]) |
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
# Attempting to connect to a C# WSDL | |
>> driver = SOAP::WSDLDriverFactory.new("...").create_rpc_driver | |
ignored element: {http://schemas.xmlsoap.org/ws/2004/09/policy}Policy | |
ignored attr: {http://www.w3.org/2006/05/addressing/wsdl}Action | |
ignored element: {http://schemas.xmlsoap.org/ws/2004/09/policy}PolicyReference | |
ignored element: {http://schemas.xmlsoap.org/wsdl/soap12/}binding | |
ignored element: {http://schemas.xmlsoap.org/wsdl/soap12/}operation | |
ignored element: {http://schemas.xmlsoap.org/wsdl/soap12/}body | |
ignored element: {http://schemas.xmlsoap.org/wsdl/soap12/}fault | |
ignored element: {http://schemas.xmlsoap.org/wsdl/soap12/}address |
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
/* Given these SQL commands */ | |
update books set author="Bob" where id=1; | |
update books set author="John" where id=2; | |
update books set author="Bob" where id=3; |
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
~/code% gem install rails --pre | |
ERROR: While executing gem ... (NoMethodError) | |
undefined method `name' for "\\Aactivesupport\\Z":String | |
~/code% gem install rails --pre | |
ruby(81212,0xa08b2720) malloc: *** error for object 0x7ced40: Non-aligned pointer being freed (2) | |
*** set a breakpoint in malloc_error_break to debug | |
ERROR: While executing gem ... (NoMethodError) | |
undefined method `name' for ["=", #<Gem::Version "1.1.0.dev.20100209">]:Array |
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
% cucumber features | |
/Users/rbates/.rvm/rubies/ruby-head/lib/ruby/1.9.1/rubygems.rb:761: [BUG] Segmentation fault | |
ruby 1.9.2dev (2010-02-24 trunk 26744) [x86_64-darwin10.0.0] | |
-- control frame ---------- | |
c:0028 p:0205 s:0109 b:0109 l:000108 d:000108 METHOD /Users/rbates/.rvm/rubies/ruby-head/lib/ruby/1.9.1/rubygems.rb:761 | |
c:0027 p:0203 s:0103 b:0103 l:000102 d:000102 METHOD /Users/rbates/.rvm/rubies/ruby-head/lib/ruby/1.9.1/rubygems.rb:212 | |
c:0026 p:0090 s:0086 b:0086 l:000085 d:000085 METHOD /Users/rbates/.rvm/rubies/ruby-head/lib/ruby/1.9.1/rubygems.rb:1042 | |
c:0025 p:0015 s:0080 b:0080 l:000079 d:000079 METHOD /Users/rbates/.rvm/gems/ruby-head/gems/cucumber-0.6.2/lib/cucumber/formatter/ansicolor.rb:102 | |
c:0024 p:0180 s:0076 b:0076 l:002518 d:002518 CLASS /Users/rbates/.rvm/gems/ruby-head/gems/cucumber-0.6.2/lib/cucumber/formatter/ansicolor.rb:138 |
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
get "/about" => 'info#about', :as => 'about' | |
get "/privacy" => 'info#privacy', :as => 'privacy' | |
get "/license" => 'info#license', :as => 'license' | |
get "/mission" => 'info#mission', :as => 'mission' | |
get "/contact" => 'info#contact', :as => 'contact' |
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
namespace :deploy do | |
desc "Make sure there are no changes that need to be pushed." | |
task :check_revision, :roles => :web do | |
unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
puts "WARNING: HEAD is not the same as origin/master" | |
puts "Run `git push` to sync changes." | |
exit | |
end | |
end | |
end |