Skip to content

Instantly share code, notes, and snippets.

View koriroys's full-sized avatar
🐢
Slow and Steady

Kori Roys koriroys

🐢
Slow and Steady
View GitHub Profile
@JeffCohen
JeffCohen / coins.rb
Created August 6, 2012 01:38
Coin Change Machine
require 'test/unit'
class ChangeMachine
# Returns an array indicating the quantity of
# each denomination required.
# [pennies, nickels, dimes, quarters]
def issue_coins(amount)
end
end
@thegrubbsian
thegrubbsian / deploy.rake
Created June 13, 2012 17:22
Heroku Deploy Rake Task
namespace :deploy do
HEROKU_ACCOUNT = "account_name"
MAINLINE_BRANCH = "master"
STAGING_REPO = "app-name-staging"
PRODUCTION_REPO = "app-name-production"
def make_git_timestamp
"#{@env}-deploy-#{Time.now.to_s.gsub(/:/, "-").gsub(/\s/, "-").gsub(/--/, "-")}"
end
@daytonn
daytonn / file_conditional.sh
Created June 11, 2012 21:36
Conditionally load an .aliases file in .bash_profile
# Include alias file
if [ -f ~/.aliases ]
then
source ~/.aliases
fi
@JoshCheek
JoshCheek / README.md
Last active May 2, 2021 19:44
Challenge to create your own struct

This is a response for one of our apprentices who wanted to learn more about how structs work.

TL;DR

Part of this is a response and part of it a challenge. If you are only interested in the challenge clone the repo and run rake (more detailed instructions here).

Introduction

@JennDudley
JennDudley / rails_github_heroku.md
Created April 25, 2012 20:56
Steps to set up a new Rails app, initialize a git repo, push to Github and deploy to Heroku

This is a list of steps to:

  • Setup a new Rails app
  • Initialize a local repository using git
  • Create a new remote repository using GitHub
  • Change README.rdoc
  • Deploy to a cloud service - Heroku

Assumptions:

  • Ruby is installed (v 1.9.3)
  • Rails is installed (v 3.2.3)
@coreyhaines
coreyhaines / Gemfile
Created March 14, 2012 23:22
Running a worker
source :rubygems
@thegrubbsian
thegrubbsian / product.rb
Created February 11, 2012 19:00
QueryBuilder Example
class Product < ActiveRecord::Base
def self.find_by_criteria(params)
query = where("id IS NOT null") # A little odd but not sure how to get an ActiveRecord::Relation that returns "all"
query = query.where("price = ?", params[:price]) if params[:price].present?
query = query.where("manufacturer = ?", params[:manufacturer]) if params[:manufacturer].present?
query = query.where("retailer = ?", params[:retailer]) if params[:retailer].present?
query = query.where("category = ?", params[:category]) if params[:category].present?
query
end