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
| source 'https://rubygems.org' | |
| # Frameworks | |
| gem 'rails', '4.0.2' | |
| # Server | |
| gem 'unicorn' | |
| # Database | |
| gem 'pg' |
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
| # GREED GAME | |
| def score(dice) | |
| return 0 if dice == nil | |
| score = 0 | |
| counts = [0,0,0,0,0,0] | |
| dice.each { |roll| counts[roll-1] += 1 if (1..6) === roll } |
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
| does it change the database? | |
| where am I going to store that data? | |
| what data needs to be stored? | |
| name | |
| the songs on the mixtape | |
| - write my migration | |
| how does that effect my models? | |
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 'Rack' | |
| # class YourAppClass | |
| # def call(env) | |
| # [200, {'Content-Type' => 'text/html'}, ['Hello Rack!']] | |
| # end | |
| # end | |
| # run YourAppClass.new |
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 factorial(num) | |
| if num <= 1 | |
| 1 | |
| else | |
| num * factorial(num-1) | |
| end | |
| 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
| class Song | |
| attr_accessor :title, :artist | |
| def serialize | |
| file_name = self.title.gsub(" ", "_").downcase | |
| File.open("#{file_name}.txt", "w+") do |f| | |
| f << "#{self.artist.name} - #{self.title}" | |
| end | |
| 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
| class Dog | |
| attr_accessor :name, :food, :breed | |
| def bark | |
| "Woof!" | |
| end | |
| def self.bark | |
| "Awoo!" | |
| 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
| class Array | |
| def version_sort | |
| self.sort_by do |file| | |
| file.scan(/\d+|[a-z]*/).map {|e1| e1.to_i} | |
| end | |
| end | |
| end | |
| filenames = [ | |
| "foo-1.10.2.ext", | |
| "foo-1.11.ext", |
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 my_each(array) | |
| i = 0 | |
| while i < array.length | |
| yield(array[i]) | |
| i+=1 | |
| end | |
| array | |
| 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
| require 'pry' | |
| class School | |
| attr_accessor :roster, :school | |
| @@schools = [] | |
| def initialize(school) | |
| @school = school | |
| @roster = {} |