Skip to content

Instantly share code, notes, and snippets.

def setup
generate(:controller, "welcome index")
route "root to: 'welcome#index'"
generate("devise:install")
generate("devise User")
environment 'config.action_mailer.default_url_options = { host: "localhost", port: 3000 }', env: 'development'
rails_command("db:migrate")
end
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}']"
@johnivanoff
johnivanoff / sada.html
Last active July 27, 2017 03:26
Sort a HTML List Alphabetically by data-attribute
<!DOCTYPE html>
<html>
<title>Sort a HTML List Alphabetically HB</title>
<style>
div{
border: solid;
padding: 1em;
margin: 1em;
}
</style>
@johnivanoff
johnivanoff / projects.rb
Created November 24, 2015 19:51
find words that start with @
# find words that start with @
def find_project(str)
p str.scan(/\B@(\w+)/i)
end
find_project('this is @cpord ford.')
find_project('this is hi@cpord ford.')
def hello(attrs)
@vin = attrs[:vin]
@vin_is_fake = attrs[:vin_is_fake]
if @vin_is_fake
puts 'true'
else
puts 'false'
end
end
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'
@johnivanoff
johnivanoff / gist:7950109
Last active December 31, 2015 06:49
Homework
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)
test$ ruby feed_aggregator_test.rb
Loaded suite feed_aggregator_test
Started
..
Finished in 0.112374 seconds.
2 tests, 3 assertions, 0 failures, 0 errors, 0 skips
require 'sinatra'
require 'nokogiri'
require 'open-uri'
feed = 'http://api.flickr.com/services/feeds/groups_pool.gne?id=1373979@N22&lang=en-us&format=rss_200'
def parse feed
doc = Nokogiri::XML(open(feed))
doc.search('item').map do |doc_item|
item = {}