Skip to content

Instantly share code, notes, and snippets.

# prepend the mime type suggested by the path_info extname to the Accept: header,
# and pass on the request with suffix removed
module Rack
class SuffixAccept
def initialize(app)
@app = app
end
def call(env)
class Object
def interesting_methods
case self.class
when Class
self.public_methods.sort - Object.public_methods
when Module
self.public_methods.sort - Module.public_methods
else
self.public_methods.sort - Object.new.public_methods
end
@slowernet
slowernet / hash.rb
Created June 11, 2015 18:37
traverse a nested hash, yielding keypath and value
class Hash
# traverse a nested hash, yielding keypath and value
def walk(path = [], &block)
self.each do |k,v|
path.push(k)
v.is_a?(Hash) ? v.walk(path, &block) : yield(path, v)
path.pop
end
end
end

Why the Ruby community is wrong about soft tabs

chrome://net-internals/#events&q=type:SPDY_SESSION%20is:active
let's make a list of sinatra-based apps!
apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>. See in action @ www.restafari.org"
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"
module Merb
def self.cache
Merb::Controller._cache.store
end
end
class Merb::Cache::MemcacheStore
def fetch(key, options = {})
if !options[:force] && value = cache_get(key)
value
module Merb
module GlobalHelpers
def include_templates
rv = '<div style="display: none;" class="jqt-templates">'
rv += glob_dir("#{Merb.root}/app/views/shared").join
rv += glob_dir("#{Merb.root}/app/views/#{controller_name.downcase}").join
rv + '</div>'
end
private