Viendo que algunos me preguntaban como bajar e instalar ruby 1.9 para probarlo. Aca les dejo un script en bash que baja, descomprime, configura e instala ruby con un prefijo -1.9.1 en el directorio /opt/local (Directorio comunmente usado en osx por macports.)
#!/bin/sh
curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz > /tmp/ruby-1.9.1-p0.tar.gz
cd /tmp
tar xvf ruby-1.9.1-p0.tar.gz
cd ruby-1.9.1-p0
autoconf
./configure --program-suffix=-1.9.1 --prefix=/opt/local
make
sudo make install
UPDATE: I just added another script to install directly from the svn repository. This is for those crazy people who like to live on the edge.
#!/bin/sh
if [ -z "$1" ]; then
echo "usage: $0
echo "Author: Matias Pablo Brutti"
echo "Bye
"
exit
fi
echo "This might not compile because it is download straight from"
echo "the svn repository. If it does not work either wait and try"
echo "again later or do your work and check why is not working."
echo "Happy hacking!"
if [ "$1" == install ]; then
echo "Downloading ruby from the svn repo"
svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby
cd ruby
fi
if [ "$1" == update ]; then
echo "Cleaning last install and updating repo"
cd ruby
make clean
svn update
fi
echo "Configuring && installing ..."
autoconf
./configure --program-suffix=-1.9 --prefix=/opt/local
make
sudo make install
Enjoy.
El s?bado fue mi cumple. Esos d?as en que te das cuenta que te estas poniendo cada d?a mas viejo. Pero solo lo festejamos 1 vez por a~no. Bueno, el tema es que me comenc? a preguntar que edad tenia en segundos, minutos, u horas.
As? que como estaba un poco aburrido mientras mi querida novia me hacia una torta
, me puse a hacer este code.
#!/bin/ruby
u = []
born = Time.parse "01/31/1981 00:30 AM"
now = Time.now
life_in_sec = (now - born).to_i
puts "Seconds of life: #{life_in_sec}"
[86400, 3600, 60, 1].inject(life_in_sec) do |life_in_sec, n|
m = life_in_sec / n
u << m if m != 0
life_in_sec % n
end
puts "A little more readable: Days/hours/minutes/seconds"
puts u.map {|t| '%02d' % t }.join(":").sub(/^0/, '')
>> output:
#Seconds of life: 883908432
#A little more readable: Days/hours/minutes/seconds
#10230:10:07:12
Slds.
