Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

String#to_range

// convert a string like "1-10" to a range 1..10

   1  
   2  class String; def to_range; Range.new(*self.split("-").map{|i|i.to_i}); end; end

get all local variables

   1  >> local_variables
   2  # => ["_"]  
   3  
   4  >> a = "Kevin"
   5  # => "Kevin"  
   6  
   7  >> local_variables
   8  # => ["_", "a"]  

Building curb under Mac OS X

Had a bit of a problem getting curb to work in OS X, but if you have the curl port installed, its easy:

sudo port install curl
cd src
curl -O http://rubyforge.iasi.roedu.net/files/curb/curb-0.1.0.tar.gz
tar -zxvf curb-0.1.0.tar.gz
cd curb-0.1.0.tar.gz
ruby extconf.rb --with-curl-lib=/opt/local/lib/ --with-curl-include=/opt/local/include/
ruby tests/alltests.rb
sudo make install

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS