I hereby claim:
- I am bestie on github.
- I am bestie (https://keybase.io/bestie) on keybase.
- I have a public key ASAU_62OgyyQ6IpGAlmQkLNK-JwXmslWMiOAueQy95ieOgo
To claim this, I am signing this object:
# Proc behavior in reply to https://gist.github.com/jcoglan/0a37aee2582877b27920 | |
def foo(&block) | |
p [:foo, 1] | |
puts "block returns " + block.call.inspect | |
p [:foo, 2] | |
end | |
def bar(&block) | |
p [:bar, 1] |
class ApplicationController | |
private | |
def core_application | |
CoreApplication.new | |
end | |
def adapter | |
RailsAdapter.new(self) | |
end |
class DateRangeFilter | |
def self.to_proc | |
->(constraint, events) { new(constraint, events).call }.to_proc | |
end | |
def initialize(constraint, events) | |
@constraint = constraint | |
@events = events | |
end |
# Ah it's OK I got this one myself. It's pretty late at night but I get it now! | |
# I'll leave this here in case anyone is interested. I've added the | |
# explaination below | |
# This is some code I wrote as excercise after watching | |
# https://youtu.be/QnWDU1wcsPA?t=470 | |
# | |
# The first example mimics the result from the video and is there just to | |
# verify my use of the TSort module is correct. |
# Task: Count how many users have each favorite color | |
User = Struct.new(:id, :favorite_color) | |
colors = [:red, :green, :blue, :hot_pink] | |
users = 10.times.map { |n| User.new(n, colors.sample) } | |
# The follow two example print the same result |
require "bundler" | |
bundle = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)) | |
gem_name_version_map = bundle.specs.map { |spec| | |
[ | |
spec.name, | |
spec.version.to_s, | |
] | |
} |
#!/usr/bin/env ruby | |
require "optparse" | |
options = { | |
:n_passwords => 1, | |
:password_length => 4, | |
:separator => " ", | |
} |
I hereby claim:
To claim this, I am signing this object:
# Run this script with the ENV var payload. | |
# Payload will be executed as part of your request to visit a prisoner. | |
# The goal is to free a prison in as few characters as possible. | |
module PrisonBreak | |
class Visit | |
attr_accessor :free_prisoner | |
attr_reader :prison, :payload |
require "socket" | |
rx_port = 2222 | |
tx_port = 2223 | |
host = "localhost" | |
socket = UDPSocket.new | |
socket.bind(host, rx_port) | |
socket.connect(host, tx_port) |