Skip to content

Instantly share code, notes, and snippets.


Mike Kelly mikekelly

View GitHub Profile
ssfrr / orders.json
Last active Aug 29, 2015
Simplified HAL
View orders.json
"self": {"href":"/orders"},
"next":{"href": "/orders?page=2"},
moiristo / gist:1245170
Created Sep 27, 2011
Rails3 way to redirect non-www domain to www domain
View gist:1245170
# Rails3 way to redirect non-www domain to www domain
# Single domain redirect
''.tap do |host|
constraints(:host => host) do
match '/(*path)', :to => redirect { |params, request| Addressable::URI.escape request.url.sub(host, "www.#{host}") }
View gist:1907466
~/Code/ember.js ‹ruby-1.9.3› ‹master*› $ bundle && echo "fuck you giles"
Using rake (
Using confparser (
Using multi_json (1.0.4)
Using execjs (1.2.13)
Using libxml-ruby (2.2.2)
Using faster_xml_simple (0.5.0)
Using httpclient (2.2.4)
Using json (1.6.5)
Using nokogiri (1.5.0)
kmayer / brand_sweeper.rb
Created Mar 31, 2012
TDD Action Caching in Rails 3
View brand_sweeper.rb
class BrandSweeper < ActionController::Caching::Sweeper
observe Brand # Observers will introspect on the class, but Sweepers don't
def after_update(brand)
expire_action :controller => "brand", :action => :preview, :brand_id => brand.to_param
domenic / hal-catalog.json
Created Apr 10, 2012
HAL version of catalog
View hal-catalog.json
"title": "Catalog for Domenic, page 1",
"description": "Contains lots of books, which is cool",
"_links": {
"self": { "href": "/docs?page=1" },
"next": { "href": "/docs?page=2" }
"_embedded": {
"": [
pironim / capybara cheat sheet
Last active Oct 5, 2015 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
mattwynne / sketch.rb
Created Jun 23, 2012 — forked from lukemelia/sketch.rb
sketch for Matt Wynne
View sketch.rb
class Organization
def to_param
def saved?
rand > 0.5
jxson / hal-plugin.js
Created Oct 18, 2012
HAL Chai plugin
View hal-plugin.js
module.exports = function(chai, utils){
var Assertion = chai.Assertion
, assert = chai.assert
Assertion.addProperty('resource', function(){
var doc = this._obj
, message = utils.flag(this, 'message')
new Assertion(doc, message)'object')

Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.

Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi



Hypermedia APIs

"Follow your nose"

— Roy T. Fielding


"build scalable, flexible implementations that do not simply run on the Web, but that actually exist in the Web"