This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a MathService module that has a method that can sum an Array of Numbers | |
# It should raise an exception if not given an Array. | |
# It should raise an exception if any elements are not Numeric. | |
module MathService | |
def sum array_of_numbers | |
raise unless array_of_numbers.is_a? Array | |
sum = array_of_numbers.inject(0) do |s,n| | |
raise unless n.is_a? Numeric | |
s += n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a ASIR::Transport::HTTP class | |
# Using HTTP::Client for transport send_request and receive_response. | |
# Using WEBrick for transport on the receive_request and send_response. | |
# Use the Marshal Coder for the Transport. | |
require 'rubygems' | |
require 'webrick' | |
gem 'httpclient' | |
require 'httpclient' | |
require 'uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a ASIR::Transport::HTTP class | |
# Using HTTP::Client for transport send_request and receive_response. | |
# Using WEBrick for transport on the receive_request and send_response. | |
# Use the Marshal Coder for the Transport. | |
require 'rubygems' | |
require 'webrick' | |
gem 'httpclient' | |
require 'httpclient' | |
require 'uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a ASIR::Transport::HTTP class | |
# Using HTTP::Client for transport send_request and receive_response. | |
# Using WEBrick for transport on the receive_request and send_response. | |
# Use the Marshal Coder for the Transport. | |
require 'rubygems' | |
require 'webrick' | |
gem 'httpclient' | |
require 'httpclient' | |
require 'uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time ruby -X+O -e "h=[]; 10000.times {|n| h = [n,n*n]}; c=0; ObjectSpace.each_object {|o| c+=1 }; puts c; GC.start; c=0; ObjectSpace.each_object {|o| c+=1 }; puts c; puts h.inspect" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
USAGE="Usage: $0 [gemset] command [args]" | |
# No args?: | |
if [ "$#" == "0" ]; then | |
echo "$USAGE" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hack to disable_referential_integrity for postgres users with sane | |
# permissions, uses deferral of constraints instead of disablement of the | |
# superuser-owned per-table triggers. Allows testing with fixtures which | |
# otherwise produce RI_ConstraintTrigger Errors. | |
# | |
# source: http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error | |
# ref: https://github.com/matthuhiggins/foreigner/issues/61 | |
module ActiveRecord | |
module ConnectionAdapters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem list -dl | |
*** LOCAL GEMS *** | |
rake (0.9.2) | |
Author: Jim Weirich | |
Rubyforge: http://rubyforge.org/projects/rake | |
Homepage: http://rake.rubyforge.org | |
Installed at: /Users/bruceb/.rvm/gems/ruby-1.8.7-p352 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export rvm_path="$HOME/.rvm" | |
# Make this work with OS X Lion... for now... | |
if [[ `uname -v` =~ "Darwin Kernel Version 11" ]] ; then | |
export CC=/usr/bin/gcc-4.2 | |
#export CC=/usr/bin/i686-apple-darwin11-gcc-4.2.1 | |
fi | |
# Export compile flags for MacPorts: | |
if [ -d /opt/local/bin ] ; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rvm --version | |
rvm 1.16.13 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] | |
$ rvm install 1.9.3 | |
No binary rubies available for: osx/10.7/x86_64/ruby-1.9.3-p286. | |
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies. | |
Installing Ruby from source to: /Users/bruceb/.rvm/rubies/ruby-1.9.3-p286, this may take a while depending on your cpu(s)... | |
ruby-1.9.3-p286 - #downloading ruby-1.9.3-p286, this may take a while depending on your connection... | |
ruby-1.9.3-p286 - #extracting ruby-1.9.3-p286 to /Users/bruceb/.rvm/src/ruby-1.9.3-p286 |
OlderNewer