Skip to content

Instantly share code, notes, and snippets.

View TrevMcKendrick's full-sized avatar

Trevor McKendrick TrevMcKendrick

View GitHub Profile
class Student
attr_accessor :name, :twitter, :linkedin, :facebook, :website
attr_reader :id
@@students = []
def initialize
@@students << self
@id = @@students.count
end
require_relative './student_scraper'
require_relative './student'
class CLIstudent
attr_accessor :student_array, :input, :on
def initialize(student_array)
@on = true
end
# # 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
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
require_relative './song_library.rb'
def jukebox(command)
if command.downcase == "list"
list_library
else
parse_command(command)
end
end
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;
########################
# NYC PIGEON ORGANIZER #
########################
# Start with the following collected data on NYC pigeons.
pigeon_data = {
:color => {
:purple => ["Theo", "Peter Jr.", "Lucky"],
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}
# 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
# 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