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
class Student | |
attr_accessor :name, :twitter, :linkedin, :facebook, :website | |
attr_reader :id | |
@@students = [] | |
def initialize | |
@@students << self | |
@id = @@students.count | |
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
require_relative './student_scraper' | |
require_relative './student' | |
class CLIstudent | |
attr_accessor :student_array, :input, :on | |
def initialize(student_array) | |
@on = true | |
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
# # Binary Secret Handshake | |
# > There are 10 types of people in the world: Those who understand binary, and those who don't. | |
# You and your fellow flatirons are of those in the "know" when it comes to binary decide to come up with a secret "handshake". | |
# ``` | |
# 1 = wink | |
# 10 = double blink |
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
class Anagram | |
attr_accessor :word | |
def initialize(word) | |
@word = word | |
end | |
def match(target_array) | |
target_array.select do |target_word| | |
@word if @word.chars.sort == target_word.chars.sort |
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
require_relative './song_library.rb' | |
def jukebox(command) | |
if command.downcase == "list" | |
list_library | |
else | |
parse_command(command) | |
end | |
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
HOMEWORK | |
1. SELECT title, sum(amount) | |
FROM projects | |
JOIN pledges | |
ON projects.id = pledges.project_id | |
GROUP BY title; | |
2. SELECT name,age,amount | |
FROM users JOIN pledges | |
ON pledges.user_id = users.id; |
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
######################## | |
# NYC PIGEON ORGANIZER # | |
######################## | |
# Start with the following collected data on NYC pigeons. | |
pigeon_data = { | |
:color => { | |
:purple => ["Theo", "Peter Jr.", "Lucky"], |
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
require 'json' | |
require 'rest_client' | |
reddit_url = "http://www.reddit.com/" | |
reddit_hash = JSON.parse(RestClient.get('http://www.reddit.com/.json')) | |
#puts reddit_hash["data"]["children"][1] | |
#reddit_hash["data"].each {|k,v| puts k} |
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
# create a method called create_groups that, given an array of student names, | |
# a group size, and a number of groups, will return an array of groups of | |
# of students with no student in adjacent groups | |
def create_groups(students,group_size,group_count) | |
new_student_array = [] | |
i = 0 | |
j = 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
# tower_of_hanoi.rb | |
a = [1,2] | |
b = [] | |
c = [] | |
# Move the disks from one peg to another following the rules of Hanoi. | |
# | |
# number_of_disks - the total number of disks | |
# from - the starting peg |