Skip to content

Instantly share code, notes, and snippets.

View tinomen's full-sized avatar

Jake Mallory tinomen

View GitHub Profile
@tinomen
tinomen / client.rb
Created January 26, 2011 01:43
demo for urug on msgpack and 0mq
require 'Date'
class Client
attr_accessor :from, :msg
attr_reader :at, :diff
def initialize
@at = Time.now
end
@tinomen
tinomen / a_couchdb_recipe_for_ey.txt
Created March 30, 2011 00:29
Altered couchdb recipe for use on EngineYard with chef-solo 0.6
I had to alter the recipe for couchdb available on opscode.com to work on engine yard. (http://community.opscode.com/cookbooks/couchdb)
1. EY still uses chef-solo 0.6 which requires the attributes file to be changed. trial and error found a working solution
2. EY is on gentoo and the service commands hang. Changed recipe to use the typical init.d path. Updated the init.d script.
3. added couchdb.yml template to add file to app_server:/data/[app_name]/shared/config
FYI I commented out the reference to the erlang recipe for now as we've added the erlang package to the entire environment.
@tinomen
tinomen / registry_test.rb
Created April 9, 2011 02:01
Service Locator Pattern - remove the explicit references to external class names. *** I had it in my head to write something that would provide the basics of the service locator pattern. While this will provide all services without error it still leaves t
puts __FILE__
require "../service_locator.rb"
require "test/unit"
class TestServiceRegistry < Test::Unit::TestCase
def test_registry
reg = Service::Registry.new
assert_not_nil(reg)
assert_nil(reg[:bob])
@tinomen
tinomen / install_riak_with_homebrew.bash
Created April 14, 2011 22:49
riak needs erlang R13b04 and homebrew now defaults to R14
# first install erlang using the R13b04 formula
brew install https://github.com/mxcl/homebrew/raw/810d52f4a386ea9e2b837030120ffd69cad73722/Library/Formula/erlang.rb
# now you are free to install riak
brew install riak
@tinomen
tinomen / rails_logger.rb
Created May 25, 2011 16:44
changing the default rails logger
Rails::Initializer.run do |config|
log = Logger.new(File.dirname(__FILE__) + "/../log/#{RAILS_ENV}.log")
log.formatter = Logger::Formatter.new
log.level = (Services.env == 'production') ? Logger::INFO : Logger::DEBUG
log.datetime_format = "%Y-%m-%d %H:%M:%S "
config.logger = log
end
@tinomen
tinomen / Gemfile
Created June 22, 2011 04:51
example goliath app
source 'http://rubygems.org'
# gem 'goliath'
gem 'goliath', :git => 'https://github.com/postrank-labs/goliath.git'
gem 'em-http-request', '>= 1.0.0.beta.1'
# gem 'em-http-request', :git => 'https://github.com/igrigorik/em-http-request.git'
gem 'yajl-ruby'
group :development, :test do
@tinomen
tinomen / Gemfile
Created June 29, 2011 01:26
goliath demo
source 'http://rubygems.org'
gem 'goliath', :git => 'https://github.com/postrank-labs/goliath.git'
gem 'yajl-ruby'
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :require => 'eventmachine'
gem 'em-http-request', :git => 'https://github.com/igrigorik/em-http-request.git'
gem "em-synchrony", :git => 'https://github.com/igrigorik/em-synchrony.git'
@tinomen
tinomen / mail.rb
Created September 8, 2011 05:44
basic mail smtp setup
# in enviornment.rb
config.after_initialize do
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'domain.com',
:from => '[email protected]',
:user_name => '[email protected]',
:password => 'secret',
:authentication => :login,
@tinomen
tinomen / greatest_product.txt
Last active December 15, 2015 11:08
2013-03 slc.rb problem 1
Find the greatest product of five consecutive digits in the 1000-digit number.
Make a program that recieves a string of numbers (see below) and outputs the answer
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
@tinomen
tinomen / roman_numerals.txt
Created March 27, 2013 02:14
2013-03 slc.rb problem 2
Convert a number between 1 and 4999 (integer only) to the roman numeral representation.
make a command line program that takes 1 argument as a number and outputs the roman numerals.
An online converter is available at http://www.onlineconversion.com/roman_numerals_advanced.htm