Skip to content

Instantly share code, notes, and snippets.

View adelcambre's full-sized avatar

Andy Delcambre adelcambre

View GitHub Profile
Merb::Router.prepare do
# I don't like the name :condition for this
resources :users, :condition => /.*/ do
resources :comments
end
# match("/users/:id", :id => /.*/)
# match("/users/:user_id/comments", :user_id => /.*/)
end
options.scan(/(\w+)=(\w+)/).inject({}) { |h,(k,v)| h[k] = v; h }
@adelcambre
adelcambre / bench.rb
Created January 16, 2009 19:15 — forked from wycats/bench.rb
require "rubygems"
require "rbench"
RBench.run(500) do
report("memoed") do
Foo.memoed("hello")
end
report("unmemoed") do
Foo.unmemoed("hello")
end
#!/usr/bin/env ruby -KU
require "rubygems"
require "dm-core"
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.setup(:second, "sqlite3:///#{File.dirname(__FILE__)}/test.db")
class Customer
include DataMapper::Resource
def self.default_repository_name ; :default ; end
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
var url=document.location;
var links=document.getElementsByTagName('link');
var found=0;
for(var i = 0, l; l = links[i]; i++) {
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) {
found=l.getAttribute('href');
break;
}
#!/usr/bin/env ruby
require 'rubygems'
require 'httparty'
require 'pp'
TOKEN = 'token'
class Task
include HTTParty
@adelcambre
adelcambre / Gemfile
Created April 2, 2010 18:18 — forked from atmos/Gemfile
source :gemcutter
group :runtime do
gem 'sinatra', '~>1.0'
gem 'rack', '~>1.0.0'
end
# vim:ft=ruby
testing 00-metro
blah
testing 00-metro
@adelcambre
adelcambre / gist:4325305
Created December 18, 2012 05:26 — forked from schacon/gist:1
This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.