Wednesday, March 26, 2008

Dev : CVS History

I know everyone of us used to have the problem of finding what file we have updated to CVS recently and our current tortoise CVS doesn't allow to view history by project (I think so), so normally we will manually find the file and check the history 1 by 1. gosh... that's tiring...

I've found a cool software that might help us to do the job and cut down the time we wasted on checking files, and yes, it is free. Please goto
http://www.download.com/CVS-Logger/3000-2383_4-10411357.html?tag=lst-1
or goto download.com to find a software called "CVSLogger", download and unzip the application into your pc.

Steps To Open A Project (or specific folder, or specific file) History
1. Upon running the application, goto View --> Options.
2. Change the CVS executable path to your tortoise CVS home. Eg: C:\Program Files\TortoiseCVS
3. Click OK to save the changes.
4. Click File --> Open.
5. Locate the Project/Folder/file that you want to view the history.
6. Click OK to load the history.
7. Wait... It might take a long time to load all the history.

And there you are. With this, you can even filter the history by user basis. Enjoy with the new toy. Thanks alot to Sergey Zozulya for the cool application!

Tuesday, March 11, 2008

Dev : Skipping CVS Folder In WinMerge

WinMerge is quite a powerful tool to compare text document and folders, and I am currently using WinMerge 2.4 for quite some time. Comparing folders content couldn't be easier.

But when it comes to comparing development folders with CVS, it could mean just one thing, a hell lot of files. If you have 100 subfolders, then you will see 200 CVS folders, and 200x6=1200 CVS config files. Add on with your original files, you could end up with 2000-3000 files at least.

So what other alternatives do I have to reduce the file compared and viewed? Yes you do. Firstly, use the WinMerge to compare 2 simple folder. After doing that, clickView. Uncheck "Show Identical Files" and "Show Skipped Files". Other than this, I have no idea how to show this menu without comparing anything, it wont even show if just comparing a file.

You wouldn't want to view identical files if you are to use WinMerge in the first place right?

Unchecking the "Show Skipped Files" need you to actually do this second step. Else, it will not take effect on anything. The second step is to create a filter. Click Open and a small window will appear as below.



Click Select beside the filter dropdown, and another window will appear to let you create your own filter. Click New. It will prompt you to choose whether the new filter will be used personally or share. Anyone will do. It doesn't matter. Create a new filter file name called "CVS Filter", and inside the filter file, edit it to look something like this (most importantly is the bolded part) :

## This is a directory/file filter template for WinMerge
name: CVS Filter
desc: CVS Filter

## Select if filter is inclusive or exclusive

## Inclusive (loose) filter lets through all items not matching rules
## Exclusive filter lets through only items that match to rule
## include or exclude
def: include

## Filters for filenames begin with f:

## Filters for directories begin with d:
## (Inline comments begin with " ##" and extend to the end of the line)

d:
\\CVS$ ## CVS

Save it and there you go. Your new CVS filter is ready to be used with the unchecked of "Show Skipped Files".

Now, you will only see those files you really wish to see.

Monday, March 10, 2008

Dev : Java Code Exception, Getting Error Details

In java coding, we used to have try-catch statement mainly for capturing unforeseen code errors such as SQL query error, parsing a non number to number and as such.

Normally within the catch, we will either throw it back to the method that calls it, or print it out using printStackTrace(). If we were to print it to a string or a log file, we will use toString(). But then, printing to a log file using toString() method might not be sufficient for a developer.

[12:34:56] java.lang.NullPointerException

What does this means? I know the application is hitting some variables which had not been assigned to any value, but where is it? I had a thousand lines of code, which is hitting the error? My current catch is as such:

catch (Exception e) {
log.error(e.toString());
throw e;
}

Well, to get a better description on the log file, I would recommend to use these code instead of just e.toString():


catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
log.error(sw.toString());
throw e;
}

These code will actually write the more descriptive printStackTrace() to a buffer, and we print the buffer out instead of writing it somewhere else. With these code, I am able to get better description, including which line and what class as such:

[12:34:56] java.lang.NullPointerException
at a.class.package.anotherMethod(NewClass2.java:87)
at a.class.package.newMethod(NewClass.java:890)
at a.class.package.main(NewClass.java:60)
Exception in thread "main"

Isn't it better than a single line printout?

Saturday, March 01, 2008

Dev : Replace CVS Files, All Files

