Skip to content

Instantly share code, notes, and snippets.

View jwo's full-sized avatar

Jesse Wolgamott jwo

View GitHub Profile
@jwo
jwo / Gemfile
Created May 2, 2013 02:48
Gems for a Rails 3.2 Application
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
@jwo
jwo / markdown_handler.rb
Created April 10, 2013 19:44
Github flavored markdown on rails 4.0
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 [
@jwo
jwo / mysql.database.yml
Last active March 28, 2025 04:51
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# 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:
@jwo
jwo / README.md
Created January 2, 2013 19:12
Inner Query example in active record

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)
@jwo
jwo / silencer.rb
Created January 1, 2013 21:09
JRuby capture of System.out.println
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
@jwo
jwo / README.md
Created December 7, 2012 21:14
Overriding puts

What the What?

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
@jwo
jwo / the_tests_and_specs.rb
Created November 30, 2012 19:34
message vs value expection (for @RubyoffRails)
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
@jwo
jwo / the-cell-map.rb
Created November 2, 2012 13:58
Celluloid simplistic example
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!"
@jwo
jwo / 1_explanation.md
Created October 29, 2012 16:41
No Instance Variables in Specs (for @Blighte)

(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
@jwo
jwo / devise.rb
Created October 13, 2012 17:36
OmniAuth with Twitter
config.omniauth :facebook, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, { :scope => 'user_status,publish_stream' }
config.omniauth :twitter, TWITTER_KEY, TWITTER_SECRET