Craftsmanship and Ethics

This is nice presentation by Robert C. Martin posted at InfoQ. Here he talk about things that makes us professional. He talk about lot of important topics which help us to do better programming. If you are interested in programming this a going to be really really helpful for you.
In my point of view it is a MUST read for every programmer.
 

diGIT Magazine Launched


First release of the diGIT magazine was launched this month. It is a magazine dedicated for various stuff related to IT. This first release of the magazine is fairly large and rich in content ranging from introductory articles to advance stuff like Agent technology. So everyone from school children to university students can gain a lot from it.
You can view the online version of diGIT or you can download it in pdf format.
I also contributed to this magazine. My article is basically about how to start writing better code. I'm planning to write a series of articles on this topics covering various aspects of better coding practices and methods.
 

Alternative for JMS Receiver

Around 6 weeks back I was working on a project that used JMS. Application needed to receive messages through an ActiveMQ queue and then send those as SMS messages to a SMSC. This message sending happens as a batch and I needed to get batch size of messages from ActiveMQ inorder to send. I used JmsTemplate provided by Spring framework for this and used receive method to get messages from the queue.
Initially it was working fine, but later after more testing I found out that sometimes JmsTemplate's receive method do not return messages eventhough there are thousands of messages in the queue. I Googled, followed instructions given in many forum posts and ActiveMQ site with out much success.
Then one of my collegue Romith started searching source codes of some popular open source projects to see how they have used JMS receives. We were lucky... In Mule's code we found out the they have used JMS listners as a receiver. (May be mule people also have faced the same kind of problem as we were with receivers :) )
When we want to receive a message we initialise listener and get the message and then close that listener. We also developed simple class that can do the same, and it did the trick for us. Following is the simple class where we use JmsListerns to work as JmsReceiver.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jencks.amqpool.PooledConnectionFactory;

import javax.jms.*;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public class JMSQueueReceiverImpl implements MessageListener {

private QueueConnectionFactory queueConnectionFactory;
private Queue queue;
private QueueConnection queueConnection;
private QueueSession queueSession;
private QueueReceiver queueReceiver;
private final Object messageReceiveWaitLock = new Object();
private MessageConsumer messageConsumer;
private Log logger = LogFactory.getLog(JMSQueueReceiverImpl.class);
private List receivedMessages = new ArrayList(20);
private int requiredMessages = 0;
private int RECEIVE_ALL_TIMEOUT = 1000;
private PooledConnectionFactory pooledConnectionFactory;
private static Map> missedMessages = new Hashtable>();
private static long totalJmsMessageConsumed = 0;
private static long totalJmsMessageReceived =0;
private static long connectionCreateCount = 0;
private static long connectionCloseCount = 0;


public JMSQueueReceiverImpl(QueueConnectionFactory queueConnectionFactory, Queue queue) {
this.queueConnectionFactory = queueConnectionFactory;
this.queue = queue;
try {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++connectionCreateCount + "] Creating the connection to the Queue [" + queue.toString() + "]");
}
queueConnection = (QueueConnection)pooledConnectionFactory.createConnection();
queueSession = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
messageConsumer = queueSession.createConsumer(queue);
// doStart(queue);
receiveFromCacheIfExtraMessagesFetched(this.queue.getQueueName());
} catch (JMSException e) {
if (logger.isDebugEnabled()) {
logger.debug("Error while creating the connection ", e);
}
}
}


public JMSQueueReceiverImpl(PooledConnectionFactory pooledConnectionFactory, Queue queue) {
this.pooledConnectionFactory = pooledConnectionFactory;
// this.queueConnectionFactory = queueConnectionFactory;
this.queue = queue;
try {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++connectionCreateCount + "] Creating the connection to the Queue [" + queue.toString() + "]");
}
queueConnection = (QueueConnection)pooledConnectionFactory.createConnection();
queueSession = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
messageConsumer = queueSession.createConsumer(queue);
// doStart(queue);
receiveFromCacheIfExtraMessagesFetched(this.queue.getQueueName());
} catch (JMSException e) {
if (logger.isDebugEnabled()) {
logger.debug("Error while creating the connection ", e);
}
}
}

