Looked at the winning Dispatcher. Yours is better, b/c you can take it all by itself. Here are some examples of totally reasonable requirements that would feasibly be required of this application, in the real world. The winning one can't handle them without a refactoring like what we did:
This file contains 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
# The goal of this problem is to extract headers from a block of text, | |
# and arrange them hierarchically. | |
# | |
# See the specs for more detail on the output | |
require 'net/http' | |
require 'nokogiri' | |
def header_hierarchy(html) | |
# https://www.w3.org/MarkUp/html3/headings.html |
This file contains 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 is a comment. |
This file contains 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' | |
gem 'minitest', '~> 5.6' # might work w/ older vers, I didn't check | |
require 'minitest' | |
class WhateverTest < Minitest::Test | |
def setup | |
@setup_value = true | |
end | |
def test_it_passes |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
This file contains 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
# ===== Environment (MRI 2.1.1) ===== | |
RUBY_VERSION # => "2.1.1" | |
RUBY_PLATFORM # => "x86_64-darwin13.0" | |
RbConfig.ruby # => "/Users/josh/.rubies/ruby-2.1.1/bin/ruby" | |
`#{RbConfig.ruby} -v` # => "ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]\n" | |
# ===== The Hypothesis ===== | |
# A recursive method can call itself about 5000 times before it overflows. | |
# ===== Test #1 ===== |
Review of the second half of Philip Roberts' talk What the heck is the event loop, anyway?
Okay, got back to the video :) <3 the tool! We need more stuff like this, Hoping to make something similar for Ruby. At one point I got as far as drawing it, but then wound up rewriting it a few times. Hoping to
This file contains 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 PrimeFactor | |
attr_accessor :all_factors | |
def largest_divisor_less_than(number) | |
divisor = 2 | |
while divisor <= Math.sqrt(number) | |
return number / divisor if number % divisor == 0 | |
divisor = divisor + 1 | |
end | |
return 1 |
This file contains 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 'isaac' | |
configure do |c| | |
c.nick = "ButtBot" | |
c.server = "irc.freenode.net" | |
# c.port = 6667 | |
end | |
on :connect do | |
join "#wsu-acm" |
This file contains 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
<!-- It is probably easier to read if you initialize item_images to be an empty hash --> | |
<% @item.item_images ||= Hash.new %> | |
<% @item.item_images.each do |key, image| %> | |
<img src="<%= image.path %>" width="397" <% if key != 0 %>style="display:none"<% end %> /> | |
<% end %> | |
<!-- Or return a default value for when it is nil --> | |
<% (@item.item_images || Hash.new).each do |key, image| %> | |
<img src="<%= image.path %>" width="397" <% if key != 0 %>style="display:none"<% end %> /> |
NewerOlder