Boost security by disabling 10 Windows XP services

I came across this article at TechRepublic few days back about few windows services that we can disable and boost the security of our computers. Following are the services that you can disable without any problem.

  • ISS
  • NetMeeting Remote Desktop Sharing
  • Remote Desktop Help Session Manager
  • Remote Registry
  • Routing and Remote Access
  • Simple File Sharing
  • SSDP Discovery Service
  • Telnet
  • Universal Plug and Play Device Host
  • Windows Messenger Service

Some of these services may not even installed in your machine, specially some thing like ISS. Better check the services running in you machine and disable unnecessary ones. It can help you in two ways, one is that it will boost the security and other thing is that it will save your system resources  to do some thing useful.

To see list of all the services running in you machine go to Control Panel > Administrative Tools > Services

You can find the original article here >>

Technorati Tags: ,
 

Back to the University

graduate3

 

 

 

 

 

 

 

 

Tomorrow(19th Nov) our new academic semester begins. It will be the start of my 4th year at the university. Two months of vacation seems to be vanished. Two months of vacation was very nice one. I managed to learn lots of new things during that time, and spend lot of time with my family.

Now I'm doing the IT special degree so next few months will be very busy. Road ahead will be more difficult but will be very exciting. I'm hopping to do well in this semester.

 

Reading Excel Files from Java

Microsoft Excel is one of the common was of storing data in business. There fore when we develop applications, most of the times we have to extract data from an Excel sheet. There are many methods to extract data from Excel file, both commercial and free libraries are developed for this purpose. One of such library is Apache POI HSSF.

I came across this library few weeks back when I was researching on a methods of reading data from Excel and load it to a Java application that we are developing.  The project I'm working on is a development of Retirement Planning System, which our client is going to use for consultation purposes. He wanted to give his clients an Excel template where they put their current financial information such as incomes, expenses and our software should be able to read that file and load that data for projection purposes.

Apache POI provides good API to access Excel files, not only reading but writing as well. Here I'm only using reading functionality only. When we are panning to use Excel as data input method first thing is to develop good template with all required field. This is the sample Excel file I used in my testing.

incomes 

 

 

 

When reading the data we are reading from cell by cell, so we have to know the exact cell that contains the data we need. I'm using a common interface to read data from Excel sheet.  According to our requirement we can implement that to read data in to our java objects.

public interface RowProcessor
{
public Object[] process(HSSFSheet sheet) throws Exception;
}


Here we are passing the excel sheet to our process method and get set of objects after processing it. By implementing this interface I created a class called IncomeProcessor to read the Excel sheet and get an array of Income.



public class IncomeProcessor implements RowProcessor
{
//Row columns
private static final short COLUMN_NAME = 1;
private static final short COLUMN_OWNER = 2;
private static final short COLUMN_AMOUNT = 3;
private static final short COLUMN_INCREASE_RATE = 4;
/**
* The singleton instance of this class.
*/
private static IncomeProcessor thisProcessor;

/**
* Default constructor
* Created on: Nov 8, 2007
* @Author: Sandarenu
*/
private IncomeProcessor()
{
//Private so no outside instantiation
}

/**
* Get an instance of this row processor.
* Created on: Nov 8, 2007
* @Author Sandarenu
* @return instance of this row processor.
*/
public static RowProcessor getInstance()
{
if(thisProcessor == null)
{
thisProcessor = new IncomeProcessor();
}
return thisProcessor;
}

/**
* Do required processing for the Incomes.
*/
public Object[] process(HSSFSheet sheet) throws Exception
{
if(sheet != null)
{
int first = sheet.getFirstRowNum();
int last = sheet.getLastRowNum();
HSSFRow row = null;
List<Income> incomeList = new ArrayList<Income>(5);
Income income = null;
String owner;
first += 2; //Ignore first 2 rows - they are headers
for(int i= first; i<=last; i++)
{
row = sheet.getRow(i);
if(row != null && row.getCell(COLUMN_NAME) != null)
{
income = new Income();
income.setName(row.getCell(COLUMN_NAME).getRichStringCellValue().getString());
income.setStartingValue(row.getCell(COLUMN_AMOUNT).getNumericCellValue());
income.setIncreaseRate((float)row.getCell(COLUMN_INCREASE_RATE).getNumericCellValue());
owner = row.getCell(COLUMN_OWNER).getRichStringCellValue().getString();
if(owner.startsWith("C")|| owner.startsWith("c"))
income.setClientPercentage(100);
else if(owner.startsWith("S")|| owner.startsWith("s"))
income.setSpousePercentage(100);

incomeList.add(income);
}
}

return incomeList.toArray(new Income[incomeList.size()]);
}

return null;
}

}