private void doStart(long timeout) throws JMSException {
messageConsumer.setMessageListener(this);
queueConnection.start();
synchronized (messageReceiveWaitLock) {
try {
messageReceiveWaitLock.wait(timeout);
} catch (InterruptedException e) {
logger.info(e);
}
}
messageConsumer.setMessageListener(null);
}

private void doStop() throws JMSException {
messageConsumer.setMessageListener(null);
//queueConnection.stop();
synchronized (messageReceiveWaitLock) {
messageReceiveWaitLock.notify();
}
if (logger.isDebugEnabled()) {
logger.debug("Message receiving finished");
}

}

public Message receive(long timeout) {
try {
requiredMessages = 1;
if (receivedMessages.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("[pre-single] success jms receive calls [" + ++totalJmsMessageConsumed + "]");
}
return receivedMessages.remove(0);
}
doStart(timeout);
if (receivedMessages.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("[single] success jms receive calls [" + ++totalJmsMessageConsumed + "]");
}
return receivedMessages.remove(0);
}
return null;
} catch (JMSException e) {
logger.error("Error while starting message receiving", e);
return null;
}
}

public List receive(long timeout, int messageCount) {
try {
requiredMessages = messageCount;
doStart(timeout);
totalJmsMessageConsumed += receivedMessages.size();
if (logger.isDebugEnabled()) {
logger.debug("[count] success jms receive calls [" + totalJmsMessageConsumed + "]");
}
return receivedMessages;
} catch (JMSException e) {
logger.error("Error while starting message receiving", e);
return null;
}
}

public List receiveAll(long timeout) {
try {
requiredMessages = -1;
doStart(timeout);
return receivedMessages;
} catch (JMSException e) {
logger.error("Error while starting message receiving", e);
return null;
} finally {
try {
doStop();
} catch (JMSException e) {
logger.error("Error while stopping message receving", e);
}
}
}

public void closeConnection() {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++connectionCloseCount + "]Closing connection from queue [" + queue + "]");
}

try {
cacheIfExtraMessagesFetched();
try {
if(messageConsumer!= null){
messageConsumer.close();
}
} catch (JMSException e) {
logger.error("Error while stopping message receiver[consumer] ", e);
}
try {
if (queueSession != null) {
queueSession.close();
}
} catch (JMSException e) {
logger.error("Error while stopping message receiver[session] ", e);
}
queueConnection.close();
}catch (JMSException e) {
logger.error("Error while stopping message receiver[connection] ", e);
}
}

private void cacheIfExtraMessagesFetched() throws JMSException {
if (receivedMessages.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("Extra fetched message count is [" + receivedMessages.size() + "]");
}
String queueName = queue.getQueueName();
List queueMissed = missedMessages.get(queueName);
if (queueMissed == null) {
queueMissed = new ArrayList();
missedMessages.put(queueName, queueMissed);
}
while (receivedMessages.size() > 0) {
queueMissed.add(receivedMessages.remove(0));
}
}
}

private void receiveFromCacheIfExtraMessagesFetched(String queueName) throws JMSException {
List extraMessages = missedMessages.get(queueName);
if ( (extraMessages == null) || (extraMessages.size() == 0)) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Extra fetched message count [" + extraMessages.size() + "]");
}
while (extraMessages.size() > 0) {
receivedMessages.add(extraMessages.remove(0));
}
}

public synchronized void onMessage(Message message) {
try {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++totalJmsMessageReceived + "] Jms message received jms-correlation-id[" + message.getJMSCorrelationID() + "]");
}
receivedMessages.add(message);
message.acknowledge();
if (receivedMessages.size() >= requiredMessages) {
if (logger.isDebugEnabled()) {
logger.debug("all messages had been received ");
}
try {
doStop();
} catch (JMSException e) {
logger.error("Error while stopping message receiving", e);
}
try {
Thread.sleep(5);
} catch (InterruptedException e) {
//
}
}
} catch (JMSException e) {
logger.error("Error while acknowledging ", e);
}
}

