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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
def render_error(status, exception) | |
render template: "errors/error_#{status}", layout: 'layouts/application', status: status | |
end | |
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
$ history | awk {'print $2, $3, $4'} | sort | uniq -c | sort -k1 -rn | head -n 30 | |
610 git status | |
568 git commit -m | |
491 git add . | |
252 git push origin | |
176 bundle | |
138 rails s | |
128 ls | |
120 git commit --amend | |
114 git reset --hard |
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 CanCook | |
def bake(food_name) | |
"I'm baking the #{food_name}!" | |
end | |
end | |
class Programmer | |
def initialize | |
self.extend CanCook | |
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
module Prepending | |
def append_features(base) | |
prepend = self | |
base.define_singleton_method(:new) do |*args, &block| | |
super(*args, &block).extend(prepend) | |
end | |
end | |
end | |
module CanCook |
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 Prepending | |
def append_features(base) | |
prepend = self | |
base.extend Module.new { define_method(:new) { |*args,&block| super(*args,&block).extend(prepend) }} | |
end | |
end | |
module CanCook | |
extend Prepending |
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 "prepend" | |
module CanCook | |
def bake(food_name) | |
"I'm baking the #{food_name}!" | |
end | |
end | |
class Programmer | |
def bake(food_name) | |
"I don't know how to bake #{food_name} :(" |
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 CanCook | |
def override_bake(food_name) | |
"I'm baking the #{food_name}!" | |
end | |
end | |
class Programmer | |
def bake(food_name) | |
"I don't know how to bake #{food_name} :(" |
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 Programmer | |
def bake(food_name) | |
"I don't know how to bake #{food_name} :(" | |
end | |
end | |
class Programmer | |
alias_method :_real_bake, :bake | |
def bake(food_name) | |
"I'm baking the #{food_name}!" |
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 CanCook | |
def self.included(base) | |
base.class_eval do | |
remove_method :bake | |
end | |
end | |
def bake(food_name) | |
"I'm baking the #{food_name}!" | |
end | |
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
module CanCook | |
def bake(food_name) | |
"I'm baking the #{food_name}!" | |
end | |
end | |
class Programmer | |
def bake(food_name) | |
"I don't know how to bake #{food_name} :(" | |
end |