Thursday, January 29, 2009

Gears comes to Gmail


Well, what more can I say - Gmail is now powered by Gears. Read about the announcement and details here...




Google started off with reader and now gmail.  I see them enabling all their apps with Gears and this is the next step in making all the desktop apps irrelevant.  And they have all the right tools and pieces in hand to achieve that. The tools - Gears, the client - Chrome (& firefox?), the apps - Gmail, reader, ...

Would I be afraid if I were MSN, Yahoo, Facebook, AOL... or any other web app out there? Yes, certainly I would. And I personally would hate if Google goes ahead and dominates the web. Offline availability is so important for every web app out there. Atleast in the short run, all the web apps should try to enable offline access. Myspace saw the need for offline access to information and did the right thing by enabling their message/mail access offline.

Now I foresee many more web apps enabling offline access via Gears, or otherwise. HTML5 is still long time away before being ubiquitous. And Gears will fill in, till such a thing happens and continue to provide the new features coming in HTML5, right NOW.

Wednesday, January 21, 2009

MoMo Jan 2009

Mobile Monday meet/event for Jan 2009 is being held on 28 January 2009, from 6:30pm onwards at Sasken office. The registration is free but the number is limited, so rush for it.

The schedule is
  1. Talk by Ashish Sinha on "Is Voice the King of VAS?"
  2. Demo of VoicePHP by Yusuf Motiwala, CEO of Tringme.
I am curious and looking forward to the demo of VoicePHP.

All the details including registration can be done here...

Friday, January 09, 2009

set facebook user status

If you are familiar with facebook (or for that matter, any one of the gazillion social networking applications out there), there is a way for a user to set his status - any random string. Just like one can set a custom message on his favorite IM client.

One of my friend was exploring the facebook REST api's and was trying to set the status via the REST api. Now facebook has a peculiar feature where for certain functionality, the service adds additional security and needs additional permissions. Now, setting of the status is one such api that needs additional permission. And my friend was finding it hard to figure out how to get the permission using the REST apis. There are means to get the permission if you develop for/on the facebook platform. I too did take a look at the perl facebook api module but got fed up.

Then I googled and found this link. I used the code and ran the script. I was able to login but could not set the status nor fetch the status. So I spent some time hacking around and looking at the response from the facebook and updated the script. Now the script works, one can set the status and get the current status as well. Remember, this is not using the REST apis or the web service. I guess this is called as data scraping or spoofing? I am not sure. The code/script is not optimized but ...

Anyway, here is the perl code. The script takes the facebook login email, pass and status string as the argument...


#!/usr/bin/perl -w
use strict;
use warnings;
use HTTP::Cookies;
use LWP::UserAgent;

my $email;
my $password;

my $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6'; # whatever...

#print "Please enter FB email for login\n";
$email = $ARGV[0]; #read the login e-mail
#print "Please enter FB password\n";
$password= $ARGV[1]; #read the password

print "Thanks\n";

chomp($email); #remove last line
chomp($password);

my %postLoginData; #necessary post data for login
$postLoginData{'email'}=$email;
$postLoginData{'pass'}=$password;
$postLoginData{'persistent'}=1;
$postLoginData{'login'}='Login';

our $response; #holds the response the HTTP requests
#set the headers, let's make this a Firefox browser!
my @header = ('Referer'=>'http://www.facebook.com', 'User-Agent'=>$user_agent);

our $cookie_jar = HTTP::Cookies->new(file=>'fbkCookies.dat',autosave=>1, ignore_discard=>1);

our $browser = LWP::UserAgent->new; #init browser
$browser->cookie_jar($cookie_jar);

# incase you are behind a proxy
# $browser->proxy(['http', 'https'], 'http://127.0.0.1:9876/');

$browser->get('http://www.facebook.com/login.php',@header);

#here we actually login!
$response = $browser->post('https://login.facebook.com/login.php',\%postLoginData,@header);