public void setRECEIVE_ALL_TIMEOUT(int RECEIVE_ALL_TIMEOUT) {
this.RECEIVE_ALL_TIMEOUT = RECEIVE_ALL_TIMEOUT;
}


/* public static void main(String[] args) {
BasicConfigurator.configure();

// PropertyConfigurator propertyConfigurator = new PropertyConfigurator();
// Logger logger = Logger.getLogger("sample");
// LoggerRepository loggerRepository = new Hierarchy(logger);
// propertyConfigurator.doConfigure("log4j.properties", loggerRepository);

org.apache.activemq.ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
PooledConnectionFactory pool = new PooledConnectionFactory();
factory.setBrokerURL("failover://(tcp://localhost:61616?connectionTimeout=1000&soTimeout=1000&wireFormat.maxInactivityDuration=1000&wireFormat.tightEncodingEnabled=false)?initialReconnectDelay=100");
pool.setConnectionFactory(factory);






Thread thread1 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("recharge.subscriber.response"))); thread1.start();
Thread thread2 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("transfer.sender.agent.response"))); thread2.start();
Thread thread3 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("recharge.agent.response"))); thread3.start();
Thread thread4 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("sap.reversedeposit.sms.queue"))); thread4.start();
Thread thread5 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("transfer.receiver.agent.response"))); thread5.start();
Thread thread6 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("checkreloads.agent.response"))); thread6.start();
Thread thread7 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("changepin.agent.response"))); thread7.start();
Thread thread8 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("sap.deposit.sms.queue"))); thread8.start();

}

private static class MessageReceiver implements Runnable {
PooledConnectionFactory pool;
ActiveMQQueue activeMQQueue;
WaitLock waitLock;


private MessageReceiver(PooledConnectionFactory pool, ActiveMQQueue activeMQQueue) {
this.pool = pool;
this.activeMQQueue = activeMQQueue;
waitLock = new WaitLock();
}

public void run() {

for (int i =0; i < 100; i++) {
JMSQueueReceiverImpl listener = new JMSQueueReceiverImpl(pool, activeMQQueue);

for (int j =0; j < 20; j++) {
listener.receive(10);
}
listener.closeConnection();
try {
synchronized (waitLock) {
waitLock.wait(200);
}
} catch (InterruptedException e) {
e.printStackTrace(); //todo implement the method
}
}

}

private class WaitLock {
private WaitLock() {
}
}

}*/
}

We have used Jencks ActiveMQ connection pool here. You can download if from codehaus here.


, , ,

 

OpenXava - Easiest way to create DB driven websites in Java

If you are a someone interested in computer programming, at some point of time you may have created a DB driven website. If you have done that you may know how difficult it is to create even a small website. Even with code generation facilities provided by IDEs and ORM tools like Hibernate you have to do quite a lot to get your web app running.
This is where OpenXava (OX) comes in handy. It is really easy to create DB driven web app using this framework. With OX to create Db driven web app only thing you have to do is to define your business entities. Yes, that is the only thing you have to do, and OX will create you nice AJAX driven website with all CRUD operations implemented and also with reporting capabilities with PDF and Excel. It is amazing right....

How much time do you think will take to create above simple web app?, an hour... Actually it only took me 10 minutes to create it with all those features, what I did was implemented simple pojo class Customer and everything else was done by OX.
OX provides you lot of customization capabilities as well. So I think this is a good time saver tool.
Download OX from here and see for your self....
 

Wishing you a Very Happy New Year


Wish you all a very happy new year.
May all your dreams come true in this wonderful year....
 

2009 Sri Lankan Holidays List

Year 2008 has almost came to an end. This is the best time to get started to welcome new year. As with last year I created a List of Sri Lankan holidays, which you can add to Outlook, Thunderbird or Google calendar.

Outlook Holiday List

