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 OrderCollectionExtension | |
def revenue | |
self.sum(:payment_total_in_cents) | |
end | |
end | |
Order.non_zero_price.extend(OrderCollectionExtension).revenue |
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 Discountable | |
def to_discount_code | |
DiscountCode.find_by_code(self) | |
end | |
end | |
class DiscountCode < ActiveRecord::Base | |
def to_discount_code | |
self | |
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
"Change it until it works" used to be how I approached | |
metaprogramming - the ruby equivalent of kicking the | |
tires until the car starts. In this talk we'll gingerly | |
lift the hood and take a look at what's under there. | |
We'll start with a high-level overview to get some | |
context but quickly move on to various ways of inspecting | |
and manipulating objects, classes, and the metaclass. | |
You'll leave with a set of tools and techniques to make | |
metaprogramming more tangible and explorable. |
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
desc "Pings PING_URL to keep a dyno alive" | |
task :dyno_ping do | |
require "net/http" | |
if ENV['PING_URL'] | |
puts "Pinging #{ENV['PING_URL']}" | |
uri = URI(ENV['PING_URL']) | |
Net::HTTP.get_response(uri) | |
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
<html> | |
<head> | |
<script type="text/javascript"> | |
/*! jQuery v2.0.1 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license | |
//@ sourceMappingURL=jquery-2.0.1.min.map | |
*/ | |
(function(e,undefined){var t,n,r=typeof undefined,i=e.location,o=e.document,s=o.documentElement,a=e.jQuery,u=e.$,l={},c=[],f="2.0.1",p=c.concat,h=c.push,d=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=f.trim,x=function(e,n){return new x.fn.init(e,n,t)},b=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^-ms-/,N=/-([\da-z])/gi,E=function(e,t){return t.toUpperCase()},S=function(){o.removeEventListener("DOMContentLoaded",S,!1),e.removeEventListener("load",S,!1),x.ready()};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,t,n){var r,i;if(!e)return this;if("string"==typeof e){if(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:T.exec(e),!r||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if( |
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 Bob | |
def hey(message) | |
message ||= "" | |
message = Message.new(message) | |
case | |
when message.shouting? | |
"Woah, chill out!" | |
when message.question? |
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
monitor: bundle exec ruby monitor.rb |
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
I have found these resources particularly helpful in preparing this posting: | |
Hiring Engineers, a Process | |
http://hueniverse.com/2013/02/hiring-engineers-a-process/ | |
Join the Lift Team | |
http://blog.lift.do/post/24988178079/join-the-lift-team | |
How Etsy Increased Diversity in Its Engineering Department: An Interview with Marc Hedlund | |
https://www.youtube.com/watch?v=0D66GVc7ztA |
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
def foobar(&blk) | |
yield "bar" if blk | |
"foo" | |
end | |
> foobar | |
=> "foo" | |
> foobar {|x| puts x} | |
bar | |
=> "foo" |
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
> my_array = [{server: "localhost", ip: "192.168.0.1"}, {server: "google dns", ip: "8.8.8.8"}] | |
> tp my_array | |
SERVER | IP | |
-----------|------------ | |
localhost | 192.168.0.1 | |
google dns | 8.8.8.8 | |
# or with objects | |
> class ServerInfo |