Skip to content

Instantly share code, notes, and snippets.

View ysr23's full-sized avatar

ysr23 ysr23

  • Manchester, England
View GitHub Profile
If i set default scope as below it works as seen in the count
------------
default_scope where('start > ?', Time.now+1.hour)
irb(main):016:0> guide = Guide.bbc1.count
=> 481
--------------------
yet if i set it as below it doesn't?
1 # Logfile created on 2011-10-24 18:08:09 +0100 by logger.rb/25413
2 Starting: 2011-10-24 18:09:23 +0100
3 Beginning: tv.xml, approx 24055698
4 Finishing: 2011-10-24 19:57:50 +0100
5 36170
*/01 * * * * cd ~/sites/www/twelly/
*/01 * * * * rake get_twelly
@ysr23
ysr23 / gist:1298211
Created October 19, 2011 12:58
distance_of_time_in_words
irb(main):062:0> puts time_start.class
ActiveSupport::TimeWithZone
=> nil
irb(main):063:0> distance_of_time_in_words(time_start, Time.now)
NoMethodError: undefined method `distance_of_time_in_words' for main:Object
from (irb):63
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
@ysr23
ysr23 / gist:1295352
Created October 18, 2011 12:54
string to scope
so i parse my tweet:
irb(main):033:0> p qry = reply[1] + " " + reply[2]
"bbc1 now"
=> "bbc1 now"
and these are the arguments that i would like to put on the class Guide
(eventually i will need to check that these do match the named scopes i have made)
@ysr23
ysr23 / gist:1295158
Created October 18, 2011 10:55
Guide.film.future.find(:all, :select => "DISTINCT(title), channel, start" ).to_xml
<?xml version="1.0" encoding="UTF-8"?>
<guides type="array">
<guide>
<channel>itv3.itv.co.uk</channel>
<start type="datetime">2011-10-23T14:35:00Z</start>
<title>*batteries not included</title>
</guide>
<guide>
<channel>channel4.com</channel>
<start type="datetime">2011-10-21T12:15:00Z</start>