I hereby claim:
- I am havenwood on github.
- I am havenwood (https://keybase.io/havenwood) on keybase.
- I have a public key whose fingerprint is 06CB 6789 306C 1DC4 BEAE ABF1 CF61 5467 50DB C4B4
To claim this, I am signing this object:
def merge_sort array | |
return array if array.empty? or array.one? | |
sorted = [] | |
left, right = array.each_slice(array.size.fdiv(2).round).map { |a| merge_sort a } | |
loop do | |
break sorted.concat(right) if left.empty? | |
break sorted.concat(left) if right.empty? |
module Klass | |
def self.new *args, &block | |
object = Class.allocate | |
object.send :initialize, *args, &block | |
object | |
end | |
end | |
Cat = Klass.new do | |
attr_reader :name, :age |
require 'transducers' | |
T = Transducers | |
fizzducer = T.compose T.map { |n| n % 3 == 0 && n % 5 == 0 && 'FizzBuzz' || n }, | |
T.map { |n| n % 3 == 0 && 'Fizz' || n }, | |
T.map { |n| n % 5 == 0 && 'Buzz' || n }, | |
T.map(:to_s) | |
T.transduce fizzducer, :puts, STDOUT, 1.upto(5) |
class Proc | |
class << self | |
def compose *others | |
others.map(&:to_proc).inject :* | |
end | |
end | |
def * other | |
proc { |*args| other.call self.call *args } | |
end |
class Roshambo | |
OPTIONS = [:rock, :paper, :scissors] | |
WINNERS = OPTIONS.rotate.zip(OPTIONS).to_h | |
LOSERS = WINNERS.invert | |
attr_reader :value | |
include Comparable | |
def initialize value = OPTIONS.sample |
require 'open-uri' | |
URL = 'https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/' | |
FILENAME = 'AddTrustExternalCARoot-2048.pem' | |
DIR = File.join RbConfig::CONFIG['rubylibdir'], 'rubygems', 'ssl_certs' | |
pem = open File.join(URL, FILENAME), &:read | |
File.write File.join(DIR, FILENAME), pem |
require 'shell' | |
Shell.verbose = false | |
Shell.def_system_command 'ls' | |
Shell.def_system_command 'grep' | |
sh = Shell.cd Dir.home | |
sh.transact do | |
ls('-a') | grep('^\.') > STDOUT | |
end |
require 'shell' | |
Shell.verbose = false | |
Shell.def_system_command 'seq' | |
Shell.new.transact do | |
echo( | |
seq('100').map(&:to_i).map { |x| | |
if x % 15 == 0 | |
"FizzBuzz" |
I hereby claim:
To claim this, I am signing this object:
function install_pkgsrc() { | |
local pkgsrc_url="http://pkgsrc.joyent.com/packages/Darwin/bootstrap" | |
local pkgsrc_archive="bootstrap-2015Q2-x86_64.tar.gz" | |
local pkgsrc_sha256sum="5e9717932454c6c06db2004a0efe59b40a216aa2c661bc323bd651f8ce4e6c46" | |
local pkgsrc_gpgkey="0xDE817B8E" | |
echo ">>> Downloading pkgsrc archive for OS X ..." | |
\curl -O --progress-bar "$pkgsrc_url/$pkgsrc_archive" || return $? | |
echo ">>> Verifying pkgsrc archive SHA256 checksum ..." |