Skip to content

Instantly share code, notes, and snippets.

Josh Cheek JoshCheek

Block or report user

Report or block JoshCheek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View header_hierarchy_problem.rb
# 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)
View autorun.rb
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
def test_it_passes

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:

Speed up the algorithm

View gist:9d55b06759809674951c

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

View experiment.rb
# ===== 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 =====
JoshCheek /
Last active Aug 29, 2015 — forked from anonymous/
Review of the second half of Philip Roberts' talk "What the heck is the event loop, anyway?"
View prime_factor_spec.rb
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
return 1
View Whynowork.rb
require 'isaac'
configure do |c|
c.nick = "ButtBot"
c.server = ""
# c.port = 6667
on :connect do
join "#wsu-acm"
View gist:608991
<!-- It is probably easier to read if you initialize item_images to be an empty hash -->
<% @item.item_images ||= %>
<% @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 || do |key, image| %>
<img src="<%= image.path %>" width="397" <% if key != 0 %>style="display:none"<% end %> />
You can’t perform that action at this time.