Thursday, November 12, 2009

A note on Java's Calendar set() method

Remember that the Calendar's internal fields include year, month, date, hour, minutes, seconds, milliseconds and time zone. Whenever you are calling a set() method with multiple fields, like set(year, month, date), it will not affect the rest of the fields.

Remember that there is no set() method with multiple fields available to set the milliseconds. If you would like to set the milliseconds, you must use set(Calendar.MILLISECOND, value). Likewise, if you are planning to set all the fields, its a good idea to reset all the fields using clear() method. This will clear milliseconds as well.

Most of the times, millisecond field may not be of interest to you. But if you are going to use the UTC milliseconds, by calling getTimeInMillis(), then make sure you set the right values for milliseconds as well.

Sunday, November 01, 2009

Netcat for windows

I was troubleshooting an issue with one of the clients. And I desperately needed them to run the netcat tool and send me the output. But their OS is windows. So I was looking for the netcat tool for windows. Here it is: http://joncraton.org/files/nc111nt.zip

Thursday, September 03, 2009

Eclipse - issue with setting break points

I recently ran into a weird issue. I had to debug a piece of code that I wrote. So I launched the application in Eclipse in debug mode, and set a few break points. Though I can see that the log messages related to all the break points appear in the log, it didn't stop in all the break points. In some break points it stopped and in some other it didn't stop. I checked the output directory, I checked the flags to the compiler, even I downgraded to Ganymede. Nothing seemed to work.

When I asked the question in the stackoverflow.com, I got the answer in five minutes. Looks like JDK 1.6 update 14 has an issue with debugging. So upgrading to JDK 1.6 update 16 helped. But still I am seeing the issue occasionally.

Saturday, August 29, 2009

CircuitCity online is open for business again

CircuitCity online is open for business again. They filed for bankruptcy in Nov 2008 and closed both online and stores.

Comparison of SSD and drum-based HD (HDD)

I am in the process of assembling a PC for my friend. So I was gathering information on various components. I thought I must share what I learned about hard disks.

The latest breed of hard disks in the PC segment are called Solid State Disks (SSD). Though the technology is not new, the price has become affordable in the recent few years. Due to their formidable high prices earlier, computers were usually shipped with the drum-based hard disks (I will refer to them as simply HDD). You can read about SSDs from wikipedia.

These are the points I wanted to share:
1) The transfer speed of SSD is faster compared to HDD. A good 7200 RPM hard disk usually has a transfer rate around 70 MBytes/sec. Where as SSD has a transfer speed around 200 MBytes/sec. Remember I am giving an approximate figure and speeds vary for read and write. One of the recent additions to the hard disks is 10000 RPM hard disks. I found them to be faster than SSD. For e.g. Western Digital's Velociraptor has a peak transfer speed of 384 MBytes/Sec.

2) The life time of SSD is very good. The Mean Time Between Failure for an SSD is in millions of hours. For e.g. OCZ's 60 GB SSD is having an MTBF of 1.5 million hours. So SSDs are more robust.

3) The shock tolerance of the SSD is substantially higher. For e.g. OCZ's 60 GB SSD's max shock resistance is 1500G. But for Velociraptor, the same value is 300G.

4) The SSDs make less noise compared to HDD as there is no mechanical parts.

5) One of the cons of the SSDs is the price per bit of SSD is still substantially higher. For e.g. a OCZ's 60 GB hard disk costs $219, where as the Velociraptor 300 GB costs $229.

Whats my advice? If you are serious about the life of the hard disk, try SSD. If you are crazy about the speed, try Velociraptor.

What have I decided? I have decided to buy the SSD and to add an external hard disk with eSATA interface. I have decided to buy Iomega Prestige 1TB.

Friday, July 31, 2009

Ubuntu from USB drive

I wanted to try out running Ubuntu from my USB drive (2GB). While I was searching for the right software, I came across UNetbootin utility. This utility is a lot simpler to use than the method provided in the Ubuntu site, a method that makes use of Win32 disk imager. The best part is, UNetbootin provides you options to create bootables from other operating systems like FreeBSD, NetBSD and other notable flavors of Linux.

UNetbootin is not an installable, its just one .exe file. You download the exe file and start it. It will prompt you for the version of OS you would like to burn in your USB. Once you select, it will automatically download the ISO image file and burn it for you. In case you happen to have the ISO image file available on your local hard drive, you can provide that path too.

Eclipse icons

Here is a complete list of icons that are used in Eclipse. It is very useful to understand all these icons as most of the time in the outline views only the icons are used to crisply denote what each member/method stands for.

Wednesday, July 29, 2009

Good JavaScript frameworks

This page provides you a list of top 5 JavaScript frameworks. Though I am not sure if they are the top 5, which is always arguable, I am very sure that those frameworks are good and useful.

