Skip to content

Instantly share code, notes, and snippets.

View nhessler's full-sized avatar

Nathan Hessler nhessler

  • Hessler Consulting
  • Austin, TX
View GitHub Profile
View game.ex
defmodule ElixirBaseball.Game do
def play_ball do
IO.puts inspect(play_inning([], 0, 0))
end
def play_inning(top_of_inning, _, _) when length(top_of_inning) < 9 do
bottom_of_inning = [get_inning | top_of_inning]
play_inning(bottom_of_inning,
total_score(bottom_of_inning, :home),
total_score(bottom_of_inning, :away))
@nhessler
nhessler / torc.rb
Created December 5, 2015 15:07 — forked from JoshCheek/torc.rb
Tail optimized recursive call w/ Nathan at Rubyconf
View torc.rb
$depth = 0
at_exit { p depth: $depth }
def record_depth
$depth = caller.length-1 if caller.length-1 > $depth
end
require 'binding_of_caller'
module Torc
def torc(*args)
@nhessler
nhessler / conway.rb
Last active September 21, 2015 14:51 — forked from abachman/conway.rb
An implementation of Conway's Game of Life in Ruby based on Sets
View conway.rb
# Conway's Game of Life
# 2015-09-18
# by
# Nathan Hessler https://twitter.com/spune
# Adam Bachman https://twitter.com/abachman
# at Ruby DCamp 2015 http://rubydcamp.org/
# awesome test library
def assert(value)
if !value
View rack_test_example.rb
require 'sinatra/base'
require 'minitest/autorun'
require 'minitest/spec'
require "rack/test"
require 'nokogiri'
class MyApp < Sinatra::Base
enable :inline_templates
get '/users/:id' do
@nhessler
nhessler / keybase.md
Created March 18, 2014 17:42
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am nhessler on github.
  • I am nhessler (https://keybase.io/nhessler) on keybase.
  • I have a public key whose fingerprint is D0EE 20DF 35CD B2DD 86FF 3102 EEBB 7FA1 73C4 BA4D

To claim this, I am signing this object:

@nhessler
nhessler / lineage.rb
Created June 3, 2011 21:26
creating a lineage! is it too clever?
View lineage.rb
[grandpa, father, son,].inject(nil) do |parent, child|
child.parent = parent
child
end