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
Merb::CustomFormats.add(:iphone) do | |
mime_type "application/xhtml+xml" | |
selector do |request, params| | |
request.user_agent && request.user_agent =~ /iPhone/i | |
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
#Controller | |
before :ensure_authenticated, :exclude => [:index, :show] | |
def new(project_id) | |
only_provides :html | |
@ticket = Ticket.new(:project_id => project_id) | |
display @ticket | |
end | |
# RSPEC |
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
class Array | |
def uniq_by(method) | |
results = [] | |
self.map do |e| | |
result = e.send(method) | |
results.include?(result) ? nil : (results << result; e) | |
end.compact | |
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
Transfigr.add(:textile) do | |
after_activation do | |
require 'redcloth' | |
end | |
def format! | |
RedCloth.new(target).to_html | |
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
#!/usr/bin/env ruby | |
module FooVersions | |
module Version_0_1_0 | |
def self.foo | |
:foo | |
end | |
module Constant1 | |
def self.foo |
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
class Exceptions < Merb::Controller | |
# handle NotFound exceptions (404) | |
def not_found | |
render :format => :html | |
end | |
# handle NotAcceptable exceptions (406) | |
def not_acceptable | |
render :format => :html |
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 display | |
result = open(gist_url).read | |
out = result.scan(/document.write\('(.*|\s*)'\)/)[1] | |
out.nil? ? "Not Found" : out[0] | |
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
def f(ra,n) | |
ra.inject(0){ |c, x| x.include? n ? c + 1 : c } | |
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
def f(ra,n) | |
ra.inject(0) { |r,x| r += 1 if x.include? n; r } | |
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
def f(ra,n) | |
ra.inject(0) { |r,x| r += 1 if x.include? n; r } | |
end |