Reverberations

Internet Explorer’s Trailing Comma Woes

Posted in AJAX, Coding, Computing, Hax0r, Search, javascript, trick by Brajesh on March 18th, 2008

Internet Explorer is notorious for breaking on trailing commas in JavaScript array declaration. e.g.

var obj = {
     a: 1,
      b: 2,
};

fails on IE, while all other browsers just ignore the innocuous trailing comma after second element.

Weeding out these commas from JavaScript code is absolute PITA. However, here is a regular expression search string I wrote to search such instances in the code.

,\s*\n+\s*[\}\)\]]

Even better,
,\s*\n+(\s*\/\/.*\n)*\s*[\}\)\]]
matches multiple new lines and comments.

Safari on Windows Crashes Too Often

Posted in Apple, Coding, Computing, Design, Desktop, Linux, Rant, Windows, javascript by Brajesh on January 23rd, 2008

I’m not much of a fan of Apple softwares on Windows. I like iTunes though, even if it’s a bit bulky. I’ve tried using Safari on Windows for its super pleasing font rendering, aesthetics and, of late, some testing on WebKit/KHTML. However, it crashes just too often to be of any serious use and, of course, doesn’t have any DOM inspector. It has a barely usable JavaScript console though.
On a side-note, I’ve read that Safari can work on Linux under Wine. I’ll give it a try sometime. Now, if only I could run iTunes under Wine :) .

safaricrashonwindows2.png

Static File Retrieval From Web Server Quicker Than Browser Cache

Posted in Coding, Java, Jetty, Tomcat by Brajesh on January 1st, 2008

It’s a small not-very-useful exercise, but, as the result is unexpected for me - here it is.

I’ve created a web page where two images are served as static files, and two images are served by a Java Servlet. The images served as static files (top two images) are cached by the browser for future runs.

The results are as following:
Jetty:

[Server]
jetty-server-1.png

[Cache]
jetty-cache-1.png

Tomcat:

[Server]
tomcat-server-1.png

[Cache]
tomcat-cache-1.png

The actual numbers are irrelevant, but the relative ratios consistently demonstrate that the web server “can” serve images much quicker (disregarding network latency) than the browser can retrieve them from cache. As expected, web servers serve static files quicker than they can serve Java Servlets.

Sidenote: damn, browser image resize is ugly.

Linus-logue

Posted in Coding, Culture, Linux by Brajesh on December 19th, 2007

http://groups.google.com/group/fa.linux.kernel/msg/52f04d4ab1121c9b

From: Linus Torvalds
Date: Sat, 1 Dec 2001 00:58:03 GMT
Subject: Re: Coding style - a non-issue

Newsgroups: fa.linux.kernel

On Fri, 30 Nov 2001, Rik van Riel wrote:

> I’m very interested too, though I’ll have to agree with Larry
> that Linux really isn’t going anywhere in particular and seems
> to be making progress through sheer luck.

Hey, that’s not a bug, that’s a FEATURE!

You know what the most complex piece of engineering known to man in the whole solar system is?

Guess what - it’s not Linux, it’s not Solaris, and it’s not your car.

It’s you. And me.

And think about how you and me actually came about - not through any complex design.

Right. “sheer luck”.

Well, sheer luck, AND:
- free availability and _crosspollination_ through sharing of “source code”, although biologists call it DNA.
- a rather unforgiving user environment, that happily replaces bad versions of us with better working versions and thus culls the herd (biologists often call this “survival of the fittest”)
- massive undirected parallel development (”trial and error”)

I’m deadly serious: we humans have _never_ been able to replicate something more complicated than what we ourselves are, yet natural selection did it without even thinking.

Don’t underestimate the power of survival of the fittest.

And don’t EVER make the mistake that you can design something better than what you get from ruthless massively parallel trial-and-error with a feedback cycle. That’s giving your intelligence _much_ too much credit.

Quite frankly, Sun is doomed. And it has nothing to do with their engineering practices or their coding style.

Linus

Jetty/JBoss Code Redeployment Slow on Eclipse

Posted in Coding, Computing, JBoss, Java, Jetty, Linux, Personal, Rant, Tomcat by Brajesh on December 19th, 2007

I’ve downloaded Jetty Server Adapter for Eclipse recently. Jetty is supposedly very nimble Java-based HTTP Server and Servlet Container. I’m not sure if I’m doing it wrong, but I find code redeployment very slow and buggy when using Jetty on Eclipse. Even Jboss, another heavy duty application server, is bad on Eclipse with 15-25 second redeployment time.

So far I’ve found only Tomcat to be suitable for development with almost instant redeployment.

Another nuisance is that Jetty relies on the presence of PID file ( on my RHEL 4.2) to determine whether it’s running or not, which is, more often than not, inaccurate as I usually close Eclipse without shutting down Jetty server. Tomcat is much more stable in that sense. However, Jetty seems much more exciting to develop “for” (as opposed to “on”) as it has continuations, a very clever hack/feature.

I suppose that the preferred way to develop on Jetty is to use Maven, and Jetty Server Adapter will improve with future releases of WTP/Eclipse milestones.

Google Chart API: Simple and Awesome

Posted in Coding, Google, trick by Brajesh on December 7th, 2007

The Google Chart API looks to be the simplest way of generating high quality dynamic chart images for Line chart, Bar chart, Pie chart, Venn diagram and Scatter Plots. You just have to pass the chart data as URL parameters e.g.


http://chart.apis.google.com/chart?
cht=lc&
chs=200×100&
chd=s:ThisIsReallyReallyCool&
chxt=x,y&
chxl=0:|Apr|May|June|1:||666+KB

would produce this chart -

ThisIsReallyReallyCool

Compiling Greasemonkey Scripts to xpi (Firefox Extension)

Posted in Coding, Firefox, Hax0r, greasemonkey, javascript, trick by Brajesh on November 28th, 2007

Databases vs Schemas

Posted in Coding, SQL by Brajesh on November 6th, 2007

PostgreSQL and MySQL differ on databases vs schemas terminology. While creating constraints such as foreign key, MySQL lets anyone reference tables across databases (without explicitally using schema). OTOH, PostgreSQL doesn’t have any way to maintain cross database references (as of PostgreSQL 8.2). So, although MySQL’s implimentation is non-standard (and incorrect) it is more functional in this case.
Wikipedia:

MySQL aliases schema with database behind the scenes, such that create schema and create database behave identically. It can be said that MySQL therefore has implemented cross-table functionality, skipped schema functionality entirely and provided similar functionality into their implementation of a database. In summary, Postgres fully supports schemas, but lacks some functionality MySQL has with databases, while MySQL doesn’t even attempt to support true schemas.

Gmail Updated

Posted in AJAX, Coding, Design, Firefox, Google, Hax0r, WTF, Web 2.0, greasemonkey by Brajesh on October 30th, 2007

Gmail’s new version rolled out for me today, and first thing I noticed that it had reset my gmail chat config (basically I had switched off gmail chat), my greasemonkey scripts were broken and I had a firebug extension warning on top.

While I have no gripe about greasemonkey, resetting gmail chat setting means I’ve to check rest of my settings to be sure anything else is not broken.

New version seems quicker, with additional options in “More Actions” menu and updated “Contacts” section.

Direct Link to IMDb Movie Quotes

Posted in Coding, Firefox, Hax0r, Movies, greasemonkey, trick by Brajesh on October 20th, 2007

A small greasemonkey script to get direct link to a quote on IMDb’s “memorable quotes” page. This script creates a “#” with a link to corresponding quote.