– – – – – – – – – Start Copy – – – – – – – – –
[Sri Lanka] 26
Duruthu Full Moon Poya Day(BPM),2009/1/10
Tamil Thai Pongal Day(BPM),2009/1/14
National Day(BPM),2009/2/4
Navam Full Moon Poya Day(BPM),2009/2/9
Mahasivarathri Day(BP),2009/2/23
Medin Full Moon Poya Day(BPM),2009/3/10
Milad-Un-Nabi (Holy Prophet’s Birthday)(BPM),2009/3/10
Bak Full Moon Poya Day(BPM),2009/4/9
Good Friday(BP),2009/4/10
Day Prior to Sinhala & Tamil New Year Day(BPM),2009/4/13
Sinhala & Tamil New Year Day(BPM),2009/4/14
May Day(BPM),2009/5/1
Vesak Full Moon Poya Day(BPM),2009/5/8
Day following Vesak Full Moon Poya Day(BPM),2009/5/9
Poson Full Moon Poya Day(BPM),2009/6/7
Esala Full Moon Poya Day(BPM),2009/7/6
Nikini Full Moon Poya Day(BPM),2009/8/5
Binara Full Moon Poya Day(BPM),2009/9/4
Id-Ul-Fitr (Ramazan Festival Day)(BP),2009/9/21
Vap Full Moon Poya Day(BPM),2009/10/3
Deepavali Festival Day(BP),2009/10/17
Il Full Moon Poya Day(BPM),2009/11/2
Id-Ul-Alha (Hadji Festival Day)(BP),2009/11/28
Unduvap Full Moon Poya Day(BPM),2009/12/1
Christmas Day(BPM),2009/12/25
Duruthu Full Moon Poya Day(BPM),2009/12/31
– – – – – – End Copy – – – – – – –

Please follow the instructions given in one of my previous posts to add holidays list to Outlook.
Note: If you have last year’s list under Sri Lanka you will need to replace it with this year’s ones


Google Calendar


Just click on the link to add the Holiday Calendar to your Google calendar.
http://www.google.com/calendar/render?cid=trbsm3c2ek1f1l3500qr4muejs@group.calendar.google.com


Thunderbird

In order to add calendar to Thunderbird you have to have Lightning add-on installed. Follow the instructions given here if you haven't installed Lightning yet.

After installation go to Calendar view. and select Calendar -> New Calendar from main menu. From the Create New Calendar window select >On the Network, click >Next, select >Google Calendar as the format and insert the following URL into the >Location field. http://www.google.com/calendar/ical/trbsm3c2ek1f1l3500qr4muejs%40group.calendar.google.com/public/basic.ics
Click >Next, eventually enter your Google >User Name and >Password and click >OK, >Name your calendar, give it a >Color, click >Next and finally >Finish to complete the procedure.


Hope this will help you.....
 

Solving Spring Schema not found issue

Few weeks back when we were testing a Mobicents application I came across a strange error from Spring.


Warning parsing XML: XML InputStream(68) schema_reference.4: Failed to
read schema document 'http://www.springframework.org/schema/beans/spring-beans-2.0.xsd',
because 1) could not find the document;
2) the document could not be read;
3) the root element of the document is not .


Application was working fine few hours before and I was wondering what could be the error. Later I found out that this error comes because I've unpluged the network cable, application worked fine when I plugged it back. It was seems to be that Spring is trying to download schemas from internet rather than using files in classpath. This was a serious issue because machines at production site do not have internet access.

After few hours of searching we found out that a way to tell spring to get schemas from class path rather than downloading. Just give classpath:schema location in Spring xml context file in the opening declaration instead of giving url http://www.springframework.org/schema/beans/spring-beans-2.5.xsd.


<beans schemalocation="http://www.springframework.org/schema/beans
classpath:org/springframework/beans/factory/xml/spring-beans-2.5.xsd"
xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">

</beans>
 

Extending Nautilus with Scripts

