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
n = 10_000 | |
doors = [:car, :goat, :goat] | |
results = n.times.map do | |
doors.shuffle! | |
guess = rand(3) | |
if doors[guess] == :car | |
:stay |
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 'sinatra' | |
set :protection, :except => :frame_options | |
set :bind, '0.0.0.0' | |
module CloudEvents | |
class Event | |
attr_accessor :data, :version, :id, :time, :type, :source, :schemaurl | |
HTTP_HEADERS = { |
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 UrlHelper | |
include Singleton | |
include Rails.application.routes.url_helpers | |
end | |
UrlHelper.instance.resources_path |
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 Stream | |
def initialize(*segments, &blk) | |
@source = segments.shift | |
@sink = segments.pop | |
@transforms = segments | |
run(&blk) if block_given? | |
end | |
def run(&blk) |