Skip to main content

Posts

Showing posts from 2009

Miss You.. Rani..

3 days now, and I still cannot believe this year can be so bad for us. We lost my beloved father just this May. Just were we recovering from the mammoth loss. And suddenly, we find the earth under our feet take a free fall, leaving us all no where. I just reached india, amidst chaos, shock and immense loss.

It was around 8:30 on the Wednesday night, I was picking up some holiday shopping. And talking with Jyo about the long weekend. The call came from my brother (Raghu), about the dreadful car accident my brother (Anand), aunt, and little sister (Rani), two of her friends. Rani and her friends succumbed. While Anand and aunt were barely able to survive.

Rani is not a typical girl. She was the apple of the eye for every member of the (extended) family. Even her friends. She was studying MBBS II year. She was one girl among 8 boys. She was extremely brilliant, spoke her mind always. She was fun loving and honest at the same time. Most of all, She was the one that put every small thing i…

Spring Framework 3.0 GA released!

SpringSource announced its GA release today.

My personal reasons to "go for it" - REST and Huge improvements in Annotation support. It will be interesting to see how this release is accepted by the community. 2.5.6 seems just yesterday. People (like me) with roots (and lot of existing applications (with issues)) in Spring 2 are just getting their feet wet with migration to 2.5.6 and the magical world of annotation based configuration. Now, I have to calculate ROI on migrating my still-in-development applications (on 2.5.6) to 3.0.

ah. I am so in a jinx.

GUI, Usability, Innovation.

This is a continum on my previous two posts; With out deep reference to who invented the mouse (Xerox), the touch screen (PLATO) and the multi touch (not Apple) - Its definitely pigeon holing to name M$ or sJobs for it. Look at 10/GUI's linux multitouch desktop concept.

10/GUI from C. Miller on Vimeo.
Science as perceived commonly doesn't belong to a company. Innovation is not limited by a beginning or money. But the sheer market for the FIRST has so much to play against innovation. AT&T and iPhone have limited the market so much for all the possibilities that could have happenned. iPhone's Younger brother iTouch still craves all the deserved attention after 3 generations of it.

Its not Apple to blame all of it. The gadget market here is US is so egotistically challenged, they cant see 4G, Video mobile communication witnessed heavily in Far-East. I should mention, SMS (almost free) in India has revolutionised a generation. Reliance CDMA brought a country to a different…

Introduction to Cloud for Enterprise

I am back from a big vacation.

I found this decent presentation for Cloud Computing from sun. This gives a very basic but good explanation about how cloud benefits Enterprise. The presentation can also be downloaded as a mp4 here




src: https://slx.sun.com/node/1179275657

Error creating bean with name 'tilesConfigurer'

While building a skeleton web app, using Spring and Tiles, I encountered this strange error. I am trying to configure Spring 2.5.6 and Tiles 2.2.1

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined i n ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.UnsupportedOperationException: Class org.apache.tiles.web.util.ServletContextAdapter not recognized a TilesApplicationContext at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.do…

My installation plan for Linux

This is note to self. All the applications I need to install after a clean install of a linux. I am trying to get to a more productive way of doing this. But atleast this will serve as a todo list

javasdk
tomcat6
grails
adobe air
google-gae-java
flickr uploader
Eclipse
web
git
andriodsvngrails
FireFox
addonscollection
NO ppa

conky - conky
gnome-do gnome-do-plugins gnome-do-docklets
ccsm - compizconfig-settings-manager
Keepass - keepassx
PPA
google-chrome
Dropbox - nautilus-dropbox
shutter
opera
sudo apt-get install conky compizconfig-settings-manager keepassx gnome-do gnome-do-plugins gnome-do-docklets subversion git-core

sudo apt-get install google-chrome nautilus-dropbox shutter opera

Update: For a Server
sudo apt-get install gadmin-tools

Speed up Eclipse from a slow workspace

After working on a few Java/JEE projects, your workspace really gets to become fat. I mean, it gets very very slow. This is because you opened and closed a lot of projects with a loooot of resources in it.

Also because every time you press that Ctrl+Shift+R, or Ctrl+Shift+O, or Ctrl+T in java or run some free text search, You are loading up eclipse's cache of index. Also JDT slowly keeps a track of it, for Type Hierarchies, Implementations.

