Skip to content

Instantly share code, notes, and snippets.

View sandro's full-sized avatar
☀️
Sharing Goodness

Sandro Turriate sandro

☀️
Sharing Goodness
View GitHub Profile
#!/usr/bin/env ruby
require 'rubygems'
require 'httparty'
class FakeRestJsonApi
include HTTParty
base_uri 'http://google.com/THIS_IS_A_FAKE_URL'
headers 'Accept' => 'application/json'
default_params :output => 'json'
class Array
DYNAMIC_MAPPER_REGEXP = /^map_([_a-zA-Z]\w*)_to_([_a-zA-Z]\w*)$/
def method_missing(method, *args, &block)
dynamic_mapper?(method) do |match|
map_dynamically(match[1], match[2])
end || super
end
def dynamic_mapper?(method)
@sandro
sandro / report.markdown
Created March 17, 2010 19:43 — forked from jamesgolick/gist:334347
benchmark regexp matching
require 'bench_press'
extend BenchPress
reps 1000
measure "=~" do
"abcdefg" =~ /a/
end