I wrote this up here: http://blog.steveklabnik.com/posts/2012-02-27-hypermedia-api-reading-list
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 >>(other); self + [other]; end | |
def to_proc(*args) | |
->(r) { inject(r){ |o,(m,*args)| o.send(m,*args) } } | |
end | |
def apply(rec) | |
self.to_proc[rec] | |
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
Moved to https://github.com/apeiros/available |
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
require 'airbrake' | |
Airbrake.configure do |config| | |
config.api_key = AIRBRAKE_API_KEY | |
end | |
at_exit { | |
if $! | |
e = $! | |
Airbrake.notify( |
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
module Nulayer | |
class WebProxy | |
ENDPOINT = '/webp' | |
URL_PARAM_NAME = 'url' | |
attr_accessor :env, :params, :referred, :url | |
def initialize(env, params, referred=false) | |
self.env = env | |
self.params = params |
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
html { | |
font-family: "Monaco"; | |
background-color: #fdf6e3; | |
color: #657b83; | |
word-wrap: break-word; | |
margin: 0; | |
padding: 3px 4px 10px 4px; | |
} | |
body { |
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
jQuerify: | |
http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet | |
jQuery Snowfall: | |
http://www.somethinghitme.com/2011/10/05/jquery-snowfall-1-5-update-now-with-snow-buildup/ |
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
require 'hash/dirty' | |
# DirtyHash behaves just like Hash, but keeps track of changes applied to it. | |
# | |
# @example | |
# dh = DirtyHash.with :x => 1 | |
# dh.clean? # => true | |
# dh.update :y => 2, :z => 4 | |
# dh.changed # => {:y => [:added, 2], :z => [:added, nil, 4]} | |
# dh[:z] = 3 |
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
module StringEscaper | |
def process_escapes (str) | |
str.gsub! /\\(u\d{4}|\D)/m do | |
seq = $1 | |
case seq | |
when '/' then "\/" | |
when 'b' then "\b" | |
when 'f' then "\f" | |
when 'n' then "\n" | |
when 'r' then "\r" |
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
require "stateful" | |
class Folder < ActiveRecord::Base | |
include Stateful | |
# ... | |
stateful do | |
state :active | |
state :inactive |