Instantly share code, notes, and snippets.

View sort.rb
placeholderA = []
placeholderB = []
fh.each do |key, value|
case key
when "sortdescending"
placeholderA << "a['#{value}']"
placeholderB << "b['#{value}']"
when "sortascending"
placeholderA << "b['#{value}']"
placeholderB << "a['#{value}']"
View sada.html
<!DOCTYPE html>
<title>Sort a HTML List Alphabetically HB</title>
border: solid;
padding: 1em;
margin: 1em;
View projects.rb
# find words that start with @
def find_project(str)
p str.scan(/\B@(\w+)/i)
find_project('this is @cpord ford.')
find_project('this is hi@cpord ford.')
View params.rb
def hello(attrs)
@vin = attrs[:vin]
@vin_is_fake = attrs[:vin_is_fake]
if @vin_is_fake
puts 'true'
puts 'false'
View gist:1ab07b55423e977b2d7a
johns-mbp:nrtest2 johnivanoff$ rspec
/Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/gems/sass-3.2.19/lib/sass/version.rb:5: warning: loading in progress, circular require considered harmful - /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/gems/sass-3.2.19/lib/sass.rb
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/bin/ruby_executable_hooks:15:in `<main>'
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/bin/ruby_executable_hooks:15:in `eval'
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/bin/rspec:23:in `<main>'
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/bin/rspec:23:in `load'
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/gems/rspec-core-3.0.3/exe/rspec:4:in `<top (required)>'
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/johnivanoff/.rvm/gems/ruby-2.1.2@nrtest2/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:70:in `run'
View gist:7950109
Johnny had half as many erasers as pencils.
He had nine times as many pinwheels as erasers.
He had a total os 120 peices.
How many pencils did Johnny have?
Show your work.
120 = x+(x*.5)+((x*.5)*9)
View gist:4274001
test$ ruby feed_aggregator_test.rb
Loaded suite feed_aggregator_test
Finished in 0.112374 seconds.
2 tests, 3 assertions, 0 failures, 0 errors, 0 skips
View gist:4247690
require 'sinatra'
require 'nokogiri'
require 'open-uri'
feed = ''
def parse feed
doc = Nokogiri::XML(open(feed))'item').map do |doc_item|
item = {}
View gist:4247677
require 'sinatra'
require 'nokogiri'
feed ='test/fixtures/feed.xml')
def parse feed
doc = Nokogiri::XML feed'item').map do |doc_item|
item = {}
item[:link] ='link').text