Archive for May, 2008
A teaser from ApnaBill.com
May 30th, 2008
The current week is just halfway through, but it has already been one of the most eventful week for ApnaBill.com - with some definite advances towards the release. We’ll be launching the live pilot mode release in just days time.
More good news - we’ve expanded our network coverage from a handful of operators/cities to a pan India coverage.

We’ll be supporting 16 different prepaid vendors across 14 different geographical locations - I must say, that is a mighty list!
And to give you a small hint with what’s in the store, I present to you, bits and pieces from ApnaBill.com UI - all this and much more is just waiting to go live!

All the hard work that has gone into cross browser support…

A self-explanatory teaser on the front page

Another teaser

The prepaid coupon types we’ll be selling…
![]()
Secure transactions - with subtle hints on the UI

And of course, the ubiquitous help!
Please do signup for our Beta Release if you have not done so. The Beta Signup is still open.
Posted in ApnaBill, Ruby, Startups, Web 2.0 | Comments (2)
Giving wings to RAKA - graphing ability!
May 28th, 2008
Brightest ideas hit you when you least expect them. I was trying so hard all evening to put RAKA’s output into a format Graphviz could understand - but had no luck. I tried arrays, hashes, stack and what not - but nothing seemed right (or I wasn’t doing it right
) - and at 4am - right at the moment when I was packing up for the night - it hit me! - Just like a big bright Bulb!
Why not XML? Graphviz can very well render an XML (Some examples from ruby-graphviz gem) - and I was already able to output my tree in much similar format - whoa! 5 more minutes and I had this…

