Monday, April 27, 2009

Avoiding Browser cache

When I tried for first time to acheive this, It didn't work. Even meta-tags inside head tag didn't work.
Finally this worked after few permutations... The trick is to add these lines even before HTML tag. I guess that these headers are respected by browsers when they see it before HTML content.

response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", -1);.
.

This works for sure... If anybody knows more cleaner solution, please do let me know...

Sources: You can find this information any JSP book. I dont remember where I got the tip to Adding these before html tag.

Sunday, February 04, 2007

Google Cache And Web Filtering

Hi fellow techies,
If you are using a webproxy, this tip is specially for you. What do you do when your proxy site is blocked by your network admin? Change to new proxy? come on, that too will be blocked soon.

Here is what worked for me:
lets say you are using, xyzproxy.com and its blocked.
try this link:
http://www.google.com/search?q=cache:xyzproxy.com

Your proxy's home page will open. From this page, when you start surfing, 9 out of 10 times you will be taken to someother unknown ip that xyz uses.

Thats all folks... Keep breaking rules... if you have any other alternative, feel free to share...

Friday, October 27, 2006

Shell command inside Makefile

hi,
In this post lets learn how to embed a shell script inside a Makefile.

Wot Makefile does:
The Makefile lists the modules that are part of the project and the libraries that should be linked.It is used by the Make utility of the compiler. Learning about make will give you the freedom of modifying it for compile time optimisation and also during testing we can modify Makefile to compile only the necessary files.

Why script inside Makefile:
The Makefile uses lots of Macros and environmental variables. And it does not have the intelligence to differentiate the shell command and normal text. In order to do manipulations on the variables defined inside the Make , we need to use small shell commands.

Shell command in Make:
when a variable is used within $() then the value of the variable is substituted.
To run a shell command command we need to tell make the path where the sh is present.
which sh
/bin/sh

use "shell" in the beginning of the command to tell the make that the string following the shell is a
shell command.
VARIABLE = $(shell command)
variable = $(shell echo $(VERSION))

There is no need to use back-quote for the commands given after shell keyword.

Look this space for more info on how to write, optimise and play with Makefile and tips on scripting as well. :-)

Suggestions are welcome

Saturday, October 07, 2006

Disable Write Protection on USB Stick

Hi folks,
this is how to write USB sticks when they are write protected. This works with WindowsXP.
*start -> run -> type "regedit"
*goto HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control
*select "StorageDevicePolicies" in the tree.
*double click on ‘WriteProtect’ in the right side pane.
*change its value to '0'. ('1' means enable write protection).

Screen shot is below for your reference


Sources: I really don't remember where I came across this tip :-(

Thursday, October 05, 2006

Drive Names in Windows

Have you ever thought how to get drive letters in Windows? If you know the cool hack below, you wont need to struggle for that.

import java.io.File;

/**
* @author karthikkannan
* Demo for listing drive letters on Windows
*/
public class Utility {
public static void main(String[] args) {
File[] roots = getDrives();
for (File file : roots) {
System.out.println(file.getPath());
}
}

public static File[] getDrives() {
return File.listRoots();
}
}

There is a static method called listRoots() in the java.io.File class. Hope this was a useful tip. See you in the next post folks.

Sources: http://exampledepot.com/

Let The Game Begin!!!

Hello World!!!

Hi friends, once again programmer’s style of starting things. Let’s hope I learn to write well. Expect only technical articles here folks. Catch you in the next post with some interesting stuff.