pry -r ./config/app_init_file.rb
- load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environemtn.rb
- load your rails into a pry session
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
// ---- | |
// Sass (v3.3.0.rc.2) | |
// Compass (v1.0.0.alpha.17) | |
// ---- | |
// | |
// map-fetch($map, $keys) | |
// | |
// An easy way to fetch a deep value in a multi-level map. Works much like | |
// map-get() except that you pass multiple keys as the second parameter to |
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 'sqlite3' | |
$db = SQLite3::Database.open 'congress_poll_results.db' | |
def print_arizona_reps | |
puts 'AZ REPRESENTATIVES' | |
az_reps = $db.execute("SELECT name FROM congress_members WHERE location = 'AZ'") | |
az_reps.each { |rep| puts rep } | |
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
# Your awesome code goes here! | |
class Song | |
attr_reader :track, :artist | |
def initialize(track, artist) | |
@track = track | |
@artist = artist | |
end | |
def play | |
puts 'NOW PLAYING' + ' ' + self.track + '-' + self.artist |
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 Student | |
attr_accessor :scores, :ssn, :first_name | |
def initialize(fname, ssn, scores) | |
@first_name = fname | |
@ssn = ssn | |
@scores = scores | |
end | |
def average |
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
#Output: number of possible teams | |
def choose_team(n, k) | |
return n if k == 1 | |
return 0 if k == 0 || n == 0 | |
choose_team(n-1,k-1) + choose_team(n-1,k) | |
end | |
p choose_team(6,1) == 6 |
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
/** | |
* SyntaxHighlighter | |
* http://alexgorbatchev.com/ | |
* | |
* SyntaxHighlighter is donationware. If you are using it, please donate. | |
* http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate | |
* | |
* @version | |
* 2.0.320 (May 03 2009) | |
* |
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
# PSEUDOCODE | |
# INPUT rows: integer (0 or positive) for number of rows (/columns) | |
# OUPUT times table: printed times table with the input number of rows/columns | |
# STEPS | |
# SET a collection with elements 1..rows | |
# SET counter to 1 | |
# WHILE counter is less than/equal to rows | |
# ITERATE over elements of collection | |
# MULTIPLY element by counter |
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
=begin | |
As you are debugging, ask yourself: | |
* Do you have enough information to decipher the problem? | |
* Is the error message referencing a line in your file, or a different file? | |
* Is there a methodology that you are following to systematically tackle these bugs? What is a step by step approach? | |
###2) Decipher the bugs | |
For each bug (there are three initial bugs that cause interpreter errors), answer the following questions: |