#was login successful?
if($response->content =~ /Incorrect Email/) {
print "Login Failed...Quitting..\n";
}
else {
print "..and we are in!\n";
#let's go to the homepage
$response = $browser->get('http://www.facebook.com/home.php',@header);

$response->content =~ /

Wednesday, December 10, 2008

Higher Order Perl available for download

The book "Higher Order Perl" authored by Mark Jason Dominus is available for free download. Go grab it here....

Tuesday, December 02, 2008

sipping with Net::SIP

As I had indicated in my earlier post, Net::SIP module for perl really streamlines a lot of the things for quick testing and automation. Net::SIP provides the SIP framework using which one can develop any of the SIP entity functionalities like Registrar, Proxy, UA, etc.

Net::SIP has a lot more associated modules, that help whip up some specific SIP entities in a couple of hours. Like for eg: Net::SIP::Registrar helps to implement a fully working registrar functionality fairly quickly. There are many such modules to help you build many of these entities.

The following is a sample code that acts as a SIP UA that registers with a registrar and makes a call using the Net::SIP::Simple module (from the module example) complete with SDP and RTP packet handling.

use Net::SIP;

# create new agent
my $ua = Net::SIP::Simple->new(
outgoing_proxy => '192.168.0.10',
registrar => '192.168.0.10',
domain => 'example.com',
from => 'me',
auth => [ 'me','secret' ],
);

# Register agent
$ua->register;

# Invite other party, send anncouncement once connected
$ua->invite( 'you',
init_media => $ua->rtp( 'send_recv', 'announcement.pcmu-8000' ),
asymetric_rtp => 1,
);

# Mainloop
$ua->loop;
Isn't that simple? If one has some custom requirements, then Net::SIP provides low level modules and utilities using which one can implement custom SIP entities and behaviours.  Net::SIP::Packet lets you handle the SIP packets and Net::SIP::Leg which acts as a wrapper around sockets and lets one send and receive data.

happy sipping....


Friday, November 14, 2008

Google's SEO Starter Guide

What does Google intend to do? Put SEO's (Search Engine Optimization) out of job!

Google SEO Starter Guide

Monday, November 10, 2008

SIP and Perl

I have been working with SIP(Session Initiation Protocol) and VoIP in general on and off for many years now. And I have been using perl whenever I could to automate stuff like testing, generate testcases, during performance testing and for recreating scenarios and fixing issues that occur at interops or at remote sites by analyzing the logs.

And uptill now, I had used some very primitive level coding involving string manipulation, sockets and some quick and dirty hard coded stuff in the code to achieve the required functionality asap. I loved this approach because it gave me immense power to simulate any scenario and simulate any proprietary implementations of vendors.

Here is a sample crude perl code I used to use earlier for simulating a SIP UA. Of course on the other end would be a SIP UA we are testing, or some other entity under test. This SIP UA registers with a registrar and waits for an incoming call and establish a call/session. Don't even ask me why this script waits for 2 responses for REGISTER, I don't even remember.


#!/usr/bin/perl -w
use IO::Socket;

#--------------------------------------------------------

$numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments.\n";

#-------------------------------------------------------

my $sock = new IO::Socket::INET (
LocalPort => 8888,
PeerAddr => '10.232.14.112',
PeerPort => '5060',
Proto => 'udp',
);
die "Could not create socket: $!\n" unless $sock;

#-------------------------------------------------------

my $sip_request="";
my $response = "";

# register
$sip_request = "REGISTER sip:10.232.14.112:5060 SIP/2.0\r\nFrom: 1550 ;tag=hrs7fes6\r\n";
$sip_request = $sip_request."To: 1550 \r\nCall-ID: ft36633sdffff7a21111111z7\r\n";
$sip_request = $sip_request."CSeq: 1 REGISTER\r\nContact: 1550 ;q=0.9;expires=3600\r\n";
$sip_request = $sip_request."Via: SIP/2.0/UDP 10.232.15.31:8888;branch=z9hG4bK548s97i77d555458fs\r\n";
$sip_request = $sip_request."Max-Forwards: 70\r\n\r\n";

print "Request to be sent: \n$sip_request\n";

print $sock $sip_request;
#
$sock->recv($sip_request, 5000);
print "Response received: \n$sip_request\n";

$sock->recv($sip_request, 5000);
print "Response received: \n$sip_request\n";

#-------------------------------------------------------

$sip_request = "";
$response = "";


while (TRUE) {

$sock->recv($sip_request, 5000);
print "Response received: $sip_request\n";

@sip_headers = split(/\r\n/, $sip_request);

print "Number of headers in received message: $#sip_headers\n\n";

print "\n\n-------------------------------------------------\n\n";


#-------------------------------------------------------------

#send 100 Trying
$response = "SIP/2.0 100 Trying\r\n";

foreach $header (@sip_headers) {
if (($header =~ "^From") or ($header =~ "^To") or ($header =~ "^Call-ID") or ($header =~ "^CSeq") or ($header =~ "^Via")) {
$response = $response.$header."\r\n";
}
}

$response = $response."\r\n";

print "Response to be sent: $response\n";

print $sock $response;

#-----------------------------------------------------------

#send 180 Ringing
$response = "SIP/2.0 180 Ringing\r\n";

foreach $header (@sip_headers) {
if (($header =~ "^From") or ($header =~ "^To") or
($header =~ "^Call-ID") or ($header =~ "^CSeq") or
($header =~ "^Via")) {

if ($header =~ "^To") {
$header = $header.";tag=rfsdf677566577";
}
$response = $response.$header."\r\n";
}
}

$response = $response."Contact: ; isfocus\r\nContent-Length:0\r\n";
$response = $response."Record-Route: ,,\r\n";
$response = $response."Require: 100rel\r\nRSeq: 1\r\n";
$response = $response."Content-Type: application/sdp\r\n";

$response = $response."\r\n";

print "Response to be sent: $response\n";

print $sock $response;

#---------------------------------------------------------------
# wait for PRACK

$sock->recv($sip_request, 5000);
print "Response received: $sip_request\n";

@sip_headers = split(/\r\n/, $sip_request);

print "Number of headers in received message: $#sip_headers\n\n";

print "\n\n-------------------------------------------------\n\n";

#-----------------------------------------------------------------

#send 200 OK
$response = "SIP/2.0 200 OK\r\n";

foreach $header (@sip_headers) {
if (($header =~ "^From") or ($header =~ "^To") or
($header =~ "^Call-ID") or ($header =~ "^CSeq") or
($header =~ "^Via")
) {
$response = $response.$header."\r\n";
}
}

$response = $response."Contact: ; isfocus\r\nContent-Length:189\r\n";
$response = $response."Content-Type: application/sdp\r\n";

$response = $response."\r\n";

$response = $response."v=0"."\r\n"."o=RV-MCU 2021970 2021970 IN IP4 10.232.15.31"."\r\n"."s=RV MCU Session\r\n"."c=IN IP4 10.232.15.31"."\r\n"."b=CT:64"."\r\n"."t=0 0"."\r\n"."m=audio 6028 RTP/AVP 8"."\r\n"."c=IN IP4 10.232.15.31"."\r\n"."a=rtpmap:8 PCMA/8000"."\r\n"."a=sendrecv"."\r\n";

print "Response to be sent: $response\n";

print $sock $response;

#---------------------------------------------------------------

#Wait for ACK
$sip_request = "";
@sip_headers = "";

$sock->recv($sip_request, 5000);
print "Response received: $sip_request\n";

@sip_headers = split(/\r\n/, $sip_request);

print "Number of headers in received message: $#sip_headers\n\n";

print "\n\n-------------------------------------------------\n\n";

print "CALL SETUP\n";
sleep 100;

#----------------------------------------------------------------

}

close $sock;
Of course, I am bringing this up in this post because I have found Net::SIP module for perl. That reminded me of my earlier days and this dirty code I used to write. I don't know how I didn't discover this module earlier. However, my experiments with Net::SIP will be part of another post.

Saturday, November 08, 2008

ActivePerl to Strawberry Perl

Activeperl from ActiveState has been the predominant flavour of perl used by many over the years. In addition to the core perl, the package release includes some of the mostly used modules and some win32 specific modules which make the life easier for a developer if he is developing anything for Windows. It also has ppm tool which is quite handful for querying and installing modules and packages from activeperl repository.

However, I have found some irritating issues with activeperl especially if one is developing platform-independant code. First one would be missing packages. For eg support for SSL packages - ssleay and HTTPS support for LWP. I understand that it is not activestate's fault as such since Canadian federal government does not permit distributing of cryptographic software. But it is an annoying thing for a developer since HTTPS is such an important requirement if one is working on any web related programs. Of course, there are work arounds like adding another repository that has them. I have encountered other missing modules like - Net::SIP.

Next in line would be manual compilation on Windows. One can download the source packages from CPAN and try to compile. If the module is a perl only module, then you are in safe land. Compilation and installation will go through. Even for that one needs to have the 'nmake' utility. This is distributed as part of Visual Studio (VS) application by Microsoft. In case one doesn't have VS installed, then one can google for 'nmake' and download it for free else download the express edition of the VS which is free. Probably some tests will fail probably because author made use of *nix specific stuff in the test code, but that's still better than not having anything at all. However if the module has some C code, then you are on your own. It will consume too much effort to proceed.

One of my other grudges is the lack of cpan connectivity. CPAN is one of the reasons why perl is so popular.

Recently I came across strawberryperl. This flavour of win32 perl comes with mingw compiler (gcc for Windows) and other unix utilities for Windows. And has CPAN tool chain with auto-upgrade support. So incase you need a module that's missing, just drop into the cpan shell that's part of the strawberry perl release and install or update the desired module. Incase the module has C source code and needs to be built, then no problem. The mingw compiler and other unix utilities will do the job for you.

Have just started playing around with strawberry perl. If still curious about win32 perl version, then head over to this wiki to quench your thirst.

Update: In the comments, Jan Dubois mentions that most of the issues I have mentioned here have been fixed in the last week's build of the activeperl releases. Thanks Jan for updating. However, I have not tried the latest activeperl releases yet.

Thursday, November 06, 2008

Linus family blog

This post is to just communicate to all the penguin lovers about the personal family blog of one of their leaders.

Linus Torvalds has a personal family blog over here, where he talks of mostly non-linux stuff.

Friday, October 31, 2008

ubuntu 8.10 is available...


ubuntu 8.10 for desktop as well as server is available. Personally I would not be upgrading to the new desktop version for now since the new features in this release are not exciting or useful for me. 

Some of the key features are
  • 3G packet connectivity 
  • Guest sessions
  • Gnome 2.24 desktop
Details release notes is here....

Saturday, October 25, 2008

sandbox upgrade to hardy heron

Long time, no post!

The long weekend has given me some time to again tinker around with sandbox - my old desktop at home. It had been pretty much been sitting idle for sometime now.

Well, I have just upgraded my ubuntu distribution to 8.04 (Hardy Heron). And 8.10 is just couple of days away :). There was no urge as such to upgrade. However, I was tinkering with some open source projects (to keep myself grounded to coding :)) and I just was not able to compile because they insisted on glibc 2.16 or higher. And I was using the latest available glibc (2.14?) for the older ubuntu - 7.10.

