Tuesday, June 9, 2009

what is DIGSBY

Since I have couple of accounts in various community sites and in the mail servers I had a problem of sing in to all those accounts and check whether there are any mails have dropped for me or there are any updates in my profile. But now I found a solution to that which helps me to get all the notifications of the mails and the accounts. It is the DIGSBY software which can be download it from here.

You can enter your account passwords in to this software and when you connect to the internet it automatically give you the updates of your accounts. So try it. It will make your works easy.

Thursday, May 28, 2009

How to add a Statcounter to your blog

Hi friends. Do you know how to insert a gadget to your blog to keep track of the visitors who visited to your blog. There are lots of web sites which are offers this facility freely.

statcounter.com is a good web site for that. You can make your own account in that and after that you can choose the gadget which is suitable for your blog. Then add a html/JSP gadget in your blog and past the code provided by the website on that. It will make nice tool on your blog which shows you the number of visitors. Try it………


There is another website which will give you a visitor counter freely. It is FlagCounter. Try it and get the new gadget ….

Saturday, May 16, 2009

My mini project on search engine

I’m at my level two-semester two of my university life. Last month I was very busy after my new year vacation because I had to implement a search engine for Algorithm subject which was conducted by Madam Upuli and Sir Saliya.

We had taught several types of algorithms and data structures before this project and we had to apply those things when implementing that.

The search engine works like this. Initially we have to input the root path of the folder which we are going to search. Then the search engine should search all the files within that folder as well as the subfolders. Then it should read all the words in text files and store the words and the corresponding file paths in a suitable data structure. After finishing the storing the search engine is ready for search. Then the user can input a word alone or multiple words using & and | operations for search. then the search engine should return the corresponding file paths as the output.

At the beginning the task was not easy to achieve because I didn’t even knew how to differentiate text files and directories. So I had to work hard to fulfill this task.

I choose java to implement the search engine and these are my classes

I implemented my own vector class which have method

putValue( String data)-store data

getvalue(int index)-get the value according to the index

appendValue(String data)- append data to an existing row

to do this I had to implement an dynamic array.


This is the code for creating a dynamic array which is send by one of my friends.

1)first create a fixed array(say array[100]).

2)write a logical condition in the code, if the fixed array is full , create a new array(say tempArray) with a greater size (you can increment the fixed array size with some value).

3)then use the following method to copy the object references in the fist array to the new one.

System.arraycopy(,0,,0,) // here two zeros are to specify beginning position.

4)then make the new one referenced by the fist array name.
ex: array=tempArray;

Then I used the vector class to implement the hash table class. This has methods called

insertWord(String skey,String data)-insert the word and the path to the hash table

getData(String searchKey)-get the path of the word

checkData(String path,String data)- check the existence of the word before storing it.

In this class we use a 2D object array of vectors and after we pass the word and the path to the HashTable it converts the word to a hash value by using the inbuilt method hashCode(). Then calculate the key by

key=hashvalue%100

and key is the row of the object array. Then the class search the pre existence of that hash value in that vector and if not store the hashcode in the first column and store the path in the second column. If the hash value is already exists in that vector it appends the path of the word to the existing path.

Then the most interesting part was the searching the files in folders. And I used fileFilters to Identify the folders and the files in an given root folder.

A link for learn fileFilter

I used all these tools and finished my project successfully. I hope you can use try this so you can improve your programming skills. Keep cording ,it will train you to be an outstanding coder.

XML

Why people prefer XML

XML stands for Extensible Markup Language and that was design to transfer and store data. But we can display data in XML by using style sheets (CSS, XSLT). Not like in HTML the tags are not predefined in XML and you must define your own tags as you wish.

Ex:

                                                                                                                                                                                                            

 A good programming practice is naming tags related to the information it carries, so another developer can easily identify tags.

Another huge advantage is easy to work with data bases and computer systems. In other cases they sore data in data bases as incompatible types. But XML stores data in text format and it makes easy when storing because format is independent by software and hardware variations. The data in Xml files are send using XML DOM (Document Object Model) objects.

Try to learn XML. It will reduce your stuff. 

This is a great tuutorial for beginers. http://www.w3schools.com/xml/xml_whatis.asp

Funny programs

Before six months ago one of my friends came to ask some basic things in java from me. I taught him some basic things on functions and loops and I showed him how to print a triangle from stars like this.



Then I asked him that can you write a code which gives an output like this, and I went to bring a cup of tea.


When I came back he showed me the code which wrote from bottom to top.