Skip to content

Instantly share code, notes, and snippets.

View burtlo's full-sized avatar

Lynn Frank burtlo

View GitHub Profile
@burtlo
burtlo / apple.rb
Created February 26, 2013 16:48
Delaying size of the apple until after initialization
module Fruit
class Apple
attr_reader :variety, :created_at
def initialize(variety = default_variety)
@variety = variety
@created_at = Time.now
end
@burtlo
burtlo / scrabble.rb
Created February 28, 2013 16:46
Scrabble intermediate solutions
puts "Welcome to Scrabble"
class Scrabble
def self.score(word)
one_point_group = %w[ A E I O U L N R S T ]
two_point_group = %w[ D G ]
three_point_group = %w[ B C M P ]
four_point_group = %w[ F H V W Y ]
five_point_group = %w[ K ]
eight_point_group = %w[ J X ]
@burtlo
burtlo / gist:5095917
Created March 6, 2013 01:13
Parade presentation that will look for CSS and JS files within the sub-folder 'resources'
title "Example Presentation"
description "Several parade examples to assist with showing others how to get started with Parade"
pause_message "Visit github.com/schacon/parade"
resources "resources"
section "Introduction" do
@burtlo
burtlo / gist:5104644
Created March 7, 2013 00:55
Keep crying
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=fxfxcxdxbxegedabagacad
export HISTCONTROL=ignoredups:erasedups
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=/usr/local/Cellar/wkhtmltopdf/0.9.9:$PATH
export PATH=/usr/local/share/npm/bin:$PATH
export PATH=.:$PATH
@burtlo
burtlo / conway_spec.rb
Last active December 15, 2015 08:09
Kanye's Game of Life
class Point < Struct.new(:x,:y)
def self.at(x,y)
new x, y
end
def ==(other)
other.x == x and other.y == y
end
def around
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=fxfxcxdxbxegedabagacad
export HISTCONTROL=ignoredups:erasedups
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=/usr/local/Cellar/wkhtmltopdf/0.9.9:$PATH
export PATH=/usr/local/share/npm/bin:$PATH
export PATH=.:$PATH
class Allergies
def initialize(score)
@score = score
end
attr_reader :score
def allergens
@burtlo
burtlo / anagram.rb
Last active December 16, 2015 14:59
class String
def char_counts_hash
char_hash = Hash.new(0)
each_char {|char| char_hash[char] += 1 }
char_hash
end
def anagram_of?(word)
word.char_counts_hash == char_counts_hash
end
require 'spec_helper'
describe ApplicationController do
describe "#require_login" do
context "when the user is logged in" do
it "does nothing" do
end
end
context "when the user is not logged in" do
class SumOfMultiples
def self.to(input)
new(3,5).to(input)
end
def initialize(*params)
@params = params
end