Anyways, upgrade was a breeze over broadband except for the fact that one needs to have enough patience for the packages to download (took almost 4 hours for me). Also upgrade was an issue for older boxes like mine which does not have sufficient disk space.

As for development, I tried Ajunta IDE, which is an IDE for C/C++. It has some minor bugs (annoying for me) with customising the look n feel (fonts, colour, blah) and sudden crashes. I have not however created any new projects with it though, just used it as a means to browse the code. Feel the good old terminal, vim and gdb are way better for a person like me. Probably will take some time to get a hold on this IDE... However I dont like bloated IDEs like eclipse. Let me know if there are other better lean and mean IDEs out there...

Friday, August 01, 2008

Implications of symbian going open source

This blog post pretty much sums up the implications for mobile industry of Nokia buying out rest of the stake in symbian and making it royalty free and open source.

Nokia had acquired Trolltech sometime back. I was assuming they would port Trolltech QT interface to their symbian platforms (S60, S40...) in addition to their tablet linux platform to provide similar look and feel interface across all their platforms and devies. Now that Symbian Foundation and Nokia are planning to merge symbian core OS and S60 UI platform as an all-in-one platform, there is no more differentiation across the vendors based on symbian UI platforms. So that throws up an interesting question - what are Nokia's plans with the Trolltech QT acquisition?

