###Part 1: Review Time 20 min
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 roulette(bet, total) | |
unless total < bet | |
total -= bet | |
color = choose_color | |
if color == "black" | |
return bet * 2 + total | |
else | |
return roulette(bet * 2, total) | |
end | |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
namespace :populate do | |
congresspeople = Sunlight::legislator.all_where(:gender => "M") | |
task :get_info do | |
congresspeople.each do |rep| | |
:firstname = rep.firstname | |
:lastname = rep.lastname | |
:bioguide_id = rep.bioguide_id | |
create_rep(firstname, lastname, bioguide_id) | |
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
ActiveRecord cheat sheet / EXAMPLES | |
INSTALL | |
======= | |
$ gem install activerecord | |
in GEMFILE: gem ‘activerecord’ | |
REQUIRE | |
======= | |
require ‘active_record’ |
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 EightBall | |
def response | |
response_array = ["Signs point to yes", | |
"Signs point to no", | |
"AHAHAHAHA!", | |
"Outlook is positive", | |
"No way Jose!"] | |
response_num = rand(response_array.length) | |
puts response_output = response_array[response_num] |
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
require 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
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
class Sudoku | |
def initialize(puzzle) # puzzle == String | |
@puzzle = puzzle | |
@cell = Cell.new(puzzle) | |
@rows = Row.new(puzzle) | |
@column = Column.new(puzzle) | |
@three_by_three = ThreeByThree.new(puzzle) | |
end | |
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
require 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
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
require 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
end |
NewerOlder