Windows file REPLACE command is something very useful that every person should know, esspecially for developers. Let me try elaborate using a scenario.

Using Tortoise CVS in windows to backup as well as managing source code versioning is a life saving attemped. It can help you to know who commited what and most of all, it is free.

But then, what if one day, your source code administrator sends all developers an email :
"Hi,

From today onwards, all CVS source code in SUN server will be moved to MOON server due to disk space issue. Please change your workstation's settings accordingly.

Thanks.

From,
Admin."

For the time being, I wouldn't know if there is any other ways to make life easier on this matter. All my source code are pointing towards SUN and now you say MOON? Yeah right, easy for you to say... But first of all, how?

By knowing the behaviour of Tortoise CVS, like every developer knows, there will be a hidden folder called "CVS" in each folder that is using CVS for versioning control in your workstation. But what you should really know is that is what's in it. For the time being, lets get straight to the point.

In each hidden CVS folder, there will be a file called Root. The content of Root might appear differently depending on what CVS authentication you use. As example, ":sspi:mydomain\cksgary@sun:/cvs". Notice that the word "sun" behind "@"? This is the keyword. Just replace the sun with moon. But yet, that is not enough. Because there are more than 2 thousand subfolders that contain this Root file. It is not possible for me to change one by one even if I sacrifice my whole day doing this.

And here comes the real life saver. Using windows REPLACE command really helped out. Just follow the steps below :

1. Ok, lets say your working folder is "D:\work". Make a copy of this Root file in "D:\". Please make sure that it is renamed exactly the same as in the working one. Change the content accordingly.
2. Go to "START --> RUN --> type CMD". This will open a command prompt console for you.
3. Type "REPLACE D:\Root D:\work /s". This will then start replacing all files with the name of Root in all folders and subfolders in "D:\work" with the "d:\Root" file.

3 steps, and you're done. This could be used in any other scenarios if there is a need to replace all files with the same name.

Thursday, December 27, 2007

Car Ownership Transfer

They say that it would take all day for the procedures to be done. Well, not so accurate. I would say "almost a full working day", that should be it. I've been through the hustle because I just did a car ownership transfer without bank loan recently.

Simple say, there are only 3 steps to get your transfer done. But yet, 2 among the 3 steps will kill your time. Ok, nothing is free and each steps require you to pay, pay and pay. Here is my experience.

Firstly, get your car to Puspakom. Bring your car registration card and RM30. Be sure that you be there early, else you would need to wait in the queue and it took me 2 1/2 hours to get through 5-7 cars queuing in front of me. They will inspect your windscreen (where your front windscreen transparency level must not be less than 70%, and 50% for the side windows and rear windscreen), car chassis number, car engine number and kereta-potong (which simply means 'cut-and-joint' cars in Malay).

After the long wait has been settle in Puspakom, you need to get your car insurance ready. Either you buy a new policy or get an insurance policy transfer from the previous owner. Transfer price will vary according to the available NCD/NCB. Get your insurance agent for the fee.

Lastly, the 2nd waiting session. Bring your car registration card, RM100, insurance policy/transfer letter of proof, Puspakom inspection result, K3 form, the owner and the new owner to JPJ to have your name printed on the car registration card. You can print your own K3 form at home and fill it up before going there. Well, I did called JPJ Putrajaya regarding this and they told me that neither the owner nor the new owner need to be there, Just get your photostated Identification Card verified by commissioner of oath. But it seems like JPJ Melaka is different. From their look (most are quite friendly, only one at the counter 29 seems scary and snobbish), they seem looking for both person. And I too heard that JPJ Melaka really do require both of them to be there from a friend. How true is that, I dare not challenge. I would not want my time wasted for nothing.

Wallah... Done... The formula on how to waste 1 full working day! Sigh... Driving from one place to another, which is certainly not near really waste much of the time.

But somethings I cannot understand why must we send our car to Puspakom for checkup before ownership transfer. It is really a waste of time. By the way, Puspakom is a member of DRB-HICOM, which is a private company. I guess it is just a way to make more money to team up with the government?

Wednesday, December 05, 2007

Dev : Telnet-ing

A simple tips to share to everyone. As we know, each program that dwells through the network will be communicating through a certain specific port. For example, MSSQL2000 is using port 1433, SMTP is using port 25 and ssh is using port 22.

