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
Started GET "/work_orders/queue" for 127.0.0.1 at 2010-07-18 19:53:11 -0400 | |
SQL (1.6ms) SELECT name | |
FROM sqlite_master | |
WHERE type = 'table' AND NOT name = 'sqlite_sequence' | |
SQL (1.1ms) SELECT name | |
FROM sqlite_master | |
WHERE type = 'table' AND NOT name = 'sqlite_sequence' | |
SQL (1.1ms) SELECT name | |
FROM sqlite_master |
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
# model | |
class GiftIdea | |
has_many :images | |
end | |
# in the view (say app/views/gift_ideas/show.html.erb) | |
# say we are rendering html about one GiftIdea object, found in the @gift_idea variable | |
.. | |
.. | |
<div class="gift_idea"> |
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
Started GET "/product_categories/autocomplete_for_product_sub_category_name?q=ang&limit=10×tamp=1279805094583" for 130.15.105.53 at 2010-07-22 09:29:55 -0400 | |
Processing by ProductCategoriesController#autocomplete_for_product_sub_category_name as HTML | |
Parameters: {"q"=>"ang", "limit"=>"10", "timestamp"=>"1279805094583"} | |
Rendered inline template (0.6ms) | |
Completed 200 OK in 58ms (Views: 1.7ms | ActiveRecord: 7.7ms) | |
Started GET "/product_categories/autocomplete_for_product_sub_category_name?q=ang&limit=10×tamp=1279805094583" for 130.15.105.53 at 2010-07-22 09:30:05 -0400 | |
Processing by ProductCategoriesController#autocomplete_for_product_sub_category_name as HTML | |
Parameters: {"q"=>"ang", "limit"=>"10", "timestamp"=>"1279805094583"} |
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 build_role(&block) | |
@role = Role.new | |
self.instance_eval &block if block_given? | |
r = @role | |
@role = nil | |
r | |
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
Questions: do you always need to have m or can you just use a helper method where you get the number of elements in a, that way you limit the number of parameters you pass always? | |
1. More on list intersections | |
Algorithm: commonElementsList( a, m, b, n) | |
Input: Two arrays, a and b, with m and n distinct String elements respectively | |
Output: A list of String elements common to both arrays | |
function commonElementsList( a, m, b, n) { | |
if( listIntersection( a, m, b, n ) > 0 ) |
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
User | |
- has_many :end_of_day_reports | |
Quote | |
- has_and_belongs_to_many :end_of_day_reports | |
- has_many :time_reports | |
EndOfDayReport | |
- has_and_belongs_to_many :quotes | |
- belongs_to :user |
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
module Toto | |
module Template | |
def to_html page, config, &blk | |
path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages]) | |
config[:to_html].call(path, page, self, blk) | |
end | |
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
toto = Toto::Server.new do | |
# ... | |
set :to_html, lambda {|path, page, ctx, blk| | |
Dir.glob("#{path}/#{page}.*").each do |filename| | |
return ::Tilt.new(filename).render(ctx, &blk) | |
end | |
raise Errno::ENOENT # Tell toto to 404 if no files can be found | |
} |
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
hash = {foo: 1, bar: 2, baz: 3} | |
handlers = [] | |
for key, val of hash | |
callback = -> | |
console.log "Callback has been called for key #{key}" | |
handlers[val] = callback | |
handlers[1].call() # outputs 'baz' instead of the expected 'foo', because baz was the last key assigned. |
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
// A complete example. | |
var Post = Backbone.Model.extend({ | |
validations: { | |
body: { | |
required: true, // Uses the built in validation methods | |
minLength: 100 | |
}, | |
title: { | |
// Pass multiple arguments to the validation function | |
lengthInRange: [10,100], |