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: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: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
 =&gt; Float 
@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: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:"
$ cd path/to/repos
$ mkdir hello
$ cd hello
$ cd path/to/repos
$ mkdir hello
$ cd hello
$ git init
Initialized empty Git repository in /home/toast/rails/hello/.git/
$
$ vim hello.sh
echo "Hello, World!"
$ vim goodbye.sh
echo "Goodbye"
echo "cruel"
echo "world"
$ git add hello.sh
$ git add goodbye.sh
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: goodbye.sh
# new file: hello.sh