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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> | |
<link type="text/css" rel="stylesheet" href="style.css"/> | |
<script type="text/javascript" src="js/d3.v3.min.js"></script> | |
<script> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
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
**Background** | |
I am trying to create links that redirect to an index page listing an arbitrary set of records. I believe that the best way to accomplish this is to pass an array of the IDs of the objects that I would like to be included to the index controller method. | |
**Method** | |
I have a working solution where I look for params[:ids] in my index method and if it exists, I find those records and display them. If that params[:ids] doesn't exists, I default to the default index behavior. | |
**Problem** |
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
# Ruby Code | |
def fun | |
a = 1 | |
add1(a) == 2 | |
sub2(a) == -1 | |
end | |
def add1(num) | |
num += 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
sirmxanot@sirmxanot-CT15:~/Sites/hw2_rottenpotatoes$ rbenv local | |
1.9.2-p290 | |
sirmxanot@sirmxanot-CT15:~/Sites/hw2_rottenpotatoes$ ber db:migrate --trace | |
rake aborted! | |
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type - /var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so | |
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require' | |
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>' | |
/var/lib/gems/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require' | |
/var/lib/gems/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>' | |
/var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require' |
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
sirmxanot@sirmxanot-CT15:~/Sites/hw2_rottenpotatoes$ ber db:migrate --trace | |
rake aborted! | |
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_current_thread - /var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so | |
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require' | |
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>' | |
/var/lib/gems/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require' | |
/var/lib/gems/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>' | |
/var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require' | |
/var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `block (2 levels) in require' | |
/var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `each' |
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 Numeric | |
@@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019} | |
@@currencies['dollar']=1 | |
def method_missing(method_id) | |
singular_currency = method_id.to_s.gsub( /s$/, '') | |
if @@currencies.has_key?(singular_currency) | |
self * @@currencies[singular_currency] | |
else | |
super | |
end |
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 preferable | |
graph[vertex_delete].each do |edge| | |
graph[edge].map! do |vertex| | |
vertex == vertex_delete ? vertex_keep : vertex | |
end | |
end | |
#to this? | |
graph[vertex_delete].each {|edge| graph[edge].map! {|vertex| vertex == vertex_delete ? vertex_keep : vertex}} |
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
ArgumentError: comparison of Fixnum with nil failed | |
from mergesort3.rb:34:in `<' | |
from mergesort3.rb:34:in `block in merge' | |
from mergesort3.rb:31:in `each' | |
from mergesort3.rb:31:in `merge' | |
from mergesort3.rb:17:in `merge_sort' | |
from mergesort3.rb:14:in `merge_sort' | |
from (irb):4 | |
from /usr/bin/irb:12:in `<main>' |
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
def merge_sort(m) | |
#base case | |
if m.length <= 1 | |
m | |
#all other cases | |
else | |
#intialize variables | |
left = Array.new | |
right = Array.new | |
middle = m.length/2 |
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
def merge_sort(m) | |
#base case | |
if m.length <= 1 | |
return m | |
else | |
#intialize variables | |
left = Array.new | |
right = Array.new | |
middle = m.length/2 |
NewerOlder