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 Breadcrumb | |
def breadcrumbs | |
if parent | |
parent.breadcrumbs << self | |
else | |
[self] | |
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
irb(main):001:0> thing | |
NameError: undefined local variable or method `thing' for main:Object | |
from (irb):1 | |
irb(main):002:0> defined? thing | |
=> nil | |
irb(main):003:0> thing = thing | |
=> nil | |
irb(main):004:0> thing | |
=> nil | |
irb(main):005:0> defined? thing |
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
# Spawned from this thread: http://rubyflow.com/items/1990 | |
module Enumerable | |
# Wraps an enumerable in an easy interface for selecting subsets. Comparison | |
# and method calls are supported. | |
# | |
# [0, 1, 2, 3].filter > 1 # => [2, 3] | |
# [0, 1, 2, 3].filter.zero? # => [0] | |
# | |
# Warning: Do not use this with the != operator, use filter_not instead. |
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 FilterableEnumerable | |
def initialize(original) | |
@original = original | |
end | |
def ==(value) | |
@original.select { |v| v == value } | |
end | |
def method_missing(sym, *args, &block) |
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 'rubygems' | |
require 'httparty' | |
require 'time' | |
require 'active_support' | |
File.read("#{ENV['HOME']}/.gitconfig").match(/token = (\w+)/) | |
TOKEN = $1 | |
class Github | |
include HTTParty |
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 ApplicationHelper | |
def self_url(options = {}) | |
url_for(request.path_parameters.merge(options)) | |
end | |
end | |
describe ApplicationHelper do | |
describe '#self_url' do | |
before(:each) do | |
# using params we can easily detect a reverse merge with |
NewerOlder