This is the main class I used to test my data reading. Here first I read the excel file and then get relevant Sheet for processing. Using this technique we can easily populate our java objects using the data from Excel sheet.  



public class Test {

/**
* @param args
*/
public static void main(String[] args)
{
TestListner tl = new TestListner();
ImportHandler ih = new ImportHandler();
ih.addStatusListner(tl);

try {
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream("Book1.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);


HSSFSheet sheet =wb.getSheet("Income");
RowProcessor ip = IncomeProcessor.getInstance();
Object [] incomes = ip.process(sheet);
for (Object object : incomes)
{
Income income = (Income)object;
System.out.println( income.getName() + " " + income.getStartingValue());
}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

}


Output of the code.



output



 



 



 



You can download complete source code and sample Excel workbook here.




 

Windows Live Writer for Creating blog posts

I have downloaded Windows Live Writer to see whether I can use it to publish blog posts in my blog. I think it is working fine, and I'm planing to continue using this for my next blog posts. WLW is having number of plug ins to support blog editing. One of the most important plug in is Source Code Format plug in.

 

Displaying Background Image in Swing Components

This is a wonderful way to add background images to Java swing components. We can you this method to add background images for almost all of the swing components. To add image we have to override paintComponent() method.

Eg 1: Add background image to JTextArea
JTextArea textArea = new JTextArea() {
ImageIcon backImage = new ImageIcon("Resources/Background.jpg");
Image image = backImage.getImage();
{setOpaque(false);}
//Override
public void paintComponent (Graphics g) {
g.drawImage(image, 0, 0, this);
super.paintComponent(g);
}
};


Eg 2: Add background image to JDesktopPane

JDesktopPane textArea = new JDesktopPane() {
ImageIcon backImage = new ImageIcon("Resources/Background.jpg");
Image image = backImage.getImage();
{setOpaque(false);}
//Override
public void paintComponent (Graphics g) {
g.drawImage(image, 0, 0, this);
super.paintComponent(g);
}
};

We can use this method to add background images to any Swing component.
 

Multi Table Delete Error in MySQL

Today I was trying to write some SQL scripts to delete data from MYSQL database. And it uses INNER JOIN to join two tables for the delete. My query looked like follows.

DELETE fpsdb.future_changes.* FROM fpsdb.future_changes fc INNER JOIN fpsdb.income a ON a.Income_ID = fc.Dependancy_ID WHERE a.client_ID = 1;

When I try to execute, it gave the error "Unknown table 'future_changes' in MULTI DELETE"

I tried every thing to find the error without any success. Then I google for this error. Then I found out about an MySQL bug related to this issue. It states that "Cross-database deletes are supported for multiple-table deletes, but in this case, you
must refer to the tables without using aliases."

So I changed the query removing aliases and put full qualified table names everywhere.

DELETE fpsdb.future_changes.* FROM fpsdb.future_changes INNER JOIN fpsdb.income ON fpsdb.income.Income_ID = fpsdb.future_changes.Dependancy_ID WHERE fpsdb.income.client_ID = 1;

And Then it worked..... :)

 

Java Reporting With MS Word - Part 2

Few weeks back I did a post on how to create reports using Microsoft Word and Java. That method was based on Microsoft Office XML schema. We just have to create XML document using the tags defined in that schema. Yes it creates nice reports, but it needs lot of effort right.... You have to put lot of effort to create even very small report. When number of formatings in the report increases it becomes more and more difficult. Other main issue is you can't insert images.

I did more research on how to creates reports that can be viewed from Word with less effort. And then I just thought about Rich Text Format. We can view rtf documents from MS Word. After Googling for some time I found about iText. I knew it is used to create PDF documents, but until that morment I didn't knew that it can creates rtf documents as well. So that is the solution..... Create the report using iText.

We can create rtf documents with nice formating with less effort. You can find good tutorial on how to create rtf documents using iText here.
 

Advices from Steve Jobs to Our Lives

















Few days back I got an email from one of my friend which contained the Steve Jobs' Commencement address at Stanford University in year 2005. I know now it is fairly old thing, but I thought to share it with all of you because that speech has lot of advises that we can adopt in to our life.

It contains how he faced the challenges in his life and overcome them successfully. It is a very nice speech that you must read.

Download the speech >>
 

Java Reporting With MS Word

Isn't it wonderful if we can generate MS Word documents as reports from our Java application.... There are number of way to generate MS Word documents from Java such as using Jakarta POI (Poor Obfuscation Implementation) from the Apache Jakarta Project.
But there is a much easier way to do it, by using WordprocessingML. It is an XML schema developed my Microsoft to create word documents and their formating. Using the XML tags in WordprocessingML we can create our word document very easily.
Here is a small code fragment that displays "Hello World"...

<?xml version="1.0"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<w:body>
<w:p>
<w:r>
<w:t>Hello World.</w:t>
</w:r>
</w:p>
</w:body>
</w:wordDocument>

Save this as .xml and open using MS word. You will be able to see output like in this figure.















Lets analyze important tags in the code.
  • <?mso-application progid="Word.Document"?> is a processing instruction that tells Windows to treat this XML file as a Word document. You must put it in the document for it to be recognized by Word and Windows. The text-related elements for WordprocessingML have the prefix w.
  • <wordDocument/> defines a Word document. You can see that w's namespace is defined here.
  • <body> is a container for text in the document.
  • <p> defines a paragraph.
  • <r> defines a run of other elements. Inside this tag, you should place tags like <t>, <br>, and so on. All elements inside a <r> element can have a common set of properties.
  • <t> is the element that encloses actual text.
You can find the complete Office 2003 XML Reference Schemas from the Microsoft web site.
http://www.microsoft.com/downloads/details.aspx?familyid=fe118952-3547-420a-a412-00a2662442d9&displaylang=en

Now you know the basics of WordprocessingML. Next thing to do is to use some king of XML library and generate the XML document according to WordprocessingML Reference Schema. Here I'm using dom4j XML library.



import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.QName;

/**
* @author sandarenu
*
*/
public class WordMLTest
{
/**
* Create the xml for head part of the word xml
* Add processing and schema info.
* Created on: Jun 23, 2007
* @Author sandarenu
* @return
*/
public static Document createDocument()
{
Document doc = DocumentHelper.createDocument();
HashMap pmap = new HashMap();
pmap.put("progid","Word.Document");
doc.addProcessingInstruction("mso-application",pmap);

Element root = DocumentHelper.createElement("w:wordDocument");
//Set up the necesary namespaces
root.setQName(new QName("wordDocument",new Namespace("w","http://schemas.microsoft.com/office/word/2003/wordml")));

Element e2 = DocumentHelper.createElement("w:body");
Element e = DocumentHelper.createElement("w:p");
Element e1 = DocumentHelper.createElement("w:r");
Element e3 = DocumentHelper.createElement("w:t");

root.add(e2);
doc.add(root);
e3.setText("Hello World");
e1.add(e3);
e.add(e1);
e2.add(e);

return doc;
}

/**
* Created on: Sep 29, 2007
* @Author sandarenu
* @param args
*/
public static void main(String[] args)
{
try
{
Document doc = createDocument();
File outputFile = new File("c:\\hello.xml");
FileWriter out = new FileWriter(outputFile);
doc.write(out);
out.flush();
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}

}

}

Using this simple logic you can generate very complex word reports using Java. Have fun....

You can download the source code.

 

One Stop for Keyboard Shortcuts........

Are you using keyboard shortcuts when using applications? If not you better start using them because they can save lot of time and make the work much easy.
In one of my previous posts I've put some shortcuts that you can use with Windows key. Today I found a wonderful website that contains huge list of shortcuts for various applications. It's called KeyXL. Hope you'll find it very useful.
 

I'm Back...

It has been more than 1 1/2 months since I've done my previous post. It has been very tough time for me with all of the academic activities in the university. Last semester was the toughest semester yet. Had to complete back to back assignments without break ant then had to prepare for the exam. Now it’s all finished.
With this exam our general degree finishes. But I’m planning to do the special as well, so I’ve another year to go before finishing. There is going to be two months break before start of 4th year. So I can have little bit of break and do few more blog posts :)

 

Got the Last one...

Guess what..... I got the last book, Harry Potter and Deathly Hallows.

It took me around 6 hours to read through 607 pages of true magic. I have to admit that I skip through some pages (got to read the book again). I was so anxious to find out what will happen at the endJ.K had stated that 2 main charters would die at the end; I always feared that one would be from the trio, Harry, Ron or Hermione. But I was wrong. It had a much better ending that expected. Snape proved to be a good guy; Harry defeats the dark Load.Finally Harry-Ginny and Ron-Hermione got married and J.K. finished the great magical story with “All was well”.

 

The Two F-Words You Should Love

This is a very nice article I saw at lifehack.org. Hope it will be useful to you.....


Lincoln


Make Failure and Frustration Your Friends: A History Lesson

We all experience failure and the subsequent frustration. But how you handle those tormentors makes all the difference in your final outcomes. Oftentimes the peak of frustration comes right before a major breakthrough. That's if you don't quit. So don't quit! Instead use the energy behind that frustration to break through to a new level of strategy. Make failure the friend that brought you to breakthrough's doorstep! Let frustration be the energy that propels your leap across the chasm!

What follows are several success stories from history where failure was a frequent companion throughout these great people's lives. Let's all take some inspiration from their stories.

Read the complete article >>>



 

FIT wins Imagine Cup again.....

It was an unbelievable atmosphere yesterday at Galadari Colombo as FIT guys and gals won the Imagine Cup Sri Lanka Competition for the 3rd Consecrative time. Yeh!.. that's right it was for the 3rd Consecrative time that FIT won this most prestiges software competition in Sri Lanka.
This time it was team "SARA" presenting the Application "ISECED", who did the magic for our faculty. And again it was the same wining combination as last 2 yeas, one girl and 3 guys;"Ruwindi", "Sanju","Amila", and "Anurudha".

They will fly to S.Korea to participate for the Imagine Cup 2007 global competition soon.
Good luck team and congratulations.

There is more good news, in addition to the championship FIT won the 2nd runners up as well. That was team Team "Sanhitha" presenting the application "Irrdhipada" who did that.

Congratulations to them as well.
And also there was one more team team from Faculty of Information Technology who participated for this year finals, team "Rawana" presenting the application "Virtual Desk". Even though they couldn't make it to the top 3 teams they also gave a good fight and there application was wonderful.


Congregational to Rawana as well.
 

Good Bye Navantis.....

Last week I said good bye to Navantis.
It was a very difficult decision to be made, but I had to do that since I have to put my full effort for my academics. My nine month experience at Navantis was great. I learn a lot during my internship and part time period.
I'd like to thank all my colleagues at Navantis who helped me a lot during last nine months. Especially CEO Indaka, Duneel and Irzana.

 

How to use the Windows key....


Are you using the Windows Key in your keyboard? It comes very handy on occasions. Followings are some few useful short cuts that can be used with Windows key.

W = Windows Key

W: Opens Start Menu
W+ E: Opens up Windows Explorer
W+ R: Opens the Run command.
W+ U: Opens Utility Manager
W+ L: Log Off
W+ F: Search files on your computer
W+ D: Show Desktop [will switch back and forth from all minimized and back again]
W+ F1: Help Menu
W+ Pause/Break: System Properties
W + Ctrl + Tab: Cycles through Tabs in your current app [eg. Firefox’s last focused tabs]
W+ Tab: Cycles Through Buttons in Taskbar
W+ M: Minimize all open windows.
W+ Shift+M: Maximize the windows you had open before minimizing
W+B: Set focus to the first System Tray Icon [which is the arrow if you enable the Hide Inactive Icons option]
CTRL+W +F: Search for computers

 

Debugging SQL Server Stored Procedures

Did you know that we can debug SQL Server Stored Procedures....
Yes we can debug SPs from Visual Studio. We can put break points, can execute statement by statement and much more...


Read this article for more >>

 

How to create easy-to-use Outlook e-mail templates?

Do you usually send same type of outlook email message over and over again with just small changes to the content? So how do you do that? Type same thing all the time or copy and paste content from old message? I think most of the times you are using the copy and paste method. I also did the same thing till I found out how to create email templates in Outlook.
With few simple steps we can create a menu of email templates in outlook. So you never have to find old message, copy-paste-edit. Just select from the mail templates menu edit and send.

If you have configured outlook to use Word as default email editor you have to change that temporally. You have to use outlook email editor to create the templates. To do that;
1. Go to Tools | Options and click the Mail Format tab.
2. De select the Use Microsoft Word To Edit E-mail Messages check box (Figure A) and click OK.


To switch back to using Word as your editor, just go back to the Mail Format tab and reselect that option.

Creating Email Templates

Create a new email message as normally we do. Enter the text into the body of the message. If the message template will contain the same words in the subject line, fill in the Subject field as well. You can also fill in the To, Cc, and Bcc fields with addresses if you will always be sending the
message to some of the same people. After finishing it, go to File | Save As to open the Save As dialog box and choose Outlook Template (*.oft) from the Save As Type drop-down list.


Close new message window.(Click no when asked to save changes)

Creating the Menu

To create the menu, right-click on an Outlook tool bar and choose Customize from the shortcut menu to open the dialog box.


Now, click on the Commands tab, scroll to the bottom of the Categories list box, and choose New Menu. The New Menu item will appear in the Commands list box.


Drag the New Menu item to the Menu bar where you want menu to appear. Once the New Menu item appears on the Menu bar, right-click on the item and Replace the default name in the Name field with E-mail Templates and press [Enter].



Adding Templates to the Menu

To add your template as menu item to the newly created menu, from Customize dialog box, choose File from the Categories list box. Then, select Mail Message from the Commands list box and drag it to the E-mail Templates menu. When the menu opens, drop the Mail Message item on it.


Right-click on the item and replace the default Name field entry with the name of one of your templates. Then, click Assign Hyper link at the bottom of the menu and select the Open command. In the Assign Hyper link: Open dialog box, locate and select your template file and click OK.



Just repeat these steps to add any other templates you want on the menu. When you're finished, close the Customize dialog box. Now, anytime you need to compose an e-mail message that will include a specific version of email text, pull down the E-mail Templates menu and select the appropriate template.

Technorati Tags:
 

How to Say NO....

How hard it is to say no to someone?... For me it is a very difficult thing. How about you? I think most of you also have the same problem.
Today I came across a nice article on Lifehack.org on "The Gentle Art of Saying No". It explains 10 tips on how to say no.
  1. Value your time. Know your commitments, and how valuable your precious time is. Then, when someone asks you to dedicate some of your time to a new commitment, you’ll know that you simply cannot do it. And tell them that: “I just can’t right now … my plate is overloaded as it is.”
  2. Know your priorities. Even if you do have some extra time (which for many of us is rare), is this new commitment really the way you want to spend that time? For myself, I know that more commitments means less time with my wife and kids, who are more important to me than anything.
  3. Practice saying no. Practice makes perfect. Saying “no” as often as you can is a great way to get better at it and more comfortable with saying the word. And sometimes, repeating the word is the only way to get a message through to extremely persistent people. When they keep insisting, just keep saying no. Eventually, they’ll get the message.
  4. Don’t apologize. A common way to start out is “I’m sorry but …” as people think that it sounds more polite. While politeness is important, apologizing just makes it sound weaker. You need to be firm, and unapologetic about guarding your time.
  5. Stop being nice. Again, it’s important to be polite, but being nice by saying yes all the time only hurts you. When you make it easy for people to grab your time (or money), they will continue to do it. But if you erect a wall, they will look for easier targets. Show them that your time is well guarded by being firm and turning down as many requests (that are not on your top priority list) as possible.
  6. Say no to your boss. Sometimes we feel that we have to say yes to our boss — they’re our boss, right? And if we say “no” then we look like we can’t handle the work — at least, that’s the common reasoning. But in fact, it’s the opposite — explain to your boss that by taking on too many commitments, you are weakening your productivity and jeopardizing your existing commitments. If your boss insists that you take on the project, go over your project or task list and ask him/her to re-prioritize, explaining that there’s only so much you can take on at one time.
  7. Pre-empting. It’s often much easier to pre-empt requests than to say “no” to them after the request has been made. If you know that requests are likely to be made, perhaps in a meeting, just say to everyone as soon as you come into the meeting, “Look guys, just to let you know, my week is booked full with some urgent projects and I won’t be able to take on any new requests.”
  8. Get back to you. Instead of providing an answer then and there, it’s often better to tell the person you’ll give their request some thought and get back to them. This will allow you to give it some consideration, and check your commitments and priorities. Then, if you can’t take on the request, simply tell them: “After giving this some thought, and checking my commitments, I won’t be able to accommodate the request at this time.” At least you gave it some consideration.
  9. Maybe later. If this is an option that you’d like to keep open, instead of just shutting the door on the person, it’s often better to just say, “This sounds like an interesting opportunity, but I just don’t have the time at the moment. Perhaps you could check back with me in [give a time frame].” Next time, when they check back with you, you might have some free time on your hands.
  10. It’s not you, it’s me. This classic dating rejection can work in other situations. Don’t be insincere about it, though. Often the person or project is a good one, but it’s just not right for you, at least not at this time. Simply say so — you can compliment the idea, the project, the person, the organization … but say that it’s not the right fit, or it’s not what you’re looking for at this time. Only say this if it’s true — people can sense insincerity.
 

Famous Quotes from Steve Jobs


From the recent challenge on DRM, to the iPhone hype from his presentation, and the popular iPod madness, we know Steve Jobs is a marketing genius. But that’s not the only it, he has his own view of what’s successful and the view of leadership and career. Ririan Project selected 10 quotes from Steve Jobs and describe them in details how you can learn Jobs’ way to be successful:
  • “Innovation distinguishes between a leader and a follower.”
  • “Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.
  • “The only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it.”
  • “You know, we don’t grow most of the food we eat. We wear clothes other people make. We speak a language that other people developed. We use a mathematics that other people evolved… I mean, we’re constantly taking things. It’s a wonderful, ecstatic feeling to create something that puts it back in the pool of human experience and knowledge.”
  • “There’s a phrase in Buddhism, ‘Beginner’s mind.’ It’s wonderful to have a beginner’s mind.”
  • “We think basically you watch television to turn your brain off, and you work on your computer when you want to turn your brain on.”
  • “I’m the only person I know that’s lost a quarter of a billion dollars in one year…. It’s very character-building.”
  • “I would trade all of my technology for an afternoon with Socrates.”
  • “We’re here to put a dent in the universe. Otherwise why else even be here?”
  • “Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma - which is living with the results of other people’s thinking. Don’t let the noise of other’s opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.”
Technorati Tags: