Friday, 16 September 2011

Scope of block variables in Ruby 1.8 and 1.9


There is a difference in the scope of the variables in blocks w.e.f ruby 1.8 and 1.9  I have pasted en example to high light the change. It created trouble when I moved my application from 1.8 to 1.9


a = 1
b = 2
r = 0
n =0

(0..10).each do |n|
  a = n
  r = r  + n
end

puts "a = #{a} ; b = #{b} ; r = #{r} ; n = #{n}"


ruby 1.8.7
  a = 10 ; b = 2 ; r = 55 ; n = 10

ruby 1.9.2
  a = 10 ; b = 2 ; r = 55 ; n = 0





Wednesday, 7 September 2011

Postfix on Ubuntu, send mail using telnet.



Post fix is said to be better than send mail as I read from many sources.

"sudo aptitude install postfix" Installed postfix for me.  Give various details when prompted for.
"/etc/postfix/main.cf" Has all the config details.

#sudo postfix start -> starts post fix if not already running.

#telnet localhost 25


ehlo localhost
mail from: user@localhost
rcpt to: someone@localhost
data
Subject: my subject

Hi,
 How are you?
regards,
Admin
. (Type the .[dot] in a new Line and press Enter )
quit

#mailq  will show you the mails to be delivered.