Skip to content

Instantly share code, notes, and snippets.

View ysr23's full-sized avatar

ysr23 ysr23

  • Manchester, England
View GitHub Profile
$ cd path/to/repos
$ mkdir hello
$ cd hello
$ cd path/to/repos
$ mkdir hello
$ cd hello
@ysr23
ysr23 / gist:2929747
Created June 14, 2012 11:27
Grahams Homework Pt3 Self

Self is not so much a concept as an object. The default object.

There is always only one self, but what that is may change. Like a narrator in a book with multiple first-person identities.

puts "top level"
puts "self is #{self}"

class C
 puts "Class Definition Block:"
@ysr23
ysr23 / gist:2730523
Created May 19, 2012 11:29
Grahams Homework Pt2.1 Variables

Variables

Local variables hold their value during a particular section of code. Local refers therefore to their 'scope' this can be seen through the value of the variable x below:

ruby-1.9.2-p0 > def support_united
ruby-1.9.2-p0 ?>  x = "I Support United"
ruby-1.9.2-p0 ?>  puts x
ruby-1.9.2-p0 ?>  end
ruby-1.9.2-p0 > def support_city
ruby-1.9.2-p0 ?>  x = "I Support City"
@ysr23
ysr23 / gist:2725401
Created May 18, 2012 13:58
Grahams Homework Pt1 Numbers & Strings

#Numbers

Numbers take the form of Fixnum, Bignum (Class: Integer from Class: Numeric) or Float(Class: Numeric) there are others but they are part of the Standard Library, these are Complex, BigDecimal and Rational - these are not covered here. I can't be arsed. Sooo...

ruby-1.9.2-p0 > 5.class
 => Fixnum 
ruby-1.9.2-p0 > 5453897348957348957389457389457398.class
 => Bignum 
ruby-1.9.2-p0 > 5.0.class
 => Float 
@ysr23
ysr23 / gist:1738470
Created February 4, 2012 15:23
using the twitter gem - private notes
ruby-1.9.2-p0 > Twitter.search("#mufc -rt", :rpp => 1).first
=> #<Twitter::Status:0x0000010120e728 @attrs={"created_at"=>"Sat, 04 Feb 2012 14:58:25 +0000", "from_user"=>"MostlyMinutiae", "from_user_id"=>19573143, "from_user_id_str"=>"19573143", "from_user_name"=>"Anthony Casaldi", "geo"=>nil, "id"=>165811451985014786, "id_str"=>"165811451985014786", "iso_language_code"=>"en", "metadata"=>{"result_type"=>"recent"}, "profile_image_url"=>"http://a2.twimg.com/profile_images/1490597356/image_normal.jpg", "profile_image_url_https"=>"https://si0.twimg.com/profile_images/1490597356/image_normal.jpg", "source"=>"&lt;a href=&quot;http://www.echofon.com/&quot; rel=&quot;nofollow&quot;&gt;Echofon&lt;/a&gt;", "text"=>"Looks like I'm waking up early to watch #MUFC vs #CFC tomorrow. And...rooting for Man U?! That feels dirty.", "to_user"=>nil, "to_user_id"=>nil, "to_user_id_str"=>nil, "to_user_name"=>nil}>
ruby-1.9.2-p0 > Twitter.search("#mufc -rt", :rpp => 1).first.from_user_id
=> 269318142
ruby-1.9.2-p0 > id = Twitter
@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 ***
@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
@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: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