1.9.3-p385 :020 > title = Recipe.find(12934).title
=> "The River Café's Strawberry Sorbet"
1.9.3-p385 :021 > title.encode('ISO-8859-1', 'utf-8')
=> "The River Caf\xC3\xA9's Strawberry Sorbet"
1.9.3-p385 :022 > puts _
The River Café's Strawberry Sorbet
=> nil
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 check | |
| ActiveRecord::Base.send(:subclasses).each do |klass| | |
| if klass.column_names.include?(klass.table_name) | |
| raise "#{klass.to_s}'s table name collides with column #{klass.table_name}" | |
| end | |
| end | |
| puts "All Clear." | |
| 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
| get '/' do | |
| if !File.exist?('cache') || (File.mtime('cache') < (Time.now - 1800)) | |
| puts "**********CACHE MISS**********" | |
| data = erb(:index) | |
| File.open('cache',"w"){ |f| f << data } | |
| else | |
| puts "**********CACHE HIT**********" | |
| end | |
| send_file 'cache', :type => 'html' | |
| 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
| Model.find(1,2) == Model.find(2,1) | |
| => true | |
| Model.find(1,2) == Model.find(2,1).reverse | |
| => false |
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
| SELECT COUNT(*) FROM `shipments` WHERE (status != 'delivered') | |
| SELECT COUNT(*) FROM `shipments` WHERE (status IS NULL OR status != 'delivered') |
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 status | |
| if self.reverted then | |
| "Reverted" | |
| elsif !self.ship_date then | |
| "Open" | |
| elsif (self.tracking_numbers.length == 0 and !self.shipping_cost_micros) then | |
| "Processing (awaiting)" | |
| else | |
| self.ship_date > Date.today ? | |
| "Processing" : |
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
| 1.8.7-p370 :008 > MICHAEL = "michael" | |
| => "michael" | |
| 1.8.7-p370 :009 > a = MICHAEL | |
| => "michael" | |
| 1.8.7-p370 :010 > a << " hoffman" | |
| => "michael hoffman" | |
| 1.8.7-p370 :011 > a | |
| => "michael hoffman" | |
| 1.8.7-p370 :012 > MICHAEL | |
| => "michael hoffman" |
NewerOlder