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
| module Foo | |
| def bar | |
| @bar ||= self.snakes | |
| end | |
| def bar=(val) | |
| @bar = val | |
| 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
| module Foo | |
| def self.included(base) | |
| class << base | |
| attr_accessor :bar | |
| end | |
| base.instance_eval do | |
| @bar ||= proc{self.snakes}.call | |
| 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
| module Foo | |
| def self.included(base) | |
| class << base | |
| attr_accessor :bar | |
| end | |
| base.instance_eval do | |
| @bar = "pig" | |
| 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
| #! /usr/bin/env ruby | |
| require 'rubygems' | |
| require 'chunky_png' | |
| image = ChunkyPNG::Image.from_file('input.png') | |
| h = image.dimension.height | |
| print "height #{h} \n" | |
| w = image.dimension.width | |
| print "width #{w} \n" |
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
| require 'spec_helper' | |
| describe Users::OmniauthCallbacksController do | |
| include Devise::TestHelpers | |
| before :each do | |
| @user = Factory.create(:user) | |
| request.env["devise.mapping"] = Devise.mappings[:user] | |
| 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
| # A sample Guardfile | |
| # More info at https://github.com/guard/guard#readme | |
| guard 'rspec', :version => 2, | |
| :cli => '--colour --drb --format documentation --fail-fast', | |
| :all_after_pass => false, | |
| :all_on_start => false, | |
| :keep_failed => false, | |
| :notify => true do | |
| watch(%r{^spec/.+_spec\.rb$}) |
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
| require 'spec_helper' | |
| describe Gig do | |
| before do | |
| @gig = Gig.new | |
| @gig.save | |
| end | |
| it "should belong to a user and validate the presence of a user" do |
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
| class TenCommandments | |
| # Had to change this method name, it didn't read well in my test suite. | |
| # t.should be_thou_shalt_not_kill??? Give me a break. Not idiomatic Ruby! | |
| # *I* would't be caught dead with those specs on. | |
| # def thou_shalt_not_kill | |
| # true | |
| # end | |
| # Much more idiomatic. Now my specs read like butter too. |
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
| class String | |
| def car | |
| self.match(/\s*(\S+)/) ? $1 : nil | |
| end | |
| def cbr(sep = ' ') | |
| self.split(sep).at(0) | |
| 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
| #!ruby | |
| require 'rubygems' | |
| require 'hpricot' | |
| require 'open-uri' | |
| require 'fileutils' | |
| prefix = Time.new.strftime("%F") | |
| FileUtils.mkdir(prefix) unless File.exists?(prefix) |