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
# extended from https://stackoverflow.com/questions/10661610/implement-a-tree-iterator | |
class Node | |
attr_accessor :data, :children | |
def initialize(data, *children) | |
@data = data | |
@children = children | |
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
require 'minitest/autorun' | |
Tree = Struct.new(:value, :left, :right) | |
class TestTree < Minitest::Test | |
def test_is_tree_sorted_true | |
seven = Tree.new(7) | |
three = Tree.new(3) | |
five = Tree.new(5, three, seven) |
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 'minitest/autorun' | |
require 'minitest/mock' | |
# From the Queen herself, Sandi Metz | |
# https://www.youtube.com/watch?v=URSWYvyc42M | |
# http://jnoconor.github.io/images/unit-testing-chart-sandi-metz.png | |
class Gear | |
attr_reader :chainring, :cog, :wheel, :observer |
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
# git aliases | |
alias g 'git' | |
alias gst 'git status' | |
alias gd 'git diff' | |
alias gco 'git checkout' | |
alias ga 'git add' | |
alias gcm 'git commit -m' | |
alias gl "git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold | |
green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "4096" | |
vb.cpus = "2" | |
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
require 'singleton' | |
class Subscriber | |
include Singleton | |
attr_reader :subscriptions | |
def initialize | |
@subscriptions = {} | |
end |
OlderNewer