Nautilus is the default file browser we get with Gnome. Today I found out about wonderful feature of it. We can very easily extend Nautilus functionalities by adding our own custom scripts.  These scripts can be any executable file like shell script, python script or even C/C++ program.  You only have copy your scripts to
~/.gnome2/nautilus-scripts
We can get information such as current directory path, selected files using environmental variables set by Nautilus. Full set of variables are as follows.
  • NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -lists the paths of the currently selected files, separated by newlines. Works only on local filesystem.
  • NAUTILUS_SCRIPT_SELECTED_URIS - contains the URIs (file://file) of the selected files, separated by newlines. Works on both local and remote filesystems.
  • NAUTILUS_SCRIPT_CURRENT_URI - contains the URI of the current directory. Works for both local and remote filesystems.
  • NAUTILUS_SCRIPT_WINDOW_GEOMETRY -provides the window location and geometry of the browser window.
Nautilus also passes list of selected files as args to your script.  So we can use them to do what ever processing we want to do.

This is a simple script that will prompt all selected files in a message box.

#!/bin/bash
#Author: M.A.C.Sandarenu http://sandarenu.blogspot.com
for arg
do
fileList="${fileList}${arg}, "
done
zenity --info  --text="You have selected following file(s) ""$fileList"
 

CrossOver Rocks.....

I managed to grab a copy of CodeWeaver's CossOver software using their 28th October promotion campaign. For those who don't know about CodeWeaver, they are the people behind the FOSS project wine which enables users to run windows applicaiton on their Linux boxes. CrossOver is commercial counterpart of the wine. The gave away $70 worth CrossOver Professional version for free on 28 Oct as a pomotion.

I Installed Microsoft Office 2007 on my Fedora 9 box using CrossOver and it works fine. I managed to install Word, Excel and Powepoint, but had problems with installing Visio.

Unfortunately CodeWeaver's aren't going to do this kind of promotions in near future. So you'll have to use Wine if you didn't managed to grab a copy on 28th Oct.










 

I'm Back after some time.....

During last few days I was unable to do any blogging simply because I was too busy with my work at hSenid. I just started my first job at hSenid 1st of October and It was really wonderful. On the first day itself I was put in to a really challenging project. I had to learn lot of new technologies such as JSLEE, SMPP, JMS, JMX, AOP and so on...
I'd learnt lot of new things and I'll hopping to share with you all as I get some free time :)
 

HTML Signatures for Your Favorite Webmail Services

Today I got to know about wonderful Firefox add-on called WiseStamp. It allows you to add nice HTML signatures to popular webmail services like Gmail, Yahoo, Live mail and AOL mail. This was a add-on I waited for long time. Some time ago I used Greasemonkey script to add HTML signature for Gmail. Now with WiseStamp I can use common set of signatures for all my webmail accounts.

Give it a try, You'll love it.
 

7 Years of Excellence - Faculty of Information Technology, University of Moratuwa

[Press release from FIT anniversary celebration committee]
 
The Faculty of Information Technology (FIT), University of Moratuwa which was established in year 2001 is the only faculty of its kind, producing pioneers to the ever growing IT industry in Sri Lanka. With the rapid growth and expansion of the information technology, FIT provides immense service to the nation by creating highly skilled IT professionals to bridge the gap between the demand and supply of IT personnel in the industry.

Despite the lack of adequate resources, both physical and human, the Faculty commenced its academic activities with a batch of 47 students in 2002. Its first home was a rented facility at Borella. The intake was increased to 100 in 2005 in response to the steadily increasing demand by the IT industry and also to provide more opportunities in this field to the talented youth of the country.

Though a fledgling faculty, FIT started its first postgraduate program in IT in 2004 with the PG Diploma/M.Sc. in Information Technology. In August 2008, the Faculty launched another postgraduate program, the PG Diploma/M. Sc in Artificial Intelligence (AI). This is the first postgraduate programs of this kind in Sri Lanka. The faculty also conducts several professional development programs from time to time. The FIT will continue to develop and expand its academic programs, adapting to the ever-changing needs of the IT industry to become an entity which both the students and the industry would look up to.

