Tuesday, March 23, 2010

Do you need a simple tool to count the lines of code




Use cloc - http://cloc.sourceforge.net/

Its so simple to generate the lines of code of your project. Above shows an output of the current project I'm working on.

Sunday, January 17, 2010

URL Shortners

When your tweeting, you might need to shorten some lengthy URLs. Here are some important URL shortners.

1. http://is.gd/
2. http://migre.me/
3. http://miud.in/

Monday, January 11, 2010

How to get a Blogspot RSS url

Simply add this to the end of your blogger ( blogspot ) address: /atom.xml

Example:
If we need to get RSS URL of my blogger: http://thilina-anjitha.blogspot.com

My RSS url will then be : http://thilina-anjitha.blogspot.com/atom.xml


Thursday, December 17, 2009

Wednesday, October 21, 2009

Filled your hard disk with Mysql binary logs

When I'm running a program, I saw an error message "java.io.IOException: No space left on device". I wonder how I don't have enough hard disk space, because at the same day I cleaned 2GB. Then I just think about what are the things I have done during this period to kill my hard disk. I only ran sample SQL scripts to check the MySQL Horizontal partitioning feature as mentioned in my previous post. It inserts 8,000,000 X 2 records to database.

Once I checked the size of the MySQL directory I figure out it has 6.9GB and mysql/data directory occupies 6.5GB out of that. There are lots of "mysql-bin.*" files available in the data directory. Ohhh I have enabled the binary logs. So every update your doing, it will be logged in the binary log. This will help you to recover in case of a crash. Do I need to recover my TEST databases used in the projects? Since this is a development environment, then the answer is "NO". This is how you disable it and make your hard dick clean with out the unwanted binary logs.

1. Stop the mysql server : /etc/init.d/mysql stop
2. Comment out "#log-bin=mysql-bin" in my.cnf
If you can't find out where is your my.cnf is then use the following command to find out the file.
find / -type f -name "my.cnf" -print
3. Then delete your "mysql-bin" from data directory
Note: It would be safe if you can keep last 10 bin logs files and delete the rest.
4. Start the mysql server: /etc/init.d/mysql start

Even though the disabling of binary log is straight forward for most of the developers, most of them do not disable in there MySQL at development environment. Unintentionally our hard disk will fill with out notice. That's why I thought of highlighted this.

I got 5GB cleared from my hard disk and SQL queries get faster... Now I can store 7 movies downloaded from Torrent :))

MySQL Partitioning

One of the recent project I were assigned, I had to handle lots of event records and subscriber details(which is in Telco environment). So we looked at the database partitioning for subscriber profile by the number ranges and prepaid/post-paid way. For the event tables, it would be a weekly basis tables. If we create the tables structures according to the above logic and going to handle at the coding level, then the SQL queries get very complex. Then I found the a very effective way of handling the database partitioning at the database layer itself without bothering about what kind of tables which we are having at the coding level.

MySQL 5.1 provides a very stable feature called partitioning. It provides both Horizontal and Vertical partitioning.

Check this article: Improving Database Performance with Partitioning
This specified the performance improvement and how easy for a developer to work with the higher data load.

For Oracle DB partitioning: Oracle Partitioning Oracle9i Enterprise Edition

Even though the partitioning is a very rich feature, there are few limitations as well. If you are using with innodb please check the limitations before you use it, most importantly it does not support foreign keys.
Check this: Restrictions and Limitations on Partitioning