Skip to content

Instantly share code, notes, and snippets.

View schneems's full-sized avatar

Richard Schneeman schneems

View GitHub Profile
@schneems
schneems / gist:2990855
Created June 25, 2012 19:54
Databases and Rails Recap Quiz for Week 3 [solution]
## 1) What does ERB stand for?
Embedded RuBy
## 2) What is the name of the place (library) where additional built in Ruby functions can be accessed?
STDlib
@schneems
schneems / gist:3029994
Created July 1, 2012 23:20
Databases and Rails Recap Quiz for Week 4
## 1) What does MVCr stand for?
## 2) In what file do we store 'r' from MVCr ?
@schneems
schneems / gist:3036609
Created July 3, 2012 00:25
Databases and Rails Recap Quiz for Week 3
## Week 3 Quiz
## 1) What does ERB stand for?
## 2) What is the name of the place (library) where additional built in Ruby functions can be accessed?
@schneems
schneems / gist:3079202
Created July 9, 2012 21:45
Week 5 Quiz
## Week 5 Quiz
## 0) Name 3 types of variables in Ruby? Put them in order from least scope to greatest.
## 1) Where do SQL queries belong, the view or controller?
@schneems
schneems / gist:3080499
Created July 10, 2012 01:53
Databases and Rails Recap Quiz for Week 4 [solution]
## 1) What does MVCr stand for?
Model View Controller Routes
## 2) In what file do we store 'r' from MVCr ?
@schneems
schneems / gist:3118875
Created July 15, 2012 22:08
Week 6 Quiz
## 1) Instance or class method?
A) User.where(:name => 'rich')
@schneems
schneems / gist:3140721
Created July 19, 2012 04:18
Week 5 Quiz (Solutions)
## Week 5 Quiz
## 0) Name 3 types of variables in Ruby? Put them in order from least scope to greatest.
a) Local (new = "foo")
b) Instance (@new = "foo")
c) Constant (NEW = "foo")
## 1) Where do SQL queries belong, the view or controller?
@schneems
schneems / gist:3166371
Created July 23, 2012 21:35
Week 7 Quiz
## 1) What is SQL Injection
## 2) Which of these are safe from SQL Injection attacks?
A)
User.where(:name => params[:name])
@schneems
schneems / gist:3183527
Created July 26, 2012 17:57
Week 6 Quiz Solutions
## 1) Instance or class method?
A) User.where(:name => 'rich')
Class Method
B) @user.favorite_movie
1.9.3p194 :027 > Benchmark.measure {User.where(:name => 'richard').first.products}.real
=> 0.001004934310913086
1.9.3p194 :028 > Benchmark.measure {Product.joins(:user).where(:users => {:name => 'richard'})}.real
=> 0.00015497207641601562