Saturday, July 11, 2009

VirtualBox 3.0 freezes bug has been fixed

If you had been following my blog, I posted an issue earlier with VirtualBox 3.0 that under network load it freezes. That bug has been fixed in release 3.0.2. Please refer to the release notes of 3.0.2 for an update. I verified the fix by reinstalling the 3.0.2 version.

Troubleshooting network issues in VirtualBox

VirtualBox comes with built-in facility to trace the network packets. To enable tracing, you must first shutdown your VM. Then find out the VM's name or uuid. Please refer to my earlier post to find how to find uuid. Once you have the uuid of the VM, give the following command:

vboxmanage modifyvm a27473c0-d690-4c95-a48a-1c49d69a20e6
--nictrace1 on --nictracefile1 c:\temp\nictrace1.pcap

Replace my uuid with yours. I am enabling tracing on the NIC1. You will have to change the parameters appropriately if you would like to trace some other NIC. To make sure that your VM's tracing is enabled on the specified interface, give the following command:

vboxmanage showvminfo a27473c0-d690-4c95-a48a-1c49d69a20e6
VirtualBox Command Line Management Interface Version 2.2.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Name: Ubuntu8.10
Guest OS: Ubuntu
UUID: a27473c0-d690-4c95-a48a-1c49d69a20e6
Config file: C:\Documents and Settings\xxxx\.VirtualBox\Machines\Ubuntu8.10\Ubuntu8.10.xml
Memory size: 512MB
VRAM size: 12MB
Boot menu mode: message and menu
ACPI: on
IOAPIC: off
PAE: off
Time offset: 0 ms
Hardw. virt.ext: on
Nested Paging: off
VT-x VPID: off
State: powered off (since 2009-07-11T18:45:41.000000000)
Monitor count: 1
3D Acceleration: off
Floppy: empty
SATA: disabled
IDE Controller: PIIX4
Primary master: D:\xxxx\VM\Ubuntu8.10-desktop-xVM\VDI\ubuntu-8.10-x86.vdi (UUID: 58a58064-e589-47c0-baba-de38fa62
1c80)
DVD: C:\PROGRA~1\Sun\XVMVIR~1\VBoxGuestAdditions.iso (UUID: 60b22ad4-50d1-4fb7-8097-862ce763df52)
NIC 1: MAC: 080027AC3BCE, Attachment: NAT, Cable connected: on,
Trace: on (file: c:\temp\nictrace1.pcap)
, Type: Am79C973, Reported speed: 0 Mbps
NIC 2: disabled
NIC 3: disabled
NIC 4: disabled
NIC 5: disabled
NIC 6: disabled
NIC 7: disabled
NIC 8: disabled
UART 1: disabled
UART 2: disabled
Audio: enabled (Driver: DSOUND, Controller: AC97)
Clipboard Mode: Bidirectional
VRDP: disabled
USB: enabled


Once done, start your VM. The trace would be written to the file you have specified. You can use tcpdump or Wireshark to analyze the packets.

Make sure you disable the trace once you are done. Give the following command to disable tracing:
vboxmanage modifyvm a27473c0-d690-4c95-a48a-1c49d69a20e6 --nictrace1 off

The only limitation of using the trace facility is that you cannot turn on or off tracing while the VM is up and running. Thats a very serious thing if you run into some network issue in the middle of a session in your VM.

Thursday, July 09, 2009

Line color in PlotKit

I am experimenting with PlotKit tool. So far I am liking the simplicity of the library and the good documentation.

I was making use of the SweetCanvasRenderer to draw a line graph, as I was strictly following the quick start example. I wanted to draw two line graphs in the same canvas, each with different colors. But with the SweetCanvasRenderer it is not possible to change the line color, as it always overrides the strokeStyle property in the Context with white color. See the code below from SweetCanvas.js:
context.strokeStyle = Color.whiteColor().toRGBString();
If you would like to make use of SweetCanvasRenderer, still would like to have different colors for each of the lines, you will have to do it with little changes to the SweetCanvas.js file. Or you can consider making use of the BasicCanvasRenderer.

VirtualBox 3.0 freezes under network activity

*** Update on 07/11/2009 ***
The issue below has been marked as fixed. Refer to the release notes of 3.0.2 for a note on what has been fixed. I think now you can happily move back to VirtualBox 3.0 :-)

After installing the VirtualBox 3.0, I ran my Ubuntu under that. When I ran update manager, my VM kept freezing. I realized that not only with update manager, even with Firefox trying to download a huge file, the VirtualBox freezes. Looks like this a known issue and there is a bug artifact for this one. As of now, there is no fix available and there is no ETA as well when the fix will be available.

So I have happily reverted back to VirtualBox 2.2.4 version. I don't see that issue anymore.