Skip to content

Instantly share code, notes, and snippets.

View f-mer's full-sized avatar

Fabian Mersch f-mer

View GitHub Profile
n = 10_000
doors = [:car, :goat, :goat]
results = n.times.map do
doors.shuffle!
guess = rand(3)
if doors[guess] == :car
:stay
@f-mer
f-mer / cloud_events.rb
Last active December 7, 2018 22:53
Cloud Events
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 = {
class UrlHelper
include Singleton
include Rails.application.routes.url_helpers
end
UrlHelper.instance.resources_path
@f-mer
f-mer / stream.rb
Created May 18, 2017 17:42
Transforming data with streams in Ruby
class Stream
def initialize(*segments, &blk)
@source = segments.shift
@sink = segments.pop
@transforms = segments
run(&blk) if block_given?
end
def run(&blk)