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
require 'formula' | |
class ScalaDocs < Formula | |
homepage 'http://www.scala-lang.org/' | |
url 'http://www.scala-lang.org/downloads/distrib/files/scala-docs-2.9.2.zip' | |
md5 '48d9102789bf696d3d8621fb24ed47da' | |
end | |
class ScalaCompletion < Formula | |
homepage 'http://www.scala-lang.org/' |
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
require 'test_helper' | |
class MyHelperTest < ActionView::TestCase | |
test "title" do | |
assert_select_in '<h1>My Awesome App</h1>', 'h1' | |
end | |
test "nav" do | |
html = '<div id="nav"><a href="/">Home</a></div>' | |
assert_select_in html, 'div' do |
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
require 'rubygems' | |
require 'prawn' | |
require 'prawn/measurement_extensions' | |
require 'prawn/fast_png' | |
require 'RMagick' | |
image = Magick::Image.new(300,300) do | |
self.background_color = 'black' | |
self.depth = 8 # without this it breaks in Windows | |
self.format = 'PNG' |
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
def set(value) | |
if # ... | |
# code elided for clarity | |
elsif tag_name == 'input' and type == 'checkbox' | |
# node.toggle # => JS event not fired | |
node.click # => JS event fired | |
end | |
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
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) | |
# Major.create(:name => 'Daley', :city => cities.first) | |
require 'faker' |
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
require 'active_support/ordered_hash' | |
require 'active_support/core_ext/enumerable' | |
module Enumerable | |
def group_by_attribute(attr, options={:nils_first => true}) | |
raise "attr parameter must by a symbol" unless attr.is_a?(Symbol) | |
h = group_by(&attr) | |
returning h2 = ActiveSupport::OrderedHash.new do | |
h2[nil] = h.delete(nil) if options[:nils_first] && h.has_key?(nil) | |
h2.merge!(h) |
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
# mongo_template.rb | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" | |
run "rm public/javascripts/dragdrop.js" | |
run "rm public/javascripts/effects.js" | |
run "rm public/javascripts/prototype.js" |
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
# Slight modifications to code posted by Gregory Brown at http://pastie.org/515450 | |
require 'delegate' | |
module Decoration | |
def decorator_for(*types, &block) | |
types.each do |type| | |
decorators[type] = Module.new(&block) | |
end | |
end |