This file contains 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
function cat(a,b,c){ | |
return c ? (a + b) : (a); | |
} | |
function fizz(i,s){ | |
return cat(s,"Fizz", (i%5===0)); | |
} | |
function buzz(i,s){ | |
return cat(s,"Buzz", (i%3===0)); |
This file contains 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
function foo(){ | |
alert("I'm Awesome!"); | |
} | |
foo(); |
This file contains 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
Hash[*(doc/"/b").map{|e| [e.inner_html.squeeze(" ").chomp(" ").chomp(":"), e.next.to_s.squeeze(" ").chomp(" ")] }.flatten] |
This file contains 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
{ | |
"teacher": { | |
"rating": 4.66666666666667, | |
"listings_count": 5, | |
"mediumImageUrl": "http://images3.teachstreet.com:80/image/view?e=cr-75-75&id=im-d0rg2h1ldc&reference_id=ir-19f7mu9xnvk", | |
"about_me": "<p>This is my amazing description.This is my amazing description This is my amazing descriptionThis is my amazing description This is my amazing description This is my amazing descriptionThis is my amazing description.</p>\r\n<p><a href=\"http://www.teachstreet.com/teacher-requests/create\" class=\"\" target=\"_blank\">foo</a></p>\r\n<p> </p>\r\n<p> </p>\r\n<p> </p>\r\n<p> </p>\r\n<p> </p>\r\n<p> </p>", | |
"location": { | |
"name": "Seattle, WA", | |
"city": "Seattle", | |
"lon": -122.333139770975, |
This file contains 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
#!/usr/bin/env ruby | |
require 'netflix' | |
File.open('catalog_titles_index.xml', 'w') do |f| | |
f.write(Netflix.catalog_titles_index) | |
end |
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'ruby_odata' | |
svc = OData::Service.new "http://odata.netflix.com/Catalog/" | |
puts "DVD:" | |
svc.Titles.filter("AverageRating le 2 and Type eq 'Movie' and Dvd/Available eq true").order_by("AverageRating asc").top(100) | |
movies = svc.execute |
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'redis' | |
redis = Redis.new | |
ratings = redis.zrangebyscore("netflix_ratings", 0, 5, :with_scores => true, :limit => [0, 100]) | |
counter = 0 | |
index = 1 |
This file contains 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
#!/usr/bin/env ruby | |
require 'netflix' | |
require 'redis' | |
redis = Redis.new | |
File.open("movies.txt", "r") do |f| | |
f.each_line do |line| | |
id = line.chomp |
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'oauth' | |
require 'crack' | |
class Netflix | |
class CatalogTitle | |
attr_accessor :average_rating, :release_year, :category, :short_title, :title, :id, :runtime, :box_art, :link |
This file contains 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
# Store data alongside MongoDB instead of the default, /data/db/ | |
dbpath = /opt/local/var/mongodb/data | |
# Only accept local connections | |
bind_ip = 127.0.0.1 |
NewerOlder