Skip to content

Instantly share code, notes, and snippets.

View jqr's full-sized avatar

Elijah Miller jqr

View GitHub Profile
module Breadcrumb
def breadcrumbs
if parent
parent.breadcrumbs << self
else
[self]
end
end
end
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
# 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.
class FilterableEnumerable
def initialize(original)
@original = original
end
def ==(value)
@original.select { |v| v == value }
end
def method_missing(sym, *args, &block)
require 'rubygems'
require 'httparty'
require 'time'
require 'active_support'
File.read("#{ENV['HOME']}/.gitconfig").match(/token = (\w+)/)
TOKEN = $1
class Github
include HTTParty
@jqr
jqr / gist:57524
Created February 3, 2009 13:30 — forked from anonymous/gist:57476
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