Wednesday, August 20, 2008
Modifying the right click in Win XP
1) To add the command prompt entry to your right click Open Explorer -> Tools(menu) -> Option -> FileTypes (tab) -> Folder Click on the Advanced button. In the dialog box , click on the New Button. In the new dialog box that pops up
Action: Command Prompt (any title)
Application used to perform action : cmd.exe
Click all the Ok buttons and your work is done. Now everytime you right click on any folder, you will see the Command Prompt option which you can use to directly go to the command prompt.
Note: Instead of choosing ‘Folder’(Open Explorer -> Tools(menu) -> Option -> FileTypes (tab)-> Folder) if you choose ‘File Folder’ you are in for some trouble. Everytime now you double click a folder, instead of opening it , it will open the command prompt. Now to solve this problem read point 2) below
2) To change the default action of a right click Many times after you add/remove new actions to a right click it may so happen that because of some mistake your default folder behaviour is changed. In my case every time I double clicked any folder it would open the command prompt (see note in point 1)). This is because some mistake of mine had affected the default behaviour of the folder double click. Set the HKEY_CLASSES_ROOT\Directory\shell to none and this problem should go away.
3) To remove the options added by various software’s when you install them. E.g. Winzip, Winmerge, etc You have to delete them from - HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers
Thursday, May 01, 2008
Regular Experssions and Java
Example 0)
String str = “someString”;
str.replaceAll(“*”,”#”);
The above snippet would replace all ‘*’ characters in the String str by ‘#’, simple, isn’t it? Well, if it’s so straight why is it here ;)
The replaceAll() API in String class has the following syntax – replaceAll(String regex, String replacement)
Yeah, I hope the term regex caught your attention. The first String is treated as a regular expression by Java and as a result the above snippet gives you a lovely error -
Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
Lovely, because it uses the word dangling ;)
If you know regular expressions even a little the character ‘*’ has a special meaning – it means zero/more times. Let’s take some examples so that this is clear
Example 1)
String str = "the Blue Umbrella is bllue in collor";
System.out.println(str.replaceAll("ll*","?"));
Output: the B?ue Umbre?a is b?ue in co?or
Explanation: the regular expression ll* searches for strings {l, ll, lll,….} etc and the code replaces them with ?
Note: simple l* will search for {emptyString, l, ll, lll, ….}
Example 2)
String str = "the Blue Umbrella is blue in color";
System.out.println(str.replaceAll("rella.*","???"));
Output = the Blue Umb???
Explanation: ‘.’(dot) means any character, so .* would mean any character zero/more times. Hence everything from rella… gets replaced with ???
So in Example 0) to replace * with # you have to tell Java that do not take * in the regular expression term but as it is; so do a str.replaceAll(“\*”,”#”)….just escape your *….thats all!!!!
Wednesday, April 09, 2008
Java Object References
Someone was writing a parser and while unit testing he got bugged because the two lists that he was creating using the same objects was getting modified without he explicitly doing so. After having a look at the code it turned out to be a simple problem. In java, you deal with object references as against objects. So if you have
Object o1 = new Object(); Object o2 = o1; Object o3 = o1; You have a single object but 3 references. //heres a snippet of what my colleague was actually trying to do. He complained that list1 and list2 were getting modified on their own…Really??? Have a look
import java.util.ArrayList; class Emp { private int code; public Emp(int c) { code = c; } public void setCode(int c) { code = c; } public String toString() { return ""+code; }
}
public class References {
public static void main(String[] args)
{
ArrayList
p.s. Sorry about teh formatting....this stupid doesnt maintain the format that i write in and i am too lazy to use html tags and google docs is not working....so just pick the snippet and paste in a decent browser. it will work ;)
Thursday, June 07, 2007
Reading a file using PL/SQL
Its got nothing fancy and a simple google would yield the needed info. Then the use of this blog? If thats what you were thinking....Folks googling , you will faind the info distributed. I have tried my best to put everything at one place.
I am assuming an oracle database on a windows machine;
The compact algorithm is -
Step1: Entry in your init.ora file -> utl_file_dir = dirPath
Step2: Create virtual directory mapping for oracle which points to the actual physical directory where the files are stored
Step3: Grant appropriate permissions on the virtual directory.
Step4: Create the file you would like to read thru PL/SQL, on the physical location
Step5: Write a procedure which would use the “utl_file” package of Oracle to read/write to a file
To get the details of this algo please click here
Sunday, March 25, 2007
Generics
Everything about genrics is here
Wednesday, March 21, 2007
YUI
Tuesday, February 20, 2007
An interesting problem
An interesting problem that someone had asked me -
You have a set of 300 pages that are numbered with you. The pages are in any random order. Suddenly the window opens and a single page flies out(don’t ask me why only a single page :P). Now the rule says that you can go thru the numbered pages exactly once and you can’t jot down the page numbers anywhere. How would you find the missing page number?
Solution: Let’s generalize the problem to ‘n’ pages. Find the sum of 1 to n. Call this x. Now as you can go thru the pages exactly once calculate the total of the page numbers as you go thru them. Call this total y. The missing page is obviously x – y;
Wednesday, January 17, 2007
Event Delegation Model explained
Click here for the document.
For detailed info on the same plzz visit the SUN link here.
Wednesday, January 10, 2007
First step towards JDBC
The document is in an algorithmic form and just tells u the reasons behind the order of calls of the JDBC API's. It stops when u have created a Statement and can fire queries, essentially the point where SQL queries take over JAVA. How to fire queries, ect would soon be appended to the document.
The document can be viewed here
Everytime i upload a document I dont forget to say thanx to google. Its made sharing of docs/ideas so much easier
Thursday, January 04, 2007
Using Eclipse to create a web-based project
The doc has been uploaded on net and can be accessed here
Incase you want me to add/modify anything do lemme know.