A landmark in the faculty's march towards progress is the completion of the first phase of a new state of the art building complex at the University of Moratuwa premises in August 2008. To celebrate this occasion and 7 years of excellence in the field of IT education, the Faculty will hold a series of events comprising of a multi religious ceremony, a symposium and a cricket tournament, followed by an exhibition of student innovations.

An academic conference on the theme "Graduation, Entrepreneurship and Success", will be held on 27th September 2008 at the new faculty premises with the participation students, alumni, members of the staff and industry representatives. Lead by a distinguished panel of resource persons, this conference is intended to provide students with the opportunity to experience through role models and success stories, how they can make a success of their careers in many different ways after graduation. The objectives of this symposium can be further elaborated as:

  • To create a culture of entrepreneurship among the students.
  • To learn through the experience of accomplished entrepreneurs.
  • An opportunity for the students to interact with the industry leaders.
  • To create better awareness among the corporate community about the Faculty of IT.
  • To establish links with the industry to emphasize the value and recognition of the Faculty as a leading educational body.
  • To broaden the knowledge of students on new trends in the IT industry

Among the distinguished resource persons at this event will be Mr.W.K.H Wegapitiya, CEO of Laugfs Holdings Limited, Dr. Sanjiva Weerawarana, Chairman & CEO of WSO2, Mr. Mohamed Azmeer, CEO of ConceptNursery, Mr. Ramesh Shanmuganathan, Group's Chief Information Officer, John Keels Holdings, Mr. Harsha Purasinghe, CEO of Microimage (Pvt) Ltd and Peter De Almeida, CEO of e-nable (Pvt) Ltd.


The event will conclude with a get-together at which all students past and present, will come together to celebrate the inauguration of the Faculty's new home. They will be joined by the industry representatives to create an enthralling atmosphere of celebration and entertainment.
 

Error on launching Tomcat from Eclipse in Fedora 9

Last few days I was doing some self learning on Servlets and JSP.  After doing few examples using Text Editor, I wanted to see how to create dynamic website using Eclipse; my favourite IDE. I followed the instructions given in a article in IBM site. But when I try to start the Tomcat server from Eclipse I got an strange error.

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/logging/LogFactory



I didn't have a clue about this error. As usual Google save my day. I found this post regarding the same error by Greg Johnson.

In order to solve this problem you have to download the Apache commons 1.1.1 and copy commons-logging-api-1.1.1.jar to /usr/share/tomcat/bin folder.  After copping that jar I was able to start Tomcat from Eclipse without any issue.

Thanks Greg, you save my day :)
 

End of a Beginning....

graduate

It seems yesterday that I first walked into the university, yet 4 and 1/2 years have passed. Exams of my final semester at university finished yesterday :)

It was a wonderful 4 1/2 years at FIT. I take this moment to Thank all academic, non-academic staff and my batch mates at Faculty of Information Technology, University of Moratuwa for guidance and support they gave me during all these years.

Next step of my journey begins 1st of October as a Software Engineer at hSenid....

 

Firefox on Fedora - No sound on Flash Videos

I recently shifted to Fedora from Windows XP. In Fedora it did not give sounds when I was watching flash videos such as from YouTube in Firefox. It was a big problem for me. But after some research I found out that it is due to not installing a dependency library 'libflashsupport' with Adobe Flash plugin. Fixing this problem is very simple, just insall that library using yum.

yum install libflashsupport

After intalling it I got the sounds. :)
 

Reading Excel Date fields from Java

Previously I posted on how to read data from Microsoft Excel file using Apache POI HSSF. This is a small addition to that.

If the Excel file you are to read is using 'Date' fields, then you have to be little careful about it. In HSSF these Date fields are taken as numeric fields. Anyway that is how Dates are handled in Excel; it uses an Integer to keep number of days since 1900-Jan-0. Luckily the there is a small utility provided by HSSF to covert these Execl Dates to Java Date format. Just use HSSFDateUtil.getJavaDate(double) method.


