Inspiration: https://gist.github.com/4436444
Resulting Query:
SELECT "orders".* FROM "orders" WHERE "orders"."id" IN (SELECT id FROM "orders" GROUP BY account_id ORDER BY order_date DESC)
group :assets do | |
gem 'sass-rails', '~> 3.2.3' | |
gem 'coffee-rails', '~> 3.2.1' | |
gem 'uglifier', '>= 1.0.3' | |
end |
require 'html/pipeline' | |
module MarkdownHandler | |
def self.call(template) | |
erb = ActionView::Template.registered_template_handler(:erb) | |
source = erb.call(template) | |
<<-SOURCE | |
pipeline = HTML::Pipeline.new [ |
# | |
# Install the MYSQL driver | |
# gem install mysql2 | |
# | |
# Ensure the MySQL gem is defined in your Gemfile | |
# gem 'mysql2' | |
# | |
# And be sure to use new-style password hashing: | |
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
development: |
Inspiration: https://gist.github.com/4436444
Resulting Query:
SELECT "orders".* FROM "orders" WHERE "orders"."id" IN (SELECT id FROM "orders" GROUP BY account_id ORDER BY order_date DESC)
def silencer | |
require 'java' | |
java_import 'java.io.PrintStream' | |
java_import 'java.io.ByteArrayOutputStream' | |
java_import 'java.lang.System' | |
sys_out_stream = System.out | |
my_output_stream = ByteArrayOutputStream.new |
During RubyOffRails office hours, I was asked how we could test that puts
was called at the end of a method. Something like so:
def super_awesome_method
#...
puts the_thing
end
describe Fixnum do | |
it "should add 2 + 2 and return 4" do | |
@two = 2 | |
result = @two+ @two | |
result.should eq(4) | |
end | |
end | |
class Calculator |
require 'celluloid' | |
module Enumerable | |
def pmap(&block) | |
futures = map { |elem| Celluloid::Future.new(elem, &block) } | |
futures.map { |future| future.value } | |
end | |
end | |
puts "let's do this without celluloid!" |
(this started on twitter)
The microposts spec starts out with
let(:user) { FactoryGirl.create(:user) }
before do
# This code is wrong!
@micropost = Micropost.new(content: "Lorem ipsum", user_id: user.id)
end
config.omniauth :facebook, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, { :scope => 'user_status,publish_stream' } | |
config.omniauth :twitter, TWITTER_KEY, TWITTER_SECRET |