This file contains hidden or 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
| require 'json' | |
| require 'rest_client' | |
| reddit_hash = JSON.parse(RestClient.get('http://reddit.com/.json')) | |
| def indent(string, num=1) | |
| string.each_line. | |
| map{|line| "#{" " * num}#{line}"}.join | |
| end | |
| def open_tag(string) |
This file contains hidden or 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
| ######################## | |
| # NYC PIGEON ORGANIZER # | |
| ######################## | |
| # Start with the following collected data on NYC pigs. | |
| pigeon_data = { | |
| :color => { | |
| :purple => ["Theo", "Peter Jr.", "Lucky"], | |
| :grey => ["Theo", "Peter Jr.", "Ms .K"], |
This file contains hidden or 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
| ######################## | |
| # NYC PIGEON ORGANIZER # | |
| ######################## | |
| # Start with the following collected data on NYC pigs. | |
| pigeon_data = { | |
| :color => { | |
| :purple => ["Theo", "Peter Jr.", "Lucky"], | |
| :grey => ["Theo", "Peter Jr.", "Ms .K"], |
This file contains hidden or 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
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <ul> | |
| <li> | |
| <a href=http://imgur.com/a/eMkM4> | |
| <h1>My friend having a great time in DC</h1> | |
| <img src=http://c.thumbs.redditmedia.com/mZ49t1GIpxyLU5MD.jpg /> | |
| <h4>Upvotes</h4> |
This file contains hidden or 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
| require "open-uri" | |
| require "Nokogiri" | |
| require "sqlite3" | |
| def create_db | |
| schema = students.first.keys.join(", ") | |
| rows = db.execute <<-SQL | |
| create table students ( | |
| schema | |
| ); |
This file contains hidden or 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
| class Anagram | |
| attr_reader :word | |
| def initialize(word) | |
| @word = word | |
| end | |
| def match(strings) | |
| strings.select do |string| |
This file contains hidden or 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
| songs = [ | |
| "The Phoenix - 1901", | |
| "Tokyo Police Club - Wait Up", | |
| "Sufjan Stevens - Too Much", | |
| "The Naked and the Famous - Young Blood", | |
| "(Far From) Home - Tiga", | |
| "The Cults - Abducted", | |
| "The Phoenix - Consolation Prizes" | |
| ] |
This file contains hidden or 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
| class School | |
| attr_reader :roster | |
| def initialize(school_name) | |
| @roster = {} | |
| @name = school_name | |
| end | |
| def add_student(stu_name, grade) | |
| (self.roster[grade] && (self.roster[grade] << stu_name)) || |
This file contains hidden or 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
| class TriangleError < Exception | |
| end | |
| class Triangle | |
| attr_reader :sides | |
| def initialize(side1, side2, side3) | |
| @sides = [side1, side2, side3].sort | |
| self.validate | |
| end |
This file contains hidden or 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
| class Person | |
| def initialize(attr_hash) | |
| attr_hash.each do |property, value| | |
| Person.send(:define_method, property) do | |
| @property = value | |
| end | |
| end | |
| end | |
| end |