Skip to content

Instantly share code, notes, and snippets.

@hackjoy
hackjoy / bottles_lib_5.rb
Last active August 29, 2015 14:05
bottles_lib_5.rb
class Bottles
# ... verse() method not shown for brevity ...
def verses(upper_bound, lower_bound)
upper_bound
.downto(lower_bound)
.collect {|verse_number| verse(verse_number)}
.join("\n")
end
@hackjoy
hackjoy / bottles_lib_4.rb
Last active August 29, 2015 14:05
bottles_lib_4.rb
class Bottles
# ... verse() method not shown for brevity ...
def verses(upper_bound, lower_bound)
"#{verse(upper_bound)}\n#{verse(lower_bound)}"
end
end
@hackjoy
hackjoy / bottles_test_3.rb
Last active August 29, 2015 14:05
bottles_test_3.rb
# ... previous setup and tests not shown for brevity ...
def test_a_couple_verses
expected = <<-VERSES
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
VERSES
@hackjoy
hackjoy / bottles_lib_3.rb
Last active August 29, 2015 14:05
bottles_lib_3.rb
class Bottles
def verse(num)
case num
when 0
"No more bottles of beer on the wall, no more bottles of beer.\n" +
"Go to the store and buy some more, 99 bottles of beer on the wall.\n"
when 1
"1 bottle of beer on the wall, 1 bottle of beer.\n" +
"Take it down and pass it around, no more bottles of beer on the wall.\n"
@hackjoy
hackjoy / bottles_lib_2.rb
Last active August 29, 2015 14:05
bottles_lib_2.rb
class Bottles
def verse(num)
case num
when 89
"89 bottles of beer on the wall, 89 bottles of beer.\n" +
"Take one down and pass it around, 88 bottles of beer on the wall.\n"
when 99
"99 bottles of beer on the wall, 99 bottles of beer.\n" +
"Take one down and pass it around, 98 bottles of beer on the wall.\n"
@hackjoy
hackjoy / bottles_lib_1.rb
Created August 17, 2014 15:37
bottles_lib_1.rb
class Bottles
def verse(num)
"99 bottles of beer on the wall, 99 bottles of beer.\n" +
"Take one down and pass it around, 98 bottles of beer on the wall.\n"
end
end
@hackjoy
hackjoy / bottles_test_1.rb
Last active August 29, 2015 14:05
bottles test 1
require_relative '../../test_helper'
require_relative '../lib/bottles'
class BottlesTest < Minitest::Test
attr_reader :bottles
def setup
@bottles = ::Bottles.new
end
@hackjoy
hackjoy / port_forward.sh
Created May 13, 2014 10:52
Port forwarding
ssh -L 9210:localhost:9200 user@servername.com
@hackjoy
hackjoy / nokogiri_install
Created April 27, 2014 17:46
Installing Nokogiri
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 \
gem install nokogiri -- \
--with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config \
--with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config
https://github.com/sparklemotion/nokogiri/issues/1049
@hackjoy
hackjoy / package.json
Last active December 31, 2015 23:09
[node npm] package.json
{
"name": "http-server",
"preferGlobal": true,
"version": "0.3.0",
"author": "Nodejitsu <support@nodejitsu.com>",
"description": "a simple zero-configuration command-line http server",
"contributors": [
{
"name": "Marak Squires",
"email": "marak@nodejitsu.com"