Skip to content

Instantly share code, notes, and snippets.

View quackhouse's full-sized avatar

Morgan Neiman quackhouse

View GitHub Profile
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
# 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_group :development, :test do
# 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]
@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:
@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 / 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 / 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 / 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 / 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 / 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