Skip to content

Instantly share code, notes, and snippets.

View quackhouse's full-sized avatar

Morgan Neiman quackhouse

View GitHub Profile
@quackhouse
quackhouse / calculator.rb
Created September 25, 2013 14:36
Ruby Calculator
def getNumbers(workingArray)
# Method to take multiple integers as input from user.
puts "Please enter the numbers you'd like me to use. Type 'done' when you're finished."
nextnum = 0
# Creates nextnum as variable.
while nextnum != "done"
nextnum = gets.chomp!
if nextnum == "done"
puts "Calculating!"
elsif nextnum != "0" && nextnum.to_i == 0
@quackhouse
quackhouse / hashbook.rb
Last active December 24, 2015 01:19
HashBook - Beginnings of a Facebook-like (but super basic) social network. Storing capabilities for username, name, password, etc. Search function and ability to store a message to a user's "wall". No options for display of message, while loops in progress. Flow is not circular (no way to get back to home menu).
def ask(question)
# Defines method for asking questions and receiving input.
puts question
gets.chomp!
end
def get_name
puts "What is your full name?"
full_name = gets.chomp!
end
@quackhouse
quackhouse / subway_stops.rb
Last active December 24, 2015 01:19
Calculates number of stops for a subway trip in NYC on three lines.
module LastN
def last(n)
self[-n,n]
end
end
# Defines a module that calls certain range on object.
class String
include LastN
end
@quackhouse
quackhouse / group_lab.rb
Created September 27, 2013 00:50
Sorts students into groups of selected size and assigns nicknames to each group. Adds remainder to last group.
students = [ # Array of students' names.
"Alex Hint",
"Amy Ruan",
"Ana Giraldo-Wingler",
"Cooper Mayne",
"Diego Palma",
"Edward Shin",
"Enoch Riese",
"Harrison Powers ",
"Jaclyn Jimenez",
@quackhouse
quackhouse / apartments.rb
Last active December 24, 2015 05:59
Building Manager - tool to manage various buildings, add apartment characteristics inside and move renters in/out. Updated to store building information into apartment and person classes, stores apartment info in person class as well.
class Apartment
attr_accessor :price, :sqft, :num_beds, :num_baths, :renters, :apartment_number, :building
def initialize(apartment_number, sqft, num_beds, num_baths)
@apartment_number = apartment_number
@sqft = sqft
@num_beds = num_beds
@num_baths = num_baths
@price = (50 * sqft) + (1000 * num_baths) + (2000 * num_beds)
@tenants = {}
@building = ""
@quackhouse
quackhouse / game.rb
Created October 4, 2013 13:06
Ruby & Sinatra based Rock/Paper/Scissors game with options for multi- or single-player games.
def game(input1, input2)
if input1 == input2
outcome = "It's a tie!"
elsif input1 == "rock"
if input2 == "paper"
outcome = "Paper covers rock. Player 1 loses!"
elsif input2 == "scissors"
outcome = "Rock smashes scissors. Player 1 wins!"
end
elsif input1 == "paper"
@quackhouse
quackhouse / helpers
Created October 13, 2013 22:09
active_record_helpers
before do
ActiveRecord::Base.logger = Logger.new( STDOUT )
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host => "localhost",
:username => "Ducky",
:password => "",
:database => "instagram_db"
)
@quackhouse
quackhouse / Gemfile
Created October 17, 2013 13:08
Useful Development Gems for Rails
#Gemfile
group :development, :test do
gem 'pry-rails' # Causes rails console to open pry
# https://github.com/rweng/pry-rails
gem 'pry-debugger' # Adds step, next, finish, and continue commands and breakpoints
# https://github.com/nixme/pry-debugger
gem 'pry-stack_explorer' # Navigate the call-stack
# https://github.com/pry/pry-stack_explorer
gem 'annotate' # Annotate all your models, tests, fixtures, and factories
# https://github.com/ctran/annotate_models
@quackhouse
quackhouse / Rails Standard Database.yml
Created October 17, 2013 13:09
Reusable Database.yml for Rails
development:
adapter: postgresql
encoding: unicode
database: <%= File.basename(Rails.root) %>_development
pool: 5
host: localhost
username: <%= ENV['PG_USERNAME'] %>
password:
test:
# README
# pass in this file when creating a rails project
#
# for example:
# rails _3.2.14_ new awesome_app -d postgresql -m ~/kickhash_template.rb
remove_file "README.rdoc"
create_file "README.md", "TODO"
gem 'rspec-rails', group: [:test, :development]