Read the graph - left to right, top to bottom. If X is displayed before Y in the graph, X is coded before Y.
And this is the code it corresponds to…
-
-
require "pp"
-
-
module Junk
-
-
class Maku
-
-
def say_hello(str)
-
puts "hello #{str}"
-
a = 1+1
-
if a == 2
-
if a == 1
-
puts "Yahoo"
-
if a == 10
-
puts "Microsoft"
-
else
-
puts "Google"
-
end
-
end
-
pp a
-
else
-
puts "bye"
-
end
-
puts ""
-
puts ""
-
end
-
end
-
-
end
Here is a side-by-side comparison of the output
The graph seems more like in vertical direction - however a more horizontal direction would look much better - what say?
Oh yes, I have a new expansion for RAKA - “A Ruby Klass Analyzer” ![]()
Posted in RAKA, Ruby | Comments (2)
Static call graphs for Ruby code
May 27th, 2008
Ever since my bug list for ApnaBill.com started to go down, I was worried that what am I going to do in all the free time which will suddenly be created. So much so, I was even creating unnecessary tasks and them scratching them out upon realizing that they are just not needed - sure shot symptoms of working too lately!
While working on ApnaBill, I felt a huge urge to document my code - specially the libraries I wrote and some of the complex controllers. Surely enough the code is very well documented - infact, at times makes pun and even tells stories - but I was always missing a call graph generation tool, which when given my Rails project, can graph out all the calls each of the actions make. I am not talking about profile time graphs - but something pretty static, which just looks at your ruby code and draws a graph.
…And just why is it needed? Documentation - ofcourse! A colored and connected graph, which can take you directly to the source code is alot easier to digest than just the code - specially for those who have not written that piece of code. This can be real useful in many scenarios.
Ok, so I started my search two days ago, on Saturday night - and for all night, I was crawling web pages like a googlebot - trying to find the relevant pieces of information. I did came across some fantastic projects like RailRoad, RCov and ruby-prof - but there was nothing that could satisfy my need. I even tried Doxygen (which is still to support Ruby), rdoc and almost all the other doc tools mentioned at “Other tools” seciton on Doxygen’s website.
Continuing my {re}search, I came across ParseTree. Its a C extension which churns out Sexp representation of Ruby code. You can parse ruby code in classes or methods or strings format. The library (apart from other stuff) - basically gives you a callback like access to various parts of the Ruby language. So “process_defn” would be invoked when any “def my_method()” is encountered.
There isn’t much on the internet about how to use ParseTree but the code samples and RDoc included in the gem are a good start. And then there’s the code installed by the gem - which you can always read at leisure. Another document worth checking out is Ryan’s Dependency Analyzer - where he does a bit of explaining as well.
Okay, back to the problem in hand - How can I draw a call graph of my code without actually executing it. I don’t want to execute it because it cannot guarantee 100% path coverage. Further, my objective is to document the code rather than profile it.
After my initial attempts, I was finally able to create a hierarchical structure of the code (which is utterly basic as of now).
-
-
# Target code which is to be graphed
-
# Save as "mini.rb" in your current directory
-
module Junk
-
-
class Maku
-
-
def say_hello(str)
-
puts "hello #{str}"
-
a = 1+1
-
if a == 2
-
if a == 1
-
puts "Yahoo"
-
if a == 10
-
puts "Microsoft"
-
else
-
puts "Google"
-
end
-
end
-
pp a
-
else
-
puts "bye"
-
end
-
end
-
end
-
-
end
Introducing RAKA
-
-
#!/usr/bin/env ruby
-
# RAKA - A Ruby Kode Analyzer
-
# Save in same directory as mini.rb
-
-
require "pp"
-
require ‘rubygems’
-
require ‘parse_tree’
-
require ’sexp_processor’
-
-
class Raka < SexpProcessor
-
-
attr_accessor :tabber
-
-
def initialize
-
super
-
@tabber = 0
-
self.strict = false
-
self.auto_shift_type = true
-
end
-
-
# Just a wrapper for s method.
-
# Usefull in decrementing tabbing structure once processing is done.
-
def s(*args)
-
result = super(*args)
-
@tabber -= 1
-
return result
-
end
-
-
def process_fcall(exp)
-
@tabber += 1
-
name = exp.shift
-
display "CALL #{name}"
-
return s(:fcall, exp.shift)
-
end
-
-
def process_if(exp)
-
@tabber += 1
-
display "IF"
-
test = exp.shift
-
process(test)
-
left = exp.shift
-
process(left)
-
display "ELSE"
-
right = exp.shift
-
process(right)
-
display "END"
-
return s(:if, test, left, right)
-
end
-
-
def process_defn(exp)
-
@tabber += 1
-
name = exp.shift
-
display "DEF #{name}"
-
args = process exp.shift
-
body = process exp.shift
-
display "END"
-
return s(:defn, name, args, body)
-
end
-
-
private
-
-
def display(str)
-
@tabber.times{ print "\t" }
-
puts "#{str}"
-
end
-
-
end
-
-
require "mini"
-
puts "============Junk::Maku============"
-
Raka.new.process(*ParseTree.new.parse_tree(Junk::Maku))
The result
Woha! As you can see, I am able to relate the code structure with the calls and if statements. If I can output this into a format which Graphviz can understand, we’ll have exactly what we want!
Too bad, its almost 6am - and I have to catch up on some sleep
I’ll have to stop here - more on the project as things with RAKA proceed.
Comments and suggestions are more than welcome
Posted in It calls for a blog..., Ruby | Comments (2)
Updates - Life and ApnaBill.com
May 24th, 2008
Its been long since I last blogged - and I was kinda missing the blogging scene.
Days and nights are as usual - super hectic. At 4:45am, with “Summer of 69” running at full volume - work on ApnaBill.com is going on in full swing. Last week, we completed integrating our Payment Gateway and Coupons Manager modules into the developer codebase. This was the last blocker bug holding us back from a release. Effort now is targetted on consolidation.
After spending endless days and nights (and full weekends - upto 20 hours each weekend), seeing everything coming and working together as one cohesive and functional unit - is like watching a kid grow and graduate! Bits and pieces of code which were written as long back as 6 months ago are suddenly coming alive all together. Assumptions which were made back then, still hold good - I guess, a bit of future planning always helps.
But as wise men say - “The end is just the beginning!” - there’s still a ton of work left before we can go Live - though we are very seriously thinking of announcing the dates now. The project is expected to go into pilot testing mode anytime now.
Just before ending - a teaser as usual

Mobile operators we would be supporting across India.
& now …back to Summer of 69 and styling ApnaBill.com
PS: Saturday morning, The Chronilcles of Narnia is up at 10:40am at Gold Adlabs - and we have 4 tickets booked for just INR 200
Posted in ApnaBill, Startups | Comments (0)
Making web a prettier place!
May 10th, 2008

As we speak, CSS goodieness is oozing out of ApnaBill.com developer codebase. I just wish if I could paste some screenshots of our work here…
Anyways - that time would come! ![]()
Posted in ApnaBill, Web 2.0 | Comments (0)