Wednesday, July 30, 2008

Building Data Services with XMPP PubSub

Many of the bloggers have been critical of twitter's instability and of it going down frequently against heavy traffic. This has been attributed by many to the use of RoR framework, rails architecture, ruby speed, database issues, twitter api interface, and so on. One thing to note here is that all the twitter clients keep flooding the twitter server every x seconds, traditionally known as polling even though there might not be update for the twitter stream.

At OSCON 2008, Evan Henshaw-Plath and Kellan Elliott-McCrea gave an interesting presentation on using XMPP based publish-subscribe model for online data services. The title of the presentation was "Beyond REST? Building data services with XMPP PubSub".

On monday friendfeed polled flickr nearly 3 million times for 45000 users, only 6K of whom were logged in. Architectural mismatch.

The above statement is from their presentation and explains how much of resources (cpu cycles, bandwidth, etc) are being wasted because of using polling techniques. They propose that XMPP based publish-subscribe model will greatly reduce the unnecessary transactions and overhead. Twitter is already providing XMPP streams for some of the other web services.

However not many services support publish-subscribe model. RSS based polling is very prevalent as of now. Time will tell how many of the current and upcoming services will support XMPP streams. But RSS is not going to fade away anytime soon.

Wednesday, July 02, 2008

Keep off the grass by Karan Bajaj

