This file contains hidden or 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
| MusicService::Application.routes.draw do | |
| resources :albums | |
| resources :artists | |
| resources :songs | |
| match ':artist_name(/:album_name(/:song_name))' => 'artists#search_by_multiple_criteria' | |
| end |
This file contains hidden or 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
| MusicService::Application.routes.draw do | |
| resources :albums | |
| resources :artists | |
| resources :songs | |
| match ':artist_name' => 'artists#search_by_artist' | |
| end |
This file contains hidden or 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
| myArray = [1,2,3,4,5]; | |
| mySecondArray = [1,2,3,4,5]; | |
| myThirdArray = [1,2,3,9,5]; | |
| Array.prototype.isEqualTo = function ( compareTo ) { | |
| if ( this.length !== compareTo.length ) return false; | |
| for ( var i = 0; i < this.length; i ++ ){ | |
| if ( this[i] !== compareTo[i] ) return false; | |
| } | |
| return true; |
This file contains hidden or 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
| > myArray = [1,2,3,4,5] | |
| [ 1, 2, 3, 4, 5 ] | |
| > myArrayCopy = myArray; | |
| [ 1, 2, 3, 4, 5 ] | |
| > myArray === myArrayCopy; | |
| true |
This file contains hidden or 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
| > myArray = [1,2,3,4,5] | |
| [ 1, 2, 3, 4, 5 ] | |
| > mySecondArray = [1,2,3,4,5] | |
| [ 1, 2, 3, 4, 5 ] | |
| > myArray === mySecondArray; | |
| false |
This file contains hidden or 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 'twitter' | |
| require 'tweetstream' | |
| require 'pp' | |
| require 'csv' | |
| class TwitterResponder | |
| def initialize | |
| @shakes = CSV.read('shakespeare.csv') | |
| Twitter.configure do |config| |
This file contains hidden or 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
| #test array | |
| class TestArray | |
| def initialize | |
| @array = Array.new(6).map{|i| Array.new(7)} | |
| # populate_fields | |
| populate_fields_numeric | |
| end |
This file contains hidden or 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
| ["0, 0", "0, 1", "0, 2", "0, 3", "0, 4", "0, 5", "0, 6"] | |
| ["1, 0", "1, 1", "1, 2", "1, 3", "1, 4", "1, 5", "1, 6"] | |
| ["2, 0", "2, 1", "2, 2", "2, 3", "2, 4", "2, 5", "2, 6"] | |
| ["3, 0", "3, 1", "3, 2", "3, 3", "3, 4", "3, 5", "3, 6"] | |
| ["4, 0", "4, 1", "4, 2", "4, 3", "4, 4", "4, 5", "4, 6"] | |
| ["5, 0", "5, 1", "5, 2", "5, 3", "5, 4", "5, 5", "5, 6"] | |
| ["5, 0", "5, 1", "5, 2", "5, 3", "5, 4", "5, 5", "5, 6"] | |
| ["4, 0", "4, 1", "4, 2", "4, 3", "4, 4", "4, 5", "4, 6"] | |
| ["3, 0", "3, 1", "3, 2", "3, 3", "3, 4", "3, 5", "3, 6"] |
This file contains hidden or 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 'csv' | |
| require 'sqlite3' | |
| class CongressMembers | |
| def initialize | |
| @list = [] | |
| @db = SQLite3::Database.new "test.db" | |
| CSV.foreach("politicians.csv", :headers => :first_row, :header_converters => :symbol) do |row| | |
| @list << Politician.new(row[:name], row[:party], row[:location], row[:grade_level_since_1996], row[:grade_level_112th_congress], row[:years_in_congress], row[:dw1_score]) |
This file contains hidden or 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 binary_search(item,array,min = 0,max = array.length, half = (min + max) / 2) | |
| return min if item == array[min] | |
| return -1 if (item < array[0] || item > array[array.length-1]) || (min == max - 1) | |
| item < array[half] ? binary_search(item,array,min,half) : binary_search(item,array,half,array.length) | |
| end | |
| def prime_factors(n, factors = [], f = 2) | |
| return factors.push(f) if n == f | |
| n % f == 0 ? prime_factors(n / f, factors.push(f)) : prime_factors(n, factors, f + 1) | |
| end |