This file contains hidden or 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
# This builds a publicly available SSH server on EC2. | |
# | |
# Make sure to edit the path to your public SSH key. | |
# | |
# Log in: | |
# | |
# $ ssh ubuntu@$(terraform output -raw public_ip) | |
terraform { | |
required_providers { |
This file contains hidden or 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 "nokogiri" | |
require "open-uri" | |
require "optparse" | |
require "set" | |
MAX_DEPTH = 2 | |
class Page | |
def initialize(body:, url:) | |
@body = body |
This file contains hidden or 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 "rspec/autorun" | |
# An implementation of an immutable binary search tree in Ruby, with a small | |
# suite of tests. Supports #==, #insert, #delete, and #to_a (an in-order | |
# traversal). | |
# | |
# To run the tests, just evaluate the file: `ruby binary_search_tree.rb` | |
class Leaf | |
def ==(other) |
This file contains hidden or 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
# Supposing that you're starting on the master branch... | |
# Create a new branch and switch to it: | |
git checkout -b my-work | |
# Commit your changes on that branch: | |
git add . | |
git commit -m "My work so far!" | |
# Update the master branch: |
This file contains hidden or 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 MessageDispatcher | |
def initialize | |
@observers = [] | |
end | |
def register(observer) | |
@observers << observer | |
end | |
def dispatch(message) |
This file contains hidden or 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
#!/usr/bin/env ruby | |
class UnixProcess | |
attr_reader :uid, :pid, :ppid, :cmd | |
def initialize(uid:, pid:, ppid:, cmd:) | |
@uid = uid | |
@pid = pid | |
@ppid = ppid | |
@cmd = cmd |
This file contains hidden or 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
#!/usr/bin/env ruby | |
class SayRepl | |
attr_reader :voice | |
def initialize(voice) | |
@voice = voice | |
end | |
def go |
This file contains hidden or 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
p (0..1000000).count{rand<Math.sqrt(1-rand**2)}/250000.0 |
This file contains hidden or 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
### Keybase proof | |
I hereby claim: | |
* I am hrs on github. | |
* I am hrs (https://keybase.io/hrs) on keybase. | |
* I have a public key whose fingerprint is 1B41 8F2C 23DE DD9C 807E A74F 841B 3DAE 25AE 721B | |
To claim this, I am signing this object: |
This file contains hidden or 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
# attr_reader/writers/accessors are handy shortcuts for creating | |
# getter and setter methods. That's all they're for. | |
# An attr_reader creates a getter method. For example, the following | |
# two classes have identical effects: | |
class NamedWombat | |
attr_reader :name | |
def initialize(name) |
NewerOlder