Archive for December, 2007
10 Secs Bodyguard Trick
Really nice trick for those of us that can’t tie a tie:
No commentsAmigoSecreto.rb
Using part of our research time
, Victor and I developed a very small script to play the “Amigo Secreto” (Secret Friend) game here at the PLEIAD Lab. Following is the Ruby code (we used this snippet for the email-sending function).
require 'net/smtp' def send_email(from, from_alias, to, to_alias, subject, message) msg = <<end_OF_MESSAGE From: #{from_alias} <#{from}> To: #{to_alias} <#{to}> Subject: #{subject} #{message} END_OF_MESSAGE Net::SMTP.start('dcc.uchile.cl') do |smtp| smtp.send_message(msg, from, to) end end def randomize(hash) k = hash.keys hash.keys.each_index{ |idx| pos = idx + (rand() * (k.length - idx - 1)).ceil; tmp = k[idx] k[idx] = k[pos] k[pos] = tmp } rhash = {} hash.keys.each_index{ |idx| rhash[k[idx]] = hash[hash.keys[idx]]; } rhash end users = { "vramiro@dcc.NOSPAM.uchile.cl" => "Victor", "rtoledo@dcc.NOSPAM.uchile.cl" => "Rodolfo", "etanter@dcc.NOSPAM.uchile.cl" => "Eric", "gpothier@dcc.NOSPAM.uchile.cl" => "Guillaume", "pleger@dcc.NOSPAM.uchile.cl" => "Paul", "cvairett@dcc.NOSPAM.uchile.cl" => "Carla", "jfabry@dcc.NOSPAM.uchile.cl" => "Johan"} randomize(users).each_pair{ |mail,name| msg = <<end_OF_MESSAGE Tu super amig@ secret@ es: #{name} END_OF_MESSAGE send_email("pleiad@dcc.uchile.cl","PLEIAD Lab", mail,"", "[PLEIAD] Amigo Secreto", msg) }
Moved!
I have moved my homepage from Virtuabyte to DreamHost! I’m very happy with what I have seen already!
If you want to start a new DreamHost account, use DREAMHOSTPCODE as promo code and you will get a $50 discount (the maximum possible).
I will also start posting in English to practice it