Thursday, August 26, 2010

My happy Gsoc with PhotArk

Every dawn of summer blooms with expectations of laughter and enjoyments, and this summer for many students in Computer Science was the time to make their dream come true; To do a project and walk home with money.

I as a student very much interested in Open Source, this summer was so amazing. My third year at university started with Industrial Training, and as a part of it I started my intern-ship at WSO2, one of the organizations which give all its products under Apache Licence. This intern-ship gave me a very good exposure to Open Source, and this exposure greatly encouraged me to participate in Google summer of code (Gsoc)



I was also doing CIMA as an additional qualification apart from my university studies, and I thought of pausing CIMA for a year as I have to ensure my maximum contribution on computing. This sacrifice really worked out, I got a chance to work at WSO2 and also to participate on Gsoc.  I'm happy that I had enough time to sail both the boats, where I worked for WSO2 in weekdays, and also concentrate on Gsoc during nights and on weekends.

My search for a Gsoc project started well ahead of the proposal date, I had a solid one month time to look into all the projects and select one that suits me. First I went through the last year projects and after going through several mailing lists, the projects on Apache Wookie and Apache PhotArk seemed pretty cool for me.


I thought to concentrate on both, but then I found, standing on two boats with a day job in my hand is going to kill me. When time progressed I get more involved in PhotArk and finally I got selected to the project on "Integrating OpenID with PhotArk".

This interesting project was proposed by Avdash Yadav, here my task  is to implementing authentication through OpenID integration, and to provide authorization through Role Based Access Control with User Management.

As my first step towards Gsoc I started checking out the project source code, and building it. Then I started fixing some small issues reported in the Jira issue tracking system, and submitting patches. The PhotArk community got more interested in me, and gradually started applying my patches. Then they gave me some complicated tasks, where I implemented new features such as adding album descriptions, deleting pictures and albums, and so on. Then I also started writing some test-cases for PhotArk.

When proposal deadline approaches, I wrote a proposal, got it approved form my mentor, and submitted that on time. My proposal got accepted, and I finally got selected to Gsoc among 1026 students all around the world. That’s one of the happiest days in my life.

I started my project with a small research on OpenID libraries where we selected dyuproject for our implementation. During the first half of Gsoc I implemented authentication to PhotArk. Here I integrated dyuproject, and tomcat's FORM based access control to PhotArk.

At this time my mentor proposed me as a committer for PhotArk. My ambition to become an Apache committer finally became true on 10th May 2010 - just some days after the beginning of Gsoc. Because of this I also got an email id as suho at apache dot org.

After the successful midterm evaluation I implemented authorization by implementing Role Based Access Control to PhotArk. This gave me a very good experience, where we handled some problems on user friendliness based on the design and implementations of authorization. I was force to redo the implementation in-order to minimize user issues. By fixing this issue I successfully finished my Gsoc for the year 2010. This optimization of user friendliness is very important to PhotArk as this is a photo gallery application, and its user’s wont necessary have much computer literacy.

Since I was handling security I had the chance to work in almost all PhotArk modules, this greatly help me to get myself familiar with PhotArk code base. Through this now I have become an active contributor in PhotArk, Thanks for Gsoc. I like to invite every one to try PhotArk and manage your photos with it.

The detail information, and the project description can be found at the project's wiki page.

I would like to thank all who made my Gsoc a reality, and a happy one. I also request all students to take part in future Gsocs and to get the greatest experience on Open Source and some good money ;)

Thursday, August 19, 2010

Forgot your password...! This is how you reset in Ubuntu.

It's a common case that when you have not used your Ubuntu machine for some time you may have forgotten your password.
If you want to reset a new password instead of your old one,
and don't want to loose any of your date this is the coolest way to do.

But for this your computer need to have a CD ROM and you need to have a Ubuntu Live CD with same(preferred) or fairly close version.

Step 1.
Insert the Live CD and boot the computer in the Live CD mode.

Step 2.
Open the terminal and change to the root user

sudo su

Step 3.
create a directory
e.g.
mkdir foo

Step 4.
Find your Linux partition.
e.g. using the command
fdisk -l

by this you will get all the partition in the computer, and by looking at them you can find out your Linux partition.
e.g.
Device    Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       18710   150288043+  83  Linux
/dev/sda2           18711       19457     6000277+   5  Extended
/dev/sda5           18711       19457     6000246   82  Linux swap / Solaris

here the Linux partition is /dev/sda1

Step 5.
mount the partition the the newly created file.
e.g.
mount /dev/sda1 foo/


Step 6.
Use chroot to access the partition as its root
e.g.
chroot foo/