//Date of Birth
HSSFRow row = sheet.getRow(ROW_C_DOB);
//Handle Excel Date type cells
HSSFCell cell = row.getCell(COLUMN_DATA);
if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
{
  Date d = HSSFDateUtil.getJavaDate(cell.getNumericCellValue());
  client.setBirthDay(d);
}
else
{
  String tmp =    row.getCell(COLUMN_DATA).getRichStringCellValue().toString();
  client.setBirthDay(Util.getDate(tmp)); 
} 
 

Getting Started with OpenCV

Finally our final year project is finished. As I've promised in my previous post I'm going to do few posts on OpenCV. In this post I'm going to tell you how to configure MS Visual Studio 2005 to work with OpenCV library. 

Step 1: Installiny OpenCV

First you have to download the OpenCV library from Sourceforge and run the installer. It will install OpenCV library on your computer. By default it will be installed to "C:\Program Files\OpenCV". Installer will add "C:\Program Files\OpenCV\bin" to system's PATH variable. But sometimes this do not happen properly. In such cases you'll have to add OpenCV bin directory manually to the system's PATH.

OpenCV installer

Download OpenCV: http://sourceforge.net/projects/opencvlibrary/

Step 2: Configuring VS 2005

In order to use OpenCv from VS you have to add libraries and header files to projects path. Create Win32 Console Application in VS 2005. Then right click the project form the Solution Explorer and select Properties.

project properties

Under "Configuration Properties -> C/C++ -> General" put following folders to "Additional Include Directories".

C:\Program Files\OpenCV\cxcore\include
C:\Program Files\OpenCV\cv\include\
C:\Program Files\OpenCV\cvaux\include
C:\Program Files\OpenCV\otherlibs\highgui

set include directories

Then under "Configuration Properties -> Linker -> Input" put following folders to "Additional Dependencies". Add them line by line with double quotes.

"C:\Program Files\OpenCV\lib\cv.lib"
"C:\Program Files\OpenCV\lib\cvaux.lib"
"C:\Program Files\OpenCV\lib\cxcore.lib"
"C:\Program Files\OpenCV\lib\highgui.lib"

set linker dependancies

Sometimes it is possible that you don't have above lib files in "C:\Program Files\OpenCV\lib" folder. In such situations you just have to compile the OpenCV solution.

It is also possible for you to get complains regarding corex100.dll (it can be corexXXX.dll) when running your OpenCV application. If you get such error build the OpenCV solution and check whether the "C:\Program Files\OpenCV\bin" folder is in your system PATH, if not you either have to add that to the path or copy all the DLLs in bin folder to C:\WINDOWS\SYSTEM32 folder.

opencv solution

So that basically what you have to do to configure VS2005. You can check whether you have configured the VS correctly by compiling and running some sample applications in the "C:\Program Files\OpenCV\samples\c" folder. So have fun with OpenCV.

 

Back to Firefox 2

It's being nearly a month or so I've started using Firefox 3 browser. Yes it has lot of cool new features such as new address bar. But I'm having a big problem with new FF3. It is giving me "Network Timeout Error" all the time.

FFtimeout

I have to do multiple refreshes to view the page, and if the page is having lost of images than those are also not loaded.  But when I checked the same site with IE, it loads the page correctly and without any issues.

When I searched the Google for this issue I found that FF3 is having some issue related to this Timeout problem. http://wiki.mozilla.org/Firefox3_Timeout_Problem

So until a fix is available I'm going back to good old FF2.

 

Gmail Provides Remote Sign Out and Tracking of Account Activities

If you are using Gmail this may the security feature that you were looking for ages... Now Google let you monitor your account activities and Sign out remotely. This is very good news for people like me because I access gmail from multiple computers, including from the computers at university labs.  Read more about this from

Gmail Blog >>>

gmail_Remote_Signout1

gmail_Remote_Signout2
 

All-in-One Media Converter

 FormatFactory is a free application that can convert video, audio and images in to different file formats. It also supports batch file conversion as well. As reported by DownloadSquad is seems to be really good application. FormatFactory