Skip to content

Instantly share code, notes, and snippets.

@arches
arches / sandbox.rb
Created April 1, 2012 03:35
Create and manipulate arbitrary classes with attributes and inheritance inside the safety of a module namespace
module Sandbox
def self.add_class(klass)
const_set_from_string(klass)
end
def self.add_attributes(klass, *attrs)
self.const_get_from_string(klass).class_eval do
attr_accessor *attrs
# set up the 'initialize' method to assign the attributes
@arches
arches / gist:3054004
Created July 5, 2012 14:29
HTML Curriculum

Lesson 1 - Pulling Back the Curtain

  • A web page is just a text file
  • html > body > hello world
  • definition of markup
  • the HTML is invisible

Lesson 2 - Tags are the Building Blocks of Life

  • heading
@arches
arches / irbrc.rb
Created July 19, 2012 02:54
Run a project-specific IRB config in Rails 3.1+
if ENV['RAILS_ENV']
rails_env = ENV['RAILS_ENV'].downcase
elsif Rails and Rails.env
rails_env = Rails.env.downcase
end
if rails_env
current_app = "myapp"
black = "\[\033[0;30m\]"
@arches
arches / 1_order_collection_extension.rb
Created July 20, 2012 14:25
Write methods against a collection of ActiveRecord objects
module OrderCollectionExtension
def revenue
self.sum(:payment_total_in_cents)
end
end
Order.non_zero_price.extend(OrderCollectionExtension).revenue
module Discountable
def to_discount_code
DiscountCode.find_by_code(self)
end
end
class DiscountCode < ActiveRecord::Base
def to_discount_code
self
end
@arches
arches / abstract.txt
Last active December 14, 2015 03:29
Concrete Metaprogramming
"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.
@arches
arches / scheduler.rake
Created May 12, 2013 22:11
rake task to ping a url
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
@arches
arches / gol.html
Created May 29, 2013 13:58
Doyle's Game of Conway's Life
<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(
class Bob
def hey(message)
message ||= ""
message = Message.new(message)
case
when message.shouting?
"Woah, chill out!"
when message.question?
@arches
arches / 1 resources
Last active December 21, 2015 05:39
[DRAFT] Job posting for a mobile developer at Aisle50 in Chicago. We believe in diversity and are trying to construct a welcoming interview process for all. Please leave some feedback if you have any ideas how we can improve this posting! Is anything unclear? Unaddressed? Insensitive? Offputting? What else do you want to know about the company, …
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