Skip to content

Instantly share code, notes, and snippets.

View mecampbellsoup's full-sized avatar

Matt Campbell mecampbellsoup

View GitHub Profile
require 'awesome_print'
holiday_supplies = {
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
:summer => {
:fourth_of_july => ["Fireworks", "BBQ"]
},
def take_a_number(current_line, name)
current_line << name
puts current_line.index(name)+1
end
def now_serving(current_line)
puts "Currently serving #{current_line.first}"
current_line.shift
end
require 'pry'
# Hashketball Nests
#
# Great news! You're going to an NBA game! The only catch is that you've been
# volunteered to keep stats at the game.
#
# Using Nested Hashes, define a game, with two teams, their players, and the players stats:
#
# The game has two teams.
require 'pry'
require 'awesome_print'
# 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=4, num_groups=20)
students.shuffle!
student_groups = []
require 'awesome_print'
########################
# NYC PIGEON ORGANIZER #
########################
# Start with the following collected data on NYC pigeons.
pigeon_data = {
:color => {
@mecampbellsoup
mecampbellsoup / kickstarter.sql
Created October 4, 2013 12:55
kickstarter database to learn sql :)
-- Create a schema based on the following information:
-- A project has a title, a category, a funding goal, a start date, and an end date. Valid categories are: music, books, charity.
-- A user has a name and an age
-- A pledge has an amount. It belongs to a user, and it also belongs to a project.
-- Insert some records into the datbase
@mecampbellsoup
mecampbellsoup / scrape.rb
Last active December 24, 2015 19:49
student profile scraper!
require_relative 'student_profiles_rake'
require 'pry'
def students_scrape_loop
Student.make_schema
Student.get_students.each do |student_url|
obj = Student.new(student_url)
obj.scrape_data
obj.save_to_database
end
@mecampbellsoup
mecampbellsoup / anagram.rb
Created October 7, 2013 14:49
ruby can do anything - anagrams in this case.
require 'pry'
class Anagram
attr_accessor :match_word
def initialize(match_word)
@match_word = match_word
end
@mecampbellsoup
mecampbellsoup / game_of_life_old.rb
Last active December 24, 2015 23:09
This was the bulk of my logic for coding Conway's Game of Life as I was first learning to code (last week, that is).
# setup code whereby the world of gridsize "x" by "x" cells is
# generated has been omitted for brevity, but know that the world
# argument below refers to an array of arrays giving us a 2D 'map'
# of sorts full of cells; if a cell's value == 1, that cell is alive;
# if its value == 0, that cell is dead. whether a cell lives or dies
# in the next generation of life depends solely on its # of neighbors
# and that logic is contained below.
def run_generation_of_life(world)
new_world = []
@mecampbellsoup
mecampbellsoup / binary_handshake.rb
Last active December 25, 2015 00:08
secret handshake binary decoder!!!
# # 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".
# Write a program that will convert a binary number, represented as a string (i.e. "101010"), and convert it to the appropriate sequence of events for a secret handshake.
# The program should consider strings specifying an invalid binary as the value 0.