RMS and Philosophy of Free Software

rms

Last Friday I got once in a life time opportunity to participate in a conference where Richard Stallman (RMS) did the key note speech.  If you do not know who is RMS, he is the father of "Free Software Foundation" and he is the one who started GNU project. He is a really interesting guy.

From that key note speech I got to know about four freedoms related to free software.

0. The freedom to run the program as you wish.

1. The freedom to study the program's source code and then change it so the program does what you wish.

2. The freedom to distribute exact copies to others, when you wish.

3. The freedom to distribute copies of your modified versions to others, when you wish.

Other than that I learnt that it is note fair name popular open source OS "Linux" as "Linux". It has to be corrected GNU/Linux since Linux is only the kernel where GNU project developed all other components required for the OS.  

 

ZOTERO, Ultimate Research Tool for Students

As students we have to do lot of research on various subjects. when we go researching stuff in the Internet, sometimes it can be very difficult to keep up with the information we come across and keep them organized. Before I came across this wonderful tool Zotero what I did was save all important  web pages, PDF documents, etc... in one folder and later open one by one and read them. When I'm writing a report on something this opening one by one and reading it can be really annoying.

But with Zotero all this can be done very easily. This Firefox extension can keep everything very organized. Zotero can save files, PDFs, images, links, and snapshots of web pages along with the citation.

Here are some of the other features that Zotero has to offer:

  • Automatic capture of citation information from web pages
  • Storage of PDFs, files, images, links, and whole web pages
  • Flexible notetaking with autosave
  • Fast, as-you-type search through your materials
  • Playlist-like library organization, including saved searches (smart collections) and tags
  • Platform for new forms of digital research that can be extended with other web tools and services
  • Runs right in your web browser
  • Formatted citation export (style list to grow rapidly)
  • Free and open source
  • Shared collections
  • Remote library backup
  • Integration with Microsoft Word and other word processors
  • Access your library from anywhere via the web
  • Advanced search and data mining tools
  • Recommendation engine and RSS feeds
  • Wide variety of import/export options

zotero

 

Eclipse's Local History Saved Me ...

Today while I was working on our "Financial Planing System" project I replaced one simple code fragment throughout the project. That ruined how the application works. Since I've changed nearly 20 source files correcting would have been a nightmare.

But fortunately, Eclipse is keeping track of the local changes done to source file. Because of that I've been able to replace the changes I did using that.

select

You can compare the changes you have done very easily.

LocalHistory_Compair 

This is a really cool feature to have, specially if you are not using source control system. Even with source control local history can be very useful.

 

Happy New Year 2008

 

HappyNewYear

Wish You all a Very Happy New Year.....

 

2008 Sri Lankan Holiday List

There is only few days for the dawn of the new year, 2008. It is time to get organized for the new year. As with last year I thought of creating a Sri Lankan holiday list.

Outlook Holiday List

– – – – – – – – – Start Copy – – – – – – – – –

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

– – – – – – End Copy – – – – – – –

Please follow the instructions given in my last post to add holiday list to outlook. Note that if you have last year’s list under Sri Lanka you will need to replace it with this year’s ones

Google Calendar

Click on the button to add the Holiday Calendar to your Google calendar.

 

Defragment your Hard disk with Defraggler

Defraggler is a cool utility that lets you to defragment your hard drive. If you have used windows defragmenter, I think you know that it requires at least 15% of free disk space to perform defragmenting of the drive. Some times this can be very annoying. Specially for me this is very annoying since my C drive is only 10GB and it fills up very quickly and  can't even defragment since it do not have 15% free space.

Defraggler is the solution for this. This little tool allows you to defragment your hard drive with out any restriction of free disk space. Unlike default windows defragmenter this nice tool facilitates you to defragment individual files as well. Another cool thing about Defraggler is that it is portable, means that you can run it on an USB.

defrag1

 

Imagine Cup 2008 Launch at University of Moratuwa

Yesterday 12th December we had a grand event at the university for the launch of the Imagine Cup 2008 competition. Event was organized by the Microsoft Student Champs community at the Faculty of Information Technology.

ic2008_1 Event was not only about the Imagine Cup, there was the launch of the sourceFEED - which is the new online resource center developed by student champs. SourceFEED was a long requested thing by the faculty students, it provided access to lot of online learning material and Microsoft latest software products that the faculty get through MSDNAA. Launch of the sourceFEED was done by the university vice chancellor.

After the launch of the sourceFEED we had the launch of the Imagine Cup 2008. This is the 4th time that IC is happening in Sri Lanka. During last 3 years the competition was won by students from FIT. This year also our students are ready to give a big challenge to other IT institutes around the county to bring the cup for the 4th consecutive time.

We had a introductory presentation about the IC 2008 by Wela, who is the Microsoft Developer Evangelist. And then we had 2 brief technical sessions on building WPF applications   and another one on Silvelight applications. I did the presentation on building WPF applications using VS2008 and Expression Blend. It was a very introductory session about WPF, XAML and Blend. You can view the presentation I did here in Google presentations. Wela did the presentation on Silverlight.

Technorati Tags:
 

View passwords under the asterisks in your browser

Have you ever used remember the password option in you browser and later forget that password. If you want to see what the password you typed there is small trick that can be used. Simply type this JavaScript in the address bar of your browser.

javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no passwords in forms on this page.");})();

You can find a full explanation at the Raymond.CC Blog.

 

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”.