The easiest way is to open a workspace for every unrelated project. Keep it small. But sometimes, it is not possible. Dependencies. Ease to work with one monolithic workspace (opening and closing projects - yea that's me). For these cases, You could just clean up the .metadata\.plugins\org.eclipse.jdt.core folder in your workspace.

If you are feeling even lucky, go ahead, clean up .metadata\.plugins\org.eclipse.core.resources\.history... a. a. aa. Wait, That folder, contains all that local history of files you have changed - LOCALLY (NOT …

re: Map for that.. DriodDoes

I just posted a tease in last afternoon and late in evening SNF game ads has this..





Great.. Now Verizon (and Android - Droid V's first gPhone?) are getting on an offensive.. Seriously.. Simmer this again "Everything iDont" (classic slick Black text on pure white with a drop shadow, Cheesy music running in the background "Its magic.. " : See where it is going?). Snap, fuses out to a powerful Transformers like backdrop with "DROIDDOES". Yes It does. And this is going into OT! Deep into Festive season.. Am I going to get one? Fingers crossed :)

There is a map for that :P

I am an ATT customer for 5 yrs. but I haven't yet gotten myself an iPhone. All my iPhone friends just cant dig it enough. They keep trying to convince me, in vain. But I love Google Phone and the android philosophy. What is great is they teamed up with T-Mobile; which almost does not have any issue with limiting the capability of that phone (including VOIP apps), unlike AT&T.

On the other hand, The Apple and AT&T combine is all over the news with FCC notices and replies. Some of hubdub is getting clearer. Off late AT&T is also considering opening up the (read limited) iPhone plan. I dont want to flare another hate comment thread here, but, frankly for all the restrictions iPhone and AT&T impose, I feel like being treated as a 3rd Grader. "You can do this, but you cant do that. There.. Stop there".

Verizon is coming up with a lot of Android phones this holiday season. Verizon came up with this aptly witty video for poking fun at AT&T and iPhone ads. T…

Cheating Credit Card Points

The picture is worth 10000 points, yours for free :P

(Source: mint.com)

National Boss Day!

I want to take this day as an opportunity to thank my boss, Stafford Martin, for everything he has done. My career has seen pretty challenging times in the past 9 months. And Stafford's total cooperation, in all that he could do, is simply worth a very good mention.

Thank you Stafford.

okay.. I am getting back to work now :)
photo:www.altiusdirectory.com

Only dumb enough..

Cheapest USB wireless adapter For Ubuntu

I found this Trendnet 54Mbps 802.11bg Wireless USB 2.0 Adapter. Trying to make my desktop wirefree, I got this. I was doubtful, but works flawlessly in ubuntu. You just plug and play. Supports WPA, WPA-PSK.

Microcenter is carrying a special on this one until Nov 1. You can get it for $7 (+tax).

Error handling and Production

When you are developing a customer front web application, you should take every measure to hide technical details from the user. This is especially true for JEE applications. Not only because the user is pissed off looking at a huge stack trace but also it reveals a lot. Look at the following figure


This famous shopping site has been developed to show stack trace on the web page. The developer cleverly hid the trace when the page loads up. But leaves a link that uses DHTML to show the hidden div. That kinda defeats the whole purpose. If the user sees this link, he is less likely NOT to click it.

If you really want to have a handle on this. Print out a unique token (a timestamp, md5 hash or something - get creative here), and correspondingly log it in your appserver along with stack trace. Have the user (customer or your pain-in-the-neck-QA guy) email you that token. Now you can grep that log for it.

Now, you know, I have less confidence in that site this day forward.

Free Wheelin' Annapolis' Free Bike ride

Jyothsna and I love biking. Yesterday we *surprise* visited Annapolis. It was sudden, so, I dint know where to start. So we stopped at the visitor centre. Found out US Navy Academy was a place worth going to. And there was a college football game that had just begun. We had a more naturalistic view on spending the evening. So we started walking to the Market space, to the dock.

At the end of the dock, We were surprised to find Free Wheelin'. They rent out bikes for free. Really. Its not a 16 speed mountain bike of your childhood dreams but, a simple one speed cruiser enough to have fun. All they needed was our Photo Ids and a Credit Card. (They make a copy of these and shred it when we return). They even gave us a Annapolis Transit pass each, in case we had a flat tire or just were to far to bike back.

I did a similar thing in SFO two years back. A friend and I rented a couple of bikes and biked the Golden Gate. But that wasn't free. We rented from Bikeshare.com. They charge…

DONT - Sudo without password

Reading this post, I feel the urge to burst out. This kind of tweaking is not really *adminy* . A true Admin would rather kill the terminal he sudo-ed in, to be even sure.

Enabling your user to become a sudo-er is a privilege. Like in the movie, Spider-man - Great power comes with great responsibility. The extra prompt for password might be a little annoying for frequenters. But completely overriding it is appalling at best, if not awful abuse of the said privilege.

For all the interns who joined as admins, a friendly advice - security defaults have a place in unix. They are set after a lot of research in usage (especially by admins before you). So leave them alone, as much as you can. Security is not for ease of use. The harder a password the better, so read that post with admonition.

For the new *nix users - If you just want to do this, Dont bother installing *nix. Go with an easy mac or better yet, stick with Windoze ME (I am rude, am I not?).

Well that feels happy now. I had a …

Is Google Voice down?

I LIVE google voice. I dont know if it is down, but I got this.

Time : Saturday, September 05 2009 11:08 AM EST



Calling the Phone # seems to work fine.

javascript maxlength for textarea with \r\n breaks in java (esp Firefox)

Textareas allow new lines to enter. These are represented by \n (1) or \r\n (2) characters. But when you save to DB you have a limit to certain length of chars. There is no maxlength attribute in HTML that will stop you from entering data. This is generally acomplished by Javascript. You do a onkeyup hook and stop event or trim after textarea.value.length > maxlength. There are many other solutions out there.. But..

Here is the problem that most of those solutions overlook, How do you deal with the count on \n and \r\n representations. Lets first see how it matters. If the text entered has new lines, the length is calculated differently in Firefox and IE. When you enter a Text like
01234 567890You expect the textarea.value.length to be 11. (10 chars + new line).On the backend, however, java would recieve it as 12 chars (10 chars + \r\n) (this is irrespective of FF or IE). So you are effectively saving 12 chars to DB.

Worse yet, IE seems to figure textarea.value.length as 12 (10 cha…

iBatis SQL with dynamic like operator

In iBatis, a parameter is escaped, autoquoted and replaced automatically. So a #stringParam# will be auto autoquoted and then replaced. Its also escaped, meaning symbols like ' and % are escaped. This causes a problem when you have to do wildcard searches. With a like operator.

Say, You have to look up employees by first name. The SQL would look like
select * from emp where first_name = 'sarath'
and the iBatis Query would be simply
<select id="getEmpByFName"> select * from emp where first_name = #value# </select>
On the same lines, A wildcard search of firstname would be (in SQL)
select * from emp where first_name like '%sar%'
But, if you just make an iBatis select like:
<select id="getEmpByFName"> select * from emp where first_name like #value# </select>and make it concatinate with "%" before passing it to queryForList(), You will see nothing in results. This is because iBatis will escape % too.

Some googling go…

Ubuntu Broken Upgrade, Lost GUI, /dev/null: Permission denied

I am toying with Karmic's alpha releases. So, in comes a new partial upgrade rolled out and I chose to get it. At the end of the upgrade, I had a rare - stuck linux - situation. So I hard rebooted; Only to find that the system now restarts to a GDM that is broken. It gets to a blank screen with a *loading* mouse icon. I was contemplating a complete redo(download the daily build for karmic and install it).

However, I thought its worth troubleshooting. So on that blank GDM screen, I pressed Ctrl+Alt+F2 to open a tty. When I logged in, I got a lot of
/dev/null: Permission deniedApparently, My upgrade dint finish well. First thing that came to my mind is to reconfigure the whole setup.sudo dpkg --configure -aBut I was getting the same errors /dev/null: Permission denied.

Pretty much everything I did got me to the same error. I rebooted to my Jaunty install. A quick search showed me how I could install this all important /dev/null.

All you have to do was to remove and recreate it.
su…

Sleepless with Windows updates

I dont (DONT) run windows. I have Jaunty installed on my wife's new Dell 1545. My old desktop, which I rarely use has windows XP. On the 1545, I installed a vista guest operating system on virtual box. (I am still loyal to linux, I need windoooze to access vpn at one consulting op). So I am there.

But last night was awefule' at its best. I am not sure if I got on the wagon late, but the vista took a whooping 4 hours updating a lot of stuff. This included IE8 update, SP2 update (and all of the regular crap), restarting after each one of them. Involving a user input too, so I cant just sleep. After the whole thing I got a 8GB *bulge* on the partition it was installed. To put that in a perspective - A clean vista install takes 6.4 - 7GB and installs in 45 mins(approx). All the while, I dont know when and what it is downloading, installing, or phasing (what the heck is stage 1 of 3, anyway - after it says *Installed updates, restart now*).

LOOP THIS FOR 4 HRS :D







For regular windo…

AARP and HeathCare reform

disclaimer: I consult (Enterprise Applications - Software) at AARP. Although, the views expressed here are solely mine and do not represent AARP.

I am following the whole health care *issue* moving fluidly from a thought, to a presidential campaign material, to a perceived *can-wait*, to a must-do now, to a political opportunity, and now to a furiously moving going-hot town halls and debates. I can't tell if this effects me much. I don't know completely if the reform is needed. But sure I do realize there is more than just money and politics involved. And People, Mostly, are driven by motives and myths than reality. Here is AARP's stand, clip from O' Reilly factor.



Like DividedWeFail.org, AARP's new commitment to this reform is expressed in a new site. HealthActionNow.org. It tries to address some clarity on myths that are going around.

Side note: Creative or what?

Write iBatis dynamic query that returns results only when atleast one parameter is sent

iBatis allows building dynamic query conditionally based on properties sent to the named SQL. Suppose We have a Person implementation where the search page allows search by id or by email id (assuming both are unique). We could write two queries
<select id="getPersonById" resultClass="Person" > select * from PERSON where ID = #value# </select> <select id="getPersonByManagerId" resultClass="Person" > select * from PERSON where EMAIL_ID = #value# </select>OR we could make a dynamic Query like the following
<select id="getPerson" resultClass="Person" parameterClass="java.util.map"> select * from PERSON <dynamic prepend="where" > <isNotNull parameter="id"> ID = #id# </isNotNull> <isNotNull parameter="managerId"> EMAIL_ID = #emailId# </isNotNull> </dynamic> </select>However there is one pitfall. If the parameter does…

Hmm

I am considering I should come back to blogging. Its been a while. Lot of things happened in my life. I lost my beloved father to cancer. I wish he were longer with me. But atleast he got to see my marriage. Yes. I got married. To the love of my life. Well I dropped everything for these two people, I care the most about.

Ok. Not completely. In this period, I started learning grails and groovy. Started loving App Engine for java. I upgraded my lenovo to Jaunty. I lost track of blogosphere. I bought a Dell 1545 for my wife. Forcibly turned her to a Ubuntu fan :). Started working on iBatis again :( Moved to Rockville MD. Totally ignored Hollywood (have to catch up on a lot of movies). And much more..

Coming back, let me start with a @#$@#$ on What is going on with all these news aggregation sites. Of the past, Sites have stopped creating content themselves, making a living just out of aggregation. But this is getting worse. They are linking among themselves before going onto the orginal.…

Obituary to an Extrordinary Man

My father fought a valiant battle with Cancer. He passed away in early hours IST today (May 15, 2009). He was 51, 13 days shy of being 52. He sustained Neuro Endocrine Carcinoma of Rectum (small cell type) - A rare type of protocol-less and extremely aggressive Cancer. However, Doctors at Yashodha Cancer Institute, Hyderabad, tried their best to palliate its aggression.

He did an amazing job undergoing a very excruciating Cancer treatment. He actually was asymptomatic for a couple of months in between. But the Cancer bit him back. Second time around, He could do only so much in response to the therapy. Yet he did well till the end. Thanks to the expert advice from the primary consultants at Yashoda, We were able to manage to reduce his pain to the least possible. He passed away amongst family with considerably very little pain.

Our family appreciates Dr.Vottery, Dr.Sagar, Dr.Mohanty and Dr. Babu Krishnamurthy for their efforts and their amicable nature. Without them, My father would…

My Vote for democracy.

This visit to India enabled me to exercise my vote for general elections. Our part of the state has elections in the phase 1. My voter card was promptly delivered to my home. It did have some errors. But I carried my passport to the Voting booth and it all worked out fine.

The Voting booth was close to home. I went in around 10:30. Voting was at full capacity at that time. Waiting lines went beyond 1.5 hrs. So I went back around 2PM. In around 30 mins, I finished.

For all those people who are Voting in the second phase, Please DO VOTE! JaagoRe!!

On a Break

I havent been able to post in the last month. I am in India for a family concern. I have missed quite a few things in this month.
Grails released new version , quickly following Groovy under SpringSource.
Google released the much awaited Java support in App EngineMy Grandcentral Account pepped to Google VoiceGizmo now communicates to Skype users (okay, I am late, I just noticed)I have a lot to catch up.  My Google reader has 1000+ in every folder :p

How to Make a Local (Offline) Repository in Ubuntu / Debian

If you are in a place where you dont have internet (or have a bad one) You want to download .deb packages and install them offline. Each deb file is packaged as a seperate unit but may contain dependencies (recursively). apt-get automagically solves all the dependencies and installs all that are necessary. Manually install deb files one by one resolving each dependency would be tedious.

A better approach is to make your own local repository. Before you actually make a repo, You need *all* deb files. You dont practically have to mirror all of the packages from the internet, but enough to resolve all dependencies. Also, You have to make sure, you are getting debs of the correct architecture of your system (i386 etc)
# 1. make a dir accessible (atleast by root) sudo mkdir /var/my-local-repo # 2. copy all the deb files to this directory. # 3. make the directory as a sudo dpkg-scanpackages /var/my-local-repo /dev/null > \ /var/my-local-repo/Packages # 4. add the local repo to source…

Quickly: Command history in Linux / Shell

If you are like me, doing a lot of command line in linux (Bash) shell, there are a few commands you do very often. The following commands will make your life a lot easier to quickly go back in command history.

[!!] or better yet [sudo !!] - [!!] is an alias for last run command. One of the best use of this is - Sometimes, you type a command and the shell hits you back with a root privileges required message. You dont have to copy the command and run again. just run [sudo !!]

[history] - just spits out ~/.bash_history with line numbers. A good use of this is piping it to grep to find something. The line numbers can be used to execute the command following it. Say for example, [history | grep find] lists the previous searches (okay, it also shows all commands with "find" anywhere in the line - but a filtered, smaller list).
$history | grep find 457 find *.wav 462 find *.wav -exec lame --preset fast extreme '{}' '/tmp/mp3/{}' \; 487 find *.wav -exec mp3cvb…

Fantastic Four Firefox Addons

Update: This post is outdated, I created a Firefox Addon collection

I use only 4 firefox Addons. (I am guessing this may come down to 3 with FF3.1's Tabbing features). These four make the slickest and most productive FF for me.


Firebug - A Must for all Web Developers. One stop for all development.

Tab Mix Plus - Well there is some anticipation on the tabbing features coming in 3.1, but until then (or may be even after..), this one is a must have.

DownThemAll! - The best download manager. Very nice replacement for the not-so-friendly defaulter.

GrandCentral Click to Call - For those who use grandcentral, this is awesome. To be able to click a number on a webpage and place a call is one step closer to getting dead lazy

Don't Print

Dont print that email/document. Its not a request. Its a real, honest, warning. Dont do it. You must be really out of this world, or of the last millenium, or simply a silicon dimwit to use that printer instead of using it electronically.

In the first place, you are consuming (carelessly) yet another enviromentally expensive resource. No, not the paper. The Tree (do you know how long it takes for a tree to be ready for paper manufacturing? and all those chemicals used to make it?). On the other hand, it is much easier to search an electronic catalog than manually looking up a drawer full of business requirements in hard copy. Instead of printing those comminucation emails, jira tickets, corporate bills, use case documents (and the list goes on..) - scan them / store digitally. Many of these start off as electronic documents. Use those. You can make it worth even more by using Google Desktop search or similar tools. Much worse is printing books/study material for *reference*. Are you k…

Use meld as git diff gui viewer

Meld is a popular diff viewer in linux (gnome). It is extremely light weight. UI is very similar to WinDiff. Although it is not comprehensively robust yet, It is still a great help for people like me, handicapped to read huge diffs in command line.

Git is awesome when it comes to managing version control, esp in command line. However, while committing, you would want to check what changes are going in. git gives git-diff for this purpose. Spitting out a (unified) diff format text for showing changes. But reading this could be cumbersome at times. To visually inspect git diff, you can use the latest version of meld. The version that comes with debian or ubuntu 1.1.5 lacks git support. You need to build the latest meld (I got 1.2.1) from source. Here is how you can do it.
resolve dependencies: sudo apt-get install pyorbit pygtk gnome-python intltoolGet the source from here (opens new window).Extract the archive.In the exploded directory, run make.It makes an executable meldRun meld path/…

Site now running on django 1.0

hence the bump in minor version - 3.1

While researching on grails and the patterns around it, I looked at django, rails, and lift. All these are quite amazing frameworks that get you started on an application like in 5 mins or less (That includes database layer, view pages, and controllers). Yeah it cannot do everything you want but its there to get you to kick off.

And then I realized, how much effort I am putting in maintaining my site on hand coded - wsgi.webapp based - Python app. So I started working to move this to django based multi app site. If you dont know, I host this site on Google App Engine. It does come with a patched, short featured, django of its own. However, I preferred to use app-engine-patch and deploy with a supplied django 1.0. You get most benefits of django with this port. A very big tip of hat to Waldemar Kornewald and his team for this patch. (Guess what, They also have a similar concept of stitching mutiple js/css files - media generator)

I can see how rap…

Faster webpages fewer Images with CSS Sprites

In a previous post, I have made a point how to improve performance by reduce HTTP connections by stitching together content of css and js fragments. At that time I also mentioned a way to do it further is to reduce the number of images on a page. Because images are also loaded on HTTP connections. Again the same Cache-Control headers on the client can be used to reduce much of this traffic. But to reduce the Number of HTTP connections, You can employ a technique called CSS Sprites.

I have to confess, I don't know about this technique until I was researching on GWT's ImageBundle interface. Had I known this trick, my SarathOnline2.0 site would not have been lame - text only!

Simply the technique is to stitch all images together into one big image. This big image is called a Sprite. The images used on my site are sprite-d as shown on the left. How do we display them seperately? Using css backgrounds. To achieve this We will send a blank 1px gif. Then insert an img tag with src=bl…

Javascript: Convert Strings to Binary (and representing in a nerdy way!)

I follow those GoogleDevelopers Videos. Sometime back, in one of the presentations on GoogleIO, there was this interesting string of dots at the bottom of each page of the presentation. They looked like random big and small dots. A similar bunch of dots were also on the T-shirt of a presenter was wearing in another presentation. While it seemed something in the pattern, I could not find what it was. Finally, another presenter cleared the matter that those dots are just binary representation of "GOOGLEIO" (So much for advertizing Google IO, Impressive!).

So I wanna do it. Takes me back to days of those DSP classes at school. Nerdy me had to churn some old brain cells. I remember those first programming language classes in Pascal and C when you were asked to do fibonacci series and converting a binary string to ascii codes. That *experience* came handy here: Check it out!

Text to Binarize:
For those who came to copy the javascript code to convert string to binary, Here it is…

Decorator for Memcache Get/Set in python

I have suggested some time back that you could modularize and stitch together fragments of js and css to spit out in one HTTP connection. That makes the page load faster. I also indicated that there ways to tune them by adding cache-control headers.

On the server-side however, you could have a memcache layer on the stitching operation. This saves a lot of Resources (CPU) on your server. I will demonstrate this using a python script I use currently on my site to generate the combined js and css fragments.

So My stitching method is like this
@memize(region="jscss") def joinAndPut(files, ext): res = files.split("/") o = StringIO.StringIO() for f in res: writeFileTo(o, ext + "/" + f + "." + ext) #writes file out ret = o.getvalue() o.close() return ret;
The method joinAndPut is *decorated* by memize. What this means is, all calls to joinAndPut are now wrapped (at runtime) with the logic in memize. All you want do is u…

Define Freedom - Blogging and Media

Before I start, I want to make a few points clear. I have no contempt for either Mrs. Dutt or Mr. Kunte. Neither do I have any allegation or support for either. What I am writing, is my personal view and believe in strongest sense what and how one need to be thinking.

Everything ever is a fight in India. Truth, Freedom, Life itself. What we see here is just another classic case. In short: Barkha Dutt's coverage on 26/11 aired on NDTV while millions watched out of curiosity (for information and to quench anxiety). One Mr.Kunte in his limited reach tried to push his thoughts around. Mrs. Dutt brings in a lawsuit, and Mr Kunte. 3 months later posts a "not-for-comment" withdrawl post with specific points that have been objected. Mrs. Dutt has her own explaination too.

Thats what it is. It is neither reporting nor blogging. Its just some series of words in English formed to sentences and put to some meaning. How you want to read it is your choice. If you are Barkha or her adm…

Blogger Ajax Api - Updated My Site..

Just 2 weeks of work, I am very happy to see how it came out. My Blog is now available to browse completely on ajax. Tested in FireFox 3 on windows and linux. IE7 and Chrome.

Since I host my blog on Blogger, I am able to avail Google's Blogger Ajax Api. I would want to distribute to opensource community. However, Due to limitation of time, much of the code is tighly scripted to sarathonline.com and its template. Albiet, The Source is javascript and can be viwed by checking the source. You are free to any part of code, with optional attribution (a link back would be appreciated :) ).

The Search box (based on Google Custom Search Engine) is also updated for some slick animation, if you are looking for a Google CSE with animation. You can check out the source.

Please check out the my Ajax blog. I would appreciate any bug reports, suggestions or comments.

Feeling Ominous about IE8?

Look What I found on my webware feed last night :D NullPointerException

-Open Source!

Faster webpages with fewer CSS and JS

Its easy, have lesser images, css and js files. I will cover reducing number of images in another post. But If you are like me, You always write js and css in a modular fashion. Grouping functions and classes into smaller files (and Following the DRY rule, Strictly!). But what happens is, when you start writing a page to have these css and js files, you are putting them in muliple link rel=style-sheet or script tags. Your server is being hit by (same) number of HTTP Requests for each page call. At this point, its not the size of files but the number server roundtrips on a page that slows your page down. Yslow shows how many server roundtrips happen for css and js. If you have more than one css call and one js call, You are not using your server well. How do you achieve this? By concatinating them and spitting out the content as one stream.

So Lets say I have util.js, blog.js and so.js. If I have a blog template that depends on these three, I would call them in three script tags. Which…

Java TimeZone ++: mapping Calendar to Oracle Date or TimeStamp

In Oracle Database date and timestamp columns can be read in java using s[g]etTimeStamp() methods for storing date and time information. However, they do not save the TimeZone information! The read and write operations are done on java.sql.TimeStamp which is a subclass of java.util.Date. When reading and writing to database, they just write out the *face value* (read my previous post on dates for explaination) in Java VM's default TimeZone the code is running on. And read the value too 'TO' the java VM's Default TimeZone. So assuming you WriteDate program on a VM in EST and ReadDate program on another VM in PST (or just change system timezone) - You are getting a different *value* in the date Object.

So, How do you tackle this issue. The best way is to set your application to run on a specified (constant) default timezone. As mentioned in the earlier post this can be achieved by TimeZone.setDefault(). If you are unable to do it (For reasons unknown to me, so far), JDB…

Java's Calendar Date and TimeZone - What is all about it?

Intenally, A Date object is nothing but a long value that holds the number of milliseconds since January 1, 1970, 00:00:00 GMT. So new Date() on Jan 21 13:53:58 EST 2009 would be the same as Jan 21 10:53:58 PST 2009 = 1232564038800 (precise to the last 3 digits). So how are those two different? TimeZoneOffset. This is a int value that give millisecs diference between GMT and the Specified TimeZone. So When *printing* or getting the value of date in TimeZone, this timezone offset is added to the long utc secs. This gives the new print value (or face value - Jan 21 13:53:58 EST 2009 ). The face value includes all calculations for Timezone and is meaningfully correct only when displayed with the Timezone information (as above). Just reading and writing "yyyy-MM-dd hh:mm:ss" is incorrect. To start with let me show a small example:
Date t = new Date(); System.out.println(t); //internal value - same (precise to last 3 digits) System.out.println(t.getTime()); System.out.println(Sys…

Making a better 404 page!

The old time 404 Pages are inherently dull. All they are supposed to tell you is: Sorry the file you are looking for is missing. Check spelling, or update Bookmarks. But with a little bit of creativity, you can actually make your 404 page Worthwhile!! Better yet, make it Ajaxy!!

The point is, the did already land on an non existing url! Reasons could be many; the page is in a new location now. or is completely deleted. But you dont want to really close the door on the visitor. Look at google's main site.. (It provides a search box on top. (isnt that what you were there for? in the first place). However, our users dont come to search. They ARRIVE on a link. My Idea is if its a missing spot, Ask the visitor to look around. Help him with a search page built into the 404 page.

One way is to point the 404 to a CGI or server script. Looking at the headers, you will have a pretty decent idea about where your visitor wanted to go. Then, instead of showing a boring message. Show him some s…

In javascript RegExp is also a global Object

Some time back, I was comparing Perl and JavaScript in their Regular Expression Features. I thought it was not possible to get the holders after the matching in JavaScript like in Perl. But looks like there is something like that. A little known, use of RegExp global js object.

Like for example, You want to parse the phone number 201-123-1234 and hold area code and number in two separate variables for further use, you dont have to match it twice and replace once with area code and once with the remaining.

You could just do something like
var e = "201-123-1234"; if(e.match(/([0-9]{3})-([0-9]{3})-([0-9]{4})/)){ var area = RegExp.$1; var phone = RegExp.$2+""+RegExp.$3 }
I used this for a more complicated JDBC Connect String to SQL Plus Connect String converter (YEah, it may be less complex than I thought.)

JDBC Connect String:

SQL+ Connect String:

Air Drag and Fuel Economy.. Really?

Driving back from work, this friday, My friend and I were having an interesting discussion. He suggests driving close to the car (tailgating ) in front and coasting there would improve the Fuel Efficiency because it reduces Air Drag. Spat came my answer: NO. My point was, even in a highway situation, this saving would be less when compared to the fuel expense to catch up with him if there was ever a break in speed (and that going back from work, speeds do break quite often). Not to mention the additional risk of an accident. Although I felt triumphant myself, He didnt bulge in. His example was, the cyclists in a marathon. They keep themselves together to reduce air drag and use lesser energy.

So in the weekend, I do this research. Apparently My friend was very correct on the Cyclists. It is scientifically proven that Cyclists get advantage by moving in groups and there by reducing the drag. Logically (theoritically too) it might sound appropriate to connect the dots to cars. But look…

Addthis replaced with ShareThis

Update 02/05: I am in the process of *lightening* up the page. So removed the sharethis javascript popup. The sharing button now opens a new window, the sharing feature is updated to use addtoany.com (click the share button, its very simple api, just pass two params to a url). I realised the features given below even though are nice-to-have, dont *actually* add that much for this blog with small audience.

I changed the sharing articles snippet from AddThis to ShareThis. Of all the things, I hate about Addthis, It bloats your page with a bunch of generated script tags if you have multiple shared snippets. Like lets say if you add the gadget code into each post. The home page of the blog will have multiple script tags that are calling the same addthis.js. This will slow down the rendering of the page. And then, because, AddThis pretty much stopped updating? The dashboard is just so pale.

It has also been in webware sometime back, boasting to be the next digg. I am not sure about that, …

Re: Return of the Mobile Style Sheet

In one of the recent articles on ALAP, a Return of the Mobile Style Sheet is discussed. For a whole lot of reasons, I dont think this would really be going to be a return. Or atleast it will not be a happy camper in the web community.

At least 10% of your visitors access your site over a mobile device. They deserve a good experience (and if you provide one, they'll keep coming back). Converting your multi-column layout to a single, linear flow is a good start. But mobile devices are not created equal, and their disparate handling of CSS is like 1998 all over again. Please your users and tame their devices with handheld style sheets, CSS media queries, and (where necessary) JavaScript or server-side techniques.
Before I jump on to throw dog-pile on this "re-emergence", I would like to say, using handheld media switch in css linking is a very good way to QUICKLY make your site go mobile-friendly. All you have to do is to write up a new css link to your template and vola, y…

Numeric and String comparision in Shell

String Comparision is treated differently in Shell. -eq and -ne operators cannot be applied for this. -eq (and the clan) are applicable only when you are comparing numerics. If you have a String comparision, use = (sh) or == (bash).

Examples
##GOOD #!/bin/sh if [ "$1" = "set" ]; then echo "Setting" else echo "Displaying" fi ##ERROR if [ "$1" -eq "set" ]; then echo "Setting" fi in bash
#!/bin/sh if [ "$1" == "set" ]; then echo "Setting" fi

New Year updates to the site

I made some minor updates to the blog site over the weekend, it now covers a wider screen area. Wider Sider bar. And a very own Ajax Search Engine. More coming.

To widen the layout, I not only had to change the width attributes of container and side bar, but also recreate newer top, bottom and shadow images using gimp and existing images.

The Search bar uses google Custom Search Engine and Ajax Search API.

Also there is an attempt to solve IE 6 png transparency fix via this jquery plugin. I havent tested it myself, but if someone has IE 6 or less, please let me know.

Happy New Year!!

Friends and Family,

I recieved this from my little sister, in orkut, from india.. Sweet Greeting eh?