Skip to content

Instantly share code, notes, and snippets.

View sentientmonkey's full-sized avatar

Scott Windsor sentientmonkey

View GitHub Profile
require "minitest/autorun"
class RangeTest < Minitest::Test
def test_ranges
assert 2.between? 0,5
assert (0..5).include? 2
assert (0..5).include? 0
assert (0..5).include? 5
assert (0...5).include? 0
refute (0...5).include? 5
require "continuation"
# via http://c2.com/cgi/wiki?AmbInRuby
class Amb
def initialize
@paths = []
end
def choose choices
choices.each do |choice|
class ImmutableObject
def initialize
freeze
end
end
class BaseImmutableStruct < ImmutableObject
attr_reader :members
def initialize(members)
class ImmutableObject
def initialize
freeze
end
end
class BaseImmutableStruct < ImmutableObject
attr_accessor :members
def initialize(members)
@sentientmonkey
sentientmonkey / gist:ab7c8e756d0e7b2e5db3
Created January 24, 2015 22:11
When I save keyboard modifiers in OS X 10.10.1
Jan 24 14:10:31 lambda System Preferences[28901]: CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 7. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
@sentientmonkey
sentientmonkey / benchmark_bigo_suggest.rb
Last active August 9, 2022 20:20
Metaphone vs. Levenshtien shootout
#!/usr/bin/env ruby -w
require 'benchmark/bigo'
require 'rubyfish'
require_relative 'typo_suggestor'
require_relative 'levenshtien_suggestion'
require_relative 'metaphone_suggestion'
Benchmark.bigo do |x|
@sentientmonkey
sentientmonkey / -
Last active August 29, 2015 14:05
rake spec for sample_app
$ rake spec
rake aborted!
Don't know how to build task 'test:prepare'
Tasks: TOP => spec
(See full trace by running task with --trace)
@sentientmonkey
sentientmonkey / -
Last active August 29, 2015 14:05
rspec rspec output for sample_app
$rspec spec
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
/Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
/Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/scott/.rvm/gems/ruby-1.9.3-p545/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/Users/scott/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/test/unit/assertions.rb:1:in `<top (required)>'
require "minitest/autorun"
require "date"
class Person
CURRENT_YEAR = ->{ Date.new.year }
attr_reader :birthday
def initialize(attributes={})
@birthday = attributes.fetch(:birthday)
end
require "minitest/autorun"
require "date"
class Person
attr_reader :birthday
def initialize(attributes={})
@birthday = attributes.fetch(:birthday)
end