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 'test_helper' | |
class MiniTestDoesntWorkWithUnenumerableRangesTest < ActiveSupport::TestCase | |
test ":(" do | |
period = Time.current - 1.week .. Time.current | |
mock = MiniTest::Mock.new | |
mock.expect :foo, true, [period] | |
mock.foo period |
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
time_range = Time.now .. Time.now | |
number_range = 1.0 .. 10.0 | |
p time_range.cover? Time.now | |
p number_range.cover? 5.0 | |
begin | |
time_range.to_a | |
rescue | |
puts "time_range is unenumerable" |
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
module IPoint | |
attr_accessor :x, :y | |
end | |
module IReadonlyPoint | |
attr_reader :x, :y | |
end | |
module IReadonlyLine | |
attr_reader :source, :destination |
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
class Evaluator | |
def evaluate &block | |
instance_eval &block | |
end | |
def upcase bar | |
bar.upcase | |
end | |
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
class Foo | |
class << self | |
def hello | |
"hello" | |
end | |
end | |
end | |
def singleton &block | |
singleton_class.class_eval &block |
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
#!/bin/sh | |
# get-freaky -- FREAK toolkit | |
set -e | |
usage() { | |
echo "`basename $0` scan [host:port] [host2:port2] ..." | |
echo "`basename $0` cipher [host:port] [host2:port2] ..." | |
} |
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 'fruity' | |
def bench(desc) | |
puts desc | |
Fruity.compare do | |
time_now { Time.now; nil } | |
time_now_utc { Time.now.utc; nil } | |
end | |
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
var events = require('events'); | |
var simpleBus = new events.EventEmitter(); | |
var strictlyOrderedBus = {}; | |
strictlyOrderedBus.bus = simpleBus; | |
strictlyOrderedBus.emit = function(evt) { setImmediate(this.bus.emit.bind(this.bus), evt); } | |
strictlyOrderedBus.on = simpleBus.on | |
var globalBus; |
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 'coffee-script' | |
code = DATA.read | |
magic_code = <<_EOJS_ | |
_magic_code = ($) -> | |
#{code} | |
_magic_code(jQuery); | |
_EOJS_ | |
puts CoffeeScript.compile magic_code | |
__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
def hash_smash bench_size, bm | |
hash_1 = {} | |
hash_2 = {} | |
1.upto(bench_size) do |n| | |
k = "val#{n}" | |
hash_1[k] = { | |
name: k, | |
total: n * 2, | |
} |
OlderNewer