now you have all the root permission to the mounted hard-disk partition.

Step 7.
Use the file etc/shadow to find out the users of the system
e.g. if the user name is bar,
use the commands
passwd bar

to change user password
and
passwd root

to change the root password

that's it! all done.
Now restart the computer and login to the system with the new password.

Write Unmaintainable Code & Ensure a job for life ;-)

"In the interests of creating employment opportunities in the Java programming field, I am passing on these tips from the masters on how to write code that is so difficult to maintain, that the people who come after you will take years to make even the simplest changes. Further, if you follow all these rules religiously, you will even guarantee yourself a lifetime of employment, since no one but you has a hope in hell of maintaining the code. Then again, if you followed all these rules religiously, even you wouldn't be able to maintain the code! 

You don't want to overdo this. Your code should not look hopelessly unmaintainable, just be that way. Otherwise it stands the risk of being rewritten or refactored."

by "Roedy Green"

To write Unmaintainable Code, go to...

Tuesday, July 20, 2010

How to install ANT in Windows

Its soo simple...
Go to
and download the latest version and install.

When you install this it not only install Ant but it also installs Ant-contrib
and it too sets all the environment variables for you..!


For all these you only need to know the JAVA_HOME
To find out your Java home open the command prompt and type

echo %JAVA_HOME%

Tuesday, June 1, 2010

Shell scrips to start and stop background processes in Linux

Here I presents an overview of some useful shell scripts for starting and stopping background process, manually, or by other shells or programmes.

To start and stop background processes, in most situations we need their PID (process ID).

To find out the PID of the process
use the command;
ps 

To show all the processes;
ps -A 

To find out the  PID and the PGID (process group ID) of the processes;
ps -o cmd,pid,pgid

To get the PID for the given process name;
pgrep <process name>
e.g 
pgrep bash
 
To
kill the process

To kill the process by process name;
pkill <process name>
e.g. 
pkill java

To kill by PID;
kill -9 <PID>
e.g.
kill -9 12345

To kill by
PGID (process group ID);
kill -9 -<PGID>
e.g. if pgid is 9876, then type as;
kill -9 -9876

To kill process by their process name;
pkill <process name>
e.g.
pkill java

Now we'll move in to background processes. These
processes seems to useful situations like;
  • Other processes want the same terminal to execute them selves.
  • When time consuming processes is executed
  • Several processes need to be started one after other
  • etc

There is a very easy way
to do this in Linux. We just need to add '2>&1 &' at the end of the shell command, where the process will start in the background and immediately returns the terminal back to the user.

e.g. 
./server.sh 2>&1 &
./server.sh > server.log 2>&1 &

Note: If you use '2>&1', the script won't return the terminal, until the processing is over.

But when we start and kill processes pragmatically, we encounter a new challenge. We should kill the exact process that we started, and we
should not kill some other process!!
To do so, we should keep tack of the PID of the processes we started.

In order to get the PIDs, we can add the following code to the shell script that we are running.
To get the PID of the process that is currently running;
echo $$ > server.pid

Or to get the PID of the process,
last started;
echo $! &> server.pid

Well, now we have the PID. Next, we have to kill the processes we stated.
If we only have single processes - which don't have child processes
- we can use a command like;
cat server.pid | xargs -i kill -9 {}

This kills all the processes, who's PIDs in the servers.pid.

But
sometimes we encounter process trees, in this case when we kill the parent process the child process wont just get killed, but it itself will become a parent. In such situations we should kill the whole process tree.

If you want to view the process tree, you can use the command;
ps f

Or for a detailed view;
pstree

Sometimes in background processes, you encounter problems that the child processes wont get killed even we kill the parent process. Therefore to kill the child processes, you can use two approaches.
  1. kill the process tree (recommended)
  2. kill the processes which contains the same PGID (this works because in most cases the whole process tree will have the same process group id (PGID))

Killing the process tree using the parent's PID

you can uses that following shell script;
#!/bin/sh
for i in `ps -ef| awk '$3 == '${$1}' { print $2 }'`
do
echo killing $i
kill -9 $i
done
echo killing $1
kill -9 $1

Save this as 'kill-process-tree.sh'

Give executable permission to the script by the command;
chmod 755 kill-process-tree.sh

Then use the command to run the script;
./kill-process-tree.sh
e.g.
./kill-process-tree.sh 7234

Killing the processes which contains the same PGID

First we need to find out the PGID of the given PID of the process;
echo $! |xargs echo | xargs -i ps -o pgid -p {}|xargs echo |awk '{print $2}' > server.pgid

Then to kill the processes with give PGID use the command;
cat server.pid | xargs -i kill -9 -{}