Thursday, November 24, 2005

Cache-Busting with Javascript

Got an opportunity to work with Javascript. On reading, got this information.

What it is?

As we all know, when we are browsing the pages fetched by the browser will be stored in the browser's cache. If we want to get the page from the server and not from the cache, using Javascript, it is very simple. Just add a random key-value pair to the URL. This should be unique for each request.

How to do?
Set your request URL as :
URL +"?rand=" + (Math.random() * 99999999);

How it works?

I assume that, the browser MAY maintain a key-value pair (Something like a HashTable), that contains the "URL of the requested page" as the key and the "contents of the page" as its value. So when a request is made, it first checks its cache and if it finds a page it returns it, else fetches from the server. In our case, since random() generates different values for each call, the browser will assume that this is a new request for a page and fetches it from the server. This in no way affect the server. Since the server may not know about the additional parameter, it will discard the variable.

Wednesday, November 09, 2005

printf(_"string") - What does that "_" mean?

Most of us might have encountered a code like the one mentioned above. What does this mean? Goooogling gave me its meaning.

Actually, a macro by name _(str) will be defined as follows:
#define _(str) gettext(str)

What gettext() does?

The gettext function translates the "str" from the natural language message into the user's language by looking up the translation in a message catalog.
From this, what I understand is, suppose I am using Latin language in my machine. And the string "str" is in English. So whenever printing, the gettext() translates English to Latin gives it to printf(). So I'll be seeing the messages in Latin.

Hope Microsoft also uses a similar kind of macro "_T" for displaying strings in multi-byte format.

Wednesday, October 05, 2005

Retrieve deleted mails in Microsoft Outlook

Today I SHIFT + Deleted all my mails from Outlook 2000 by mistake. I somewhere read that there is a way to recover the deleted mails. I Gooooooogled for sometime and I got a page that told me how to retrieve SHIFT + Deleted mails. As per that, I did the following steps.
  • I downloaded XVI32 and Hexadecimal editor.
  • Opened the "Personal Folders.pst" file with that.
  • Replaced some characters with space and saved the file. (Corrupted the existing pst file. Hopefully the headers)
  • Ran "scanpst.exe" on that file. (Comes with Windows. Recovers a corrupted pst file.)
  • Started outlook.
Wooooooooooooooooooooow.... All my mails were back in my Inbox.

Thursday, September 22, 2005

Is BMTC paying their conductors???????????

I am staying in Bangalore for the past 1 year and travelling in BMTC frequently for the past 6 months. I can count the number of times I got tickets from the conductors when I am going to office. My bus fare is Rs 3. When I give the amount, they will return me Re. 1. without giving me the ticket. Whenever I ask for ticket, the conductors will shake their head in such a way that it is not a problem. Or they will murmer something. (It is obvious that they are non-parlimentary).
Since I don't know Kannada, I am unable to argue with them for getting the ticket. Luckily???? or Unluckily checking inspectors never came into the busses at these times.

Lets do a simple calculation....

Assume that a conductor gets a minimum of
Rs. 60/- like this per day and there are 50 such conductors.
So the Govt. looses Rs 3000/- per day and for a month it is Rs. 90,000/-.

I am sure that the above amount is definitely less than the original amount. This money can be saved and the bus fare can be reduced a bit which will be helpful for thousands of people travelling allover Bangalore.

Will concerned people look into this??????