Skip to content

Instantly share code, notes, and snippets.

View treybean's full-sized avatar

Trey Bean treybean

View GitHub Profile
@treybean
treybean / prawn_handler_rails_3.rb
Created August 12, 2010 22:22
Prawn Handler for Rails 3
# in config/initializers
module ActionView
module Template::Handlers
class Prawn < Template::Handler
include ActionView::Template::Handlers::Compilable
self.default_format = Mime::PDF
def compile(template)
@treybean
treybean / deploy.rb
Created August 16, 2011 17:40
Heroku Deployment Script
#!/usr/bin/env ruby
# Usage
# ./deploy [staging|production] <options>
#
# Options
# -m or --maintenance - Put the application into maintenance mode
# -b or --branch - deploy from a branch other than "master"
if ['staging', 'production'].include? ARGV[0]
@treybean
treybean / 3_highest_product_of_3.rb
Created September 14, 2016 22:59
highest_product_of_3
require "test/unit"
include Test::Unit::Assertions
# Given an array_of_ints, find the highest_product you can get from three of the integers.
# The input array_of_ints will always have at least three integers.
# First attempt. O(n log(n)) (from sort), O(1) space. Bad, though, because it didn't handle negative numbers.
# def highest_product(array_of_ints)