Skip to content

Instantly share code, notes, and snippets.

@samueldowens
samueldowens / gist:6834325
Created October 4, 2013 23:07
get name of student page. Mostly do the social media stuff...
individual_student_page = Nokogiri::HTML(open('http://students.flatironschool.com/students/vivianzhang.html'))
###get name
student_name_partial = individual_student_page.css("body div h4")
student_name = student_name_partial.text ###Final Student Name
###end get name
-- 1.
SELECT project.title, SUM(pledge.amount) AS 'total'
FROM
project
INNER JOIN
pledge
ON
project.id = pledge.project_id
GROUP BY
project.title;
@samueldowens
samueldowens / jukebox
Created October 3, 2013 16:53
1st is the jukebox.rb file, second is the runner, which i think only had one small change. the jukebox one is the meat.
require_relative './song_library.rb'
def jukebox(command)
if command.downcase == "list"
list_library(full_library)
else
parse_command(command)
end
end
@samueldowens
samueldowens / gist:6809175
Created October 3, 2013 12:39
Pigeon_list
pigeon_data = {
:color => {
:purple => ["Theo", "Peter Jr.", "Lucky"],
:grey => ["Theo", "Peter Jr.", "Ms .K"],
:white => ["Queenie", "Andrew", "Ms .K", "Alex"],
:brown => ["Queenie", "Alex"]
},
:gender => {
:male => ["Alex", "Theo", "Peter Jr.", "Andrew", "Lucky"],
:female => ["Queenie", "Ms .K"]
@samueldowens
samueldowens / gist:6794504
Created October 2, 2013 14:19
reddit SFW
require 'json'
require 'rest_client'
reddit_hash = JSON.parse(RestClient.get('http://reddit.com/.json'))
over_18 = []
title = []
reddit_url = []
thumbnail = []
upvotes = []
@samueldowens
samueldowens / gist:6786003
Created October 1, 2013 22:11
Tower of Hanoi: Brute Force Method
#Tower of Hanoi
#rules:
# arrays will be the pegs
# each array goes from top on left to bottom on right
# win/stop when c = [1,2,3,4]
#pieces cannot go to a space where a lower number is farther into the array.
def move_disc
a = [1,2,3,4]
@samueldowens
samueldowens / gist:6778993
Created October 1, 2013 14:07
holiday supplier questions
1. holiday_supplies[:summer][:forth_of_july][1]
2. holiday_supplies[:winter][:christmas] << "Tree"
3. holiday_supplies[:spring][:memorial_day] << "Charcoal"
4. holiday_supplies[:summer].merge!(:august_second => ["cake", "booze"])
5.
@samueldowens
samueldowens / gist:6772496
Created October 1, 2013 00:52
Hashketball...
# overall hash
# 2 subhashes, team 1 and team 2
# each team has 3 subhashes name, colors, players
# name = just pointer
# colors = array
# players = array
# player has the following hashes in an array: name, number, shoe_size, points, rebounds, assists, steals, blocks, slam_dunks
hashketball =
@samueldowens
samueldowens / gist:6733444
Created September 27, 2013 18:51
Sam's Jukebox
#Jukebox Program
#Greeting and setup for the program.
puts "Hello and welcome to the jukebox."
puts "Please let me know your name..."
name = gets.chomp
puts ""
puts "Okay #{name.capitalize}, let me tell you how this works."
puts ""
puts "You can type any of the following commands..."
@samueldowens
samueldowens / gist:6728817
Created September 27, 2013 13:45
todo FI Day 5
def normalize_phone_number(number)
array = number.split("")
finalnum = []
array.each do |var|
if "1,2,3,4,5,6,7,8,9,0".include?(var)
finalnum << var
end
end