If we fail to connect, lets say, the mail server of the company, we can actually do a quick check on the problem. Using windows telnet to connect to the network port would be a great start. It will just take a couple of steps to check on the SMTP port of the mail server. Although telnet is defaulted to connect to port 23, but with an additional parameter, we can also telnet to any desire port.

Steps (Make sure your firewall is off and network is up for clearer picture)
1. Open your Command Prompt (Start --> Run --> cmd).
2. Type telnet mailserver 25.
3. If you receive such message Connecting To mailserver...Could not open connection to the host, on port 25: Connect failed, this means most probably the mail server itself is down or maybe the mailserver daemon is not running. Daemon is a small program running in the background either waiting for command or run on its own on a specific port.
4. If you success, you will be brought to a new blank page (normally). This means the mailserver and port is running fine. You will need to check your mail browser instead. Press keyboard ctrl+] to disconnect the telnet.
5. Type quit to exit the windows telnet.

This is very useful, esspecially if you are trying to set up a program such as Apache webserver but you are not sure whether it is running fine or not. You can try connect Apache webserver on the local machine by using telnet localhost 80.

*Keep in mind that normal telnet is telnet ip_or_hostname_of_machine. Telnet checking should be telnet ip_or_hostname_of_machine port_used.

Wednesday, November 28, 2007

Dev : Getting HTML Dropdown/Combobox Label, Not Value

Something quite interesting on combobox my colleague had just asked me. Using javascript, how do we get the label value, instead of the real value of a combobox. well, umm... har.... how har? :-) I am not an expert in HTML and javascript, so scratching my head is the only thing I can do.

But after some research on the Net, I've found some resources that helped to solve the problem. You don't need to hide the label value somewhere or in the html option tag, just create your dropdown/combobox as normal, using this three tiny line of code in your javascript, and you're done!

var comboList = document.myform.combolist;
var comboValue = comboList.value;
var comboLabel = comboList.options[comboList.options.selectedIndex].text;

Monday, October 01, 2007

Dev : Tracing Users

My Gosh! Where is the file I have just created? It was here a minute ago....

So someone had log in and done something to your file. Who is it? You have over 100 co-workers here. So how do we actually see who had done something wrong? By using the command "finger" and "w", we might be able to get something straight.

Generally, the mighty "w" will help you to trace who had login to this server and what are they doing currently. "finger" instead, will let you see the list of logged in users, what time they are already in and from where (IP address) these users come from.

These are some commands that might help you to trace the culprit. There should be some other way to get a better "result" and I am still trying to study and find the best way, but for the time being, just bear with me. :-)

Monday, September 17, 2007

Dev : EUC_CN

Wow... something so alien to me. I encounter this encoding error during a test run on a project.

java.io.UnsupportedEncodingException: EUC_CN at sun.io.Converters.getConverterClass(Unknown Source) at sun.io.Converters.newConverter(Unknown Source) at sun.io.CharToByteConverter.getConverter(Unknown Source) at java.lang.StringCoding.encode(Unknown Source) at java.lang.String.getBytes(Unknown Source) at
:
:

I have no idea what is wrong and I definately didn't have any problem on my browser's encoding because I have run this projects million of times on my workstation. I turned in to my sifu when my brain juice started leaking out. Unlike me who had use the whole morning trying to figure out what the f*** is this, my sifu just took 5 minutes to solve my misery, and he told me that it is actually the problem of my jdk. I am using 1.4 for this particular tomcat and if I change to 1.5, it will definately work. He showed me an article of the problem too.

Yeah. It really works! Cool...

Friday, August 10, 2007

Dev : Failure of server APACHE bridge

This morning was an havoc when one of our web portal was not accessible.

We got something similar to this when accessing the portal.

This in a way was useful for the developers to understand what is happening.It could only mean one thing. Apache could not connect to weblogic. But for customer point of view, it is some mambo jumbo stuff that they would just say "Server Crash!".

I would suggest to all the developers and to those who concern, when webridge Apache to Weblogic (or might work for other webserver as well), to add in some stuff to make the "error" look more beautiful.
The steps are:

1. Add in your error page in apache_path/htdocs.
2. When setting your weblogic IfModule Location for your system, add in theErrorPage parameter.
E.g.:
    <location /myportal>
      SetHandler weblogic-handler
      WebLogicHost 192.168.1.152
      WebLogicPort 7004
      ErrorPage errorpage.html
    </location>
3. Restart apache.

Currently I see that some of us do not have this practice yet. It is always better that to let our client and customer see something useful, rather than rocket science stuff.