Karan Bajaj is the newest entrant to the Indian author scene. His first book "Keep off the Grass" (KOTG) just released last month and has been fairly well received by the audience.

KOTG is yet another of those books whose characters and strory revolves around India's top educational institutions and in this case, IIMB. I am not sure if Karan had any inspiration for penning this book from Chatan Bhagat's first book - "Five Point Someone" which dealt with IIT life.

The story revolves around Samrat Ratan, US citizen born to immigrant Indians, Yale graduate and an investment banker in a top Manhattan financial institution who leaves everything back and travels to India and enrolls in IIMB to search for his roots. The book unravels his time at IIMB and his unraveling of India and himself. One peculiar thing about the story is the amount of substances/drugs used and consumed by the protagonists in the story which makes me wonder if IIM's indeed have such a facility or if it is just fiction.

The book is nice to read and not heavy on mind, though philosophical at times. I got the book one night and finished it by the next afternoon. I would recommend this one over Chetan's 3rd book - "3 Mistakes of My Life". The book also was a semi-finalist at Amazon Breakthrough Novel Award.

Saturday, June 28, 2008

Chetan Bhagat's 3rd book

I managed to read the third book by Chetan Bhagat - "the 3 mistakes of my life" a while back.

As it is with Chetan's earlier 2 books, this is again a story based on Indian youth generation. And unlike the earlier books that centred around IIT life and call centre, this one is based on the entrepreneurship and the struggle the main protagonists go through with cricket and religion mixed in.

This book too is captivating and urges one to pick up the book and keep reading ahead. However, after reading through I felt that somehow it lacks the punch that I have come to expect from Chetan. Of course, cricket and religion are an important aspect of an Indian youth. I am unable to point out why it is so. That said, this book is way above the other story books out there for a normal irregular reader like me.

However, one thing that caught my interest was in the "Acknowledgements" page of the book. Wherein Chetan mentions that the goal of the publisher's - Rupa and Co was "to make India read". A worthy intention indeed....

Update: In pursuit of their goal, the publishers have done one right thing that I have noticed - the price of all the 3 books by CB have been Rs.95/- only. The price matters a lot for the readers in India.

Bangalore directions and live traffic info

For many of us who have used the google maps, yahoo maps and mapquest for driving directions while abroad and wondered when we could get the same utility for Bangalore, we have some options. In fact they have been around for sometime, but I hadn't noticed them.
  1. BTIS (Bangalore Traffic Information System) - Provides directions and live traffic conditions
  2. Yahoo! India maps