Skip to content

Instantly share code, notes, and snippets.

View ysr23's full-sized avatar

ysr23 ysr23

  • Manchester, England
View GitHub Profile
@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>
@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: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'
*/01 * * * * cd ~/sites/www/twelly/
*/01 * * * * rake get_twelly
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
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?
@ysr23
ysr23 / gist:1335987
Created November 3, 2011 07:45
Time taken to fill DB on 2 machines

On my scrotebook

toast@scrotebook:~/ruby/twelly/script$ ./filldb.sh

  • cd /var/www/twelly/
  • export PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/www/twelly/lib:/usr/local/bin
  • PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/www/twelly/lib:/usr/local/bin
  • export RAILS_ENV=development
  • RAILS_ENV=development ++ date
@film = Film.find(:all).each do |f|
#if Film_imdb.exists?(['title = ?', (f.title)]) then
imdb_search = Imdb::Search.new(f.title)
link = imdb_search.movies.first.url
poster = imdb_search.movies.first.poster
length = imdb_search.movies.first.length
rating = imdb_search.movies.first.rating
plot = imdb_search.movies.first.plot
year = imdb_search.movies.first.year
@ysr23
ysr23 / gist:1372987
Created November 17, 2011 11:51
twelly$ git log --pretty=oneline --abbrev-commit --branches=*
twelly$ git log --pretty=oneline --abbrev-commit --branches=*
19dd560 mid-way through refactor
b817a23 unused files removed
f2ba94e all imdb now done in rakes
b82026a final push for twell-server
eb620f9 updated link
8496e17 posting to webtwelly like a king
2cbbcf1 now next working
967e2ba super polly fixed the crontab
@ysr23
ysr23 / gist:1676373
Created January 25, 2012 13:59
PostGreSQL error on railstutorial 3.2
Installing pg (0.12.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/toast/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --without-pg-config
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***