Monday, March 26, 2012

Do-while loop in Ruby

As you know, I'm trying out Ruby. While solving one of the exercise problems I felt the need for a do-while loop. Unfortunately ruby has no documented do-while loop. Thankfully, somebody has already asked this same question in stackoverflow : Is there a do-while loop in ruby?

Here is a demonstration of a do-while code in ruby:

Remember that using undocumented features is always ill-advised !!

Saturday, March 24, 2012

I'm trying out Ruby

I have always been interested in programming languages. After coding in a plethora of mainstream procedural languages C, C++ and Java, last year I tried my hands on Python. Apart from being an enjoyable experience, learning Python has paid off quite well while building prototypes in my work. This prompted me to try learning some other languages.

While searching for a cool language to try out, I came across the book, "Seven Languages in Seven Weeks" which promises to go beyond the simple tutorials and "introduction to" and introduce some non-trivial aspects of the language. I have started from page 1 and am exploring Ruby. So far the author has kept up his promise.

Ruby has got very friendly constructs and syntactic sugars like:
  • the keyword "until", which is simply a negation of the popular "while"
  • instead of simple "for" loops, constructs like "10.times"
which gives a warm and friendly feeling to the language. Besides the book mentioned above I am using "Programming Ruby 1.9" from the same publishers for a reference.

Friday, March 02, 2012

Demystifying bulk SMS sender name

With the high penetration of mobile phones, companies have started sending out automated sms. I have always wondered about the cryptic sender names. Careful observations about the sender name reveals:
  • all letters are in capitals
  • name format is **-******
    • the first two letters seem random
    • followed by an hyphen
    • followed by a six letter
  • last six letters seem to identify the sender name
    • for example presently, "SBIINB" represents SBI bank
  • sometimes the same sender can send some sms with different combinations of first two letters
    • SBI sends sms as "BX-SBIINB", "TD-SBIINB" etc.
Some researching in internet points out that my observations about the last six letters are correct. The first two letters before the hyphen represents service provider and the region from which it is sent. For the examples above:
  • "BX" = BSNL from Karnataka
  • "TD" = Tata from Delhi
View the official list of bulk sms codes in the NDNC website.