Skip to content
View 1_class_refactored_solution.rb
def valid?(card_number)
digits = card_number
.map { |number| number.to_i }
numbers = []
digits.each_with_index do |digit, index|
if index.even?
numbers << digit * 2


What are they?

"Enumerable", in Ruby, is a set of methods for collections. They are used in all the common collection classes. This command will tell you which classes. Try to guess a few before you run it:

$ ruby -e 'p ObjectSpace.each_object(Class).select { |c| c < Enumerable }'

When to indent in Ruby


Syntax is the rules for how characters of text can be put together to make a valid Ruby program. When we talk about syntax, we are talking about the letters (the whole program is a big string).

View play_movie.rb
Dir.chdir "/Users/josh/Desktop"
require 'streamio-ffmpeg'
path = ARGV[0]
movie =
width = 128
height = 80
start_time = 2.0
end_time = 3.0
frame_rate = movie.frame_rate
# This file goes in ~/.bash_profile (the tilde is your home directory)
# Environment Variables
export EDITOR='atom' # Set to your text editor
export PATH="/usr/local/bin:$HOME/bin:$PATH" # Look for executables in homebrew first
# Load chruby
source "/usr/local/share/chruby/"
chruby 2.2.2 # Default
View method_delimiter.rb
# Response to this tweet by Searls:
require 'rspec/autorun'
def method_delimiter(m)
singleton = m.owner.singleton_class?
bound = !m.respond_to?(:bind)
if singleton && bound
View lambda_syntaxes.rb
# ----- Lambda -----
# the syntax for a lambda: stabby arrow
-> a { a + a }
# ----- Block -----
# the two literal syntaxes for a block, + syntax to place lambda into block slot
lambda { |a| a + a }
lambda do |a| a + a end
lambda &->(a) { a + a }
View 1.rb
# Parses word lists without doing anything fancy
require 'treetop' # => true
Treetop.load_from_string <<GRAMMAR # => AParser
grammar A
rule word_list
word (' ' word)* {
def eval
head = elements[0].eval
tail = elements[1] { |space_word| space_word.elements[1].eval }
[head] + tail

I Wanted to clarify that my "yes" to "does learning to program make you a better person" probably meant something pretty different to me than to everyone who heard it. It was not at all a criticism of anyone who hasn't learned programming, and I wasn't defining "better" in terms of ethics, or relative to other people. Rather, I was defining it relative to the same person without the experience, and measuring it by the implications it has on the brain:

Learning to program taught me to think. It taught me to understand the world. It taught me to believe in myself. It answered my philosophical confusion. It enabled my artistic expression. It taught me rigor. It taught me how to think in abstractions and under them and across them. It gave me an avenue to have an impact. It showed me that I can do anything. It taught me not find the delight in failure rather than internalize it, it taught me that there aren't right ways to do things, only compromises across tradeoffs. It taught me that there is no magic. It taug

View resources_for_understanding_http.txt
Put this together as just some links to various materials I made.
Mostly b/c I'm low on time, but also b/c I Figured it will be good
for you to aggregate it into something coherent :)
Make a request and see both the request and response:
$ curl -v ''
Something went wrong with that request. Please try again.