Skip to main content

Posts

Showing posts from January, 2009

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. Wh

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),

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 = 123 2564038800 (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

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

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 lo

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

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 vo

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?