Archive for the ‘General’ Category

Memories of childhood

Thursday, June 21st, 2007

Today, I got a scanner and my brother wanted to scan some of our childhood photographs. So, we put four photos in each of corner of the scanner and scanned them.

After all, we had huge images, which should be split into four separate images. That was a pretty straightforward boring process. So, finally, I thought of writing a small piece code to split the images. and that�s written in JAVA :O. Code is not written for posting, so looks like poorly written code, but anyway it does the job.

import java.awt.image.*;
import javax.imageio.*;
import java.io.*;

public class ImageSpliter {
	public static void main(String args[]) {
		try {
			File file = new File(args[0]);
			int x = Integer.parseInt(args[1]);
			BufferedImage input = ImageIO.read(file);
			BufferedImage output = input.getSubimage(0,
							0,700,1000);
			File fo = new File(”C:/photos/”+x+”.jpg”);
			ImageIO.write(output,”JPG”,fo);

			output = input.getSubimage(0,
					1400,700,input.getHeight()-1400);
			fo = new File(”C:/photos/”+(x+1)+”.jpg”);
			ImageIO.write(output,”JPG”,fo);

			output = input.getSubimage(1100,
					0,input.getWidth()-1100,1000);
			fo = new File(”C:/photos/”+(x+2)+”.jpg”);
			ImageIO.write(output,”JPG”,fo);

			output = input.getSubimage(1100,
				1400,input.getWidth()-1100,input.getHeight()-1400);
			fo = new File(”C:/photos/”+(x+3)+”.jpg”);
			ImageIO.write(output,”JPG”,fo);
		} catch(Exception e) {
			System.out.println(e.toString());
		}
	}
}

Development of AcSO - From A to Z

Sunday, May 20th, 2007

Last month we got selected… oh! In case you don’t know about that, just read my previous post. “And Then” the next phrase - Development.

AcSO is basically academic information sharing site, which will be run by the users (Web 2.0 concept). So, it has some amazing features, but no so hard to code. However, since we have four fellas in the team and we want this built well, we need to come up with a nice site structure.

There was an ASP.NET built in login system. It’s very easier to use. But there were some problems, by default it uses some kind of weird database and replacing it is not so easy. So, we argued about two days whether we shall use it or not and finally decided to code our own one which only took about 15 mins :P

First what we decided was to use portlets; basically, web parts. After developing sevaral portlets, we again reran an evaluation and decided that we don’t need portlets.

Then we had an exam paper and after all we have 3 and half days to build the application. So, we just started coding raw pages, and we used some base classes written for the web part application and here is the final result : http://team4366.webdev07.imaginecup.com/

There was one big problem when we are developing the site, “version controlling”. Keshan and Me replaced each others codes several times. So, after all we used manual version controlling mechanism. Before updating code, I always took a backup of the current site. Believe me, I have more than 300 MB in backup files. But, it along didn’t solve the problem. So, we started to working at shifts ;-).

Since these pages have put together in three sleepless days, there are lots of features missing. And we also didn’t have much time to put the validations, etc. Basically, we haven’t fine tuned the site. But anyway we are happy with the current progress of the site and if we go to the next stage, we should start development at least about a month before the deadline.

Theory of making theories

Monday, May 7th, 2007

About a month ago, keshan posted a blog article called “Theory of falling in love“. There were quite amazing replies for that, and when I read those replies, I understood one thing; Most people there doesn’t have a idea about theories.

Let’s not talk about the definitions of the theory. The only thing matter here is that the word “theory” brings a concept to your mind. Ok. That’s what a theory is :).

According to Stephen Hawkins, a theory should have two basic qualities. One is that, it should only have as much as few as arbitrary elements and those should be easy to calculate. Then the next one is that it should accurately predict the behavior of the subject. In short, is it useful?

So, let’s look at the keshan’s theory of falling in love. Well, when we consider the first rule of the theory, definitely it might be hard to calculate and those are not defined yet, but somehow by measuring few facts that he mentioned will somewhat accurately predict the subject. So, in that case, we can safely assume his theory is not bad at all.

Ok. Let’s look at the comments. Most of the comments there talks about a best match which cannot be explained by maths/logic. That’s definitely one way of saying “God made us to be together”. Ok, do I have to talk more about that?

Nuwan has made some interesting comments there. “Well its true u can explain many things using maths or logic.. but yet i have to remind u that mathematics or even logic are also concepts that defined in human brain”. Let’s talk about maths. There are some base concepts in maths, and other functions, formulas, etc are proved using those concepts. And amazingly those concepts explain the physical world. So, the love is also a concept, which can used to explain to human behavior. Since love is also a concept, what else can explain it rather than concept themselves? Even, if you don’t agree the fact that love is a concept, you have to admit that love is defined in the brain. And somehow, fortunately or unfortunately, the brain works according to logics.

“What You are doing is, you trying to take some theory which is invented by the brain and ur trying to explain the brain chemistry out of that theory”. Definitely, and he is right. As I have pointed out earlier, Maths explains maths.

“if all human beings love according to theories.. the world cannot be…….”, that might be where you got wrong. People don’t love according to theories; the theory explains how people love.

After all, what really matters is not whether a theory is prefect or not; whether it is useful or not. That’s why Newton’s theories are more important than the Einstein’s theories even though Einstein proved most of Newton’s theories are not accurate in larger scale.

Theories fall when there is a better theory. Not by saying “Love is a noble thing, and it cannot be explained by theories”.

A new theme

Sunday, May 6th, 2007

After all Thoughts of a coder running on my own theme. Actually, I designed, or not designed but just layed the content, because I got several complains that the earlier theme makes the content hard to read. Now, you can read it easily.

The image in the header is taken from Mental Disorder Theme

Is it time to stop doing this bullshit and start doing a real bullshit?

Tuesday, April 10th, 2007

If you read my latest few blog posts, you might be wondering where was that technical guy who was writing about all the linux and programming stuff. Now, my psychic thinking just got more crazy and here is another post on that series.

Since I was a little kid, I had a great dream - doing my own farm, as a matter of fact, it’s not a western kind of a farm, just a Sri Lankan “hena” with few animals like cows/bulls.

It’s not just a thought that came to my mind suddenly. It’s kind of a self living concept. Well, no one can live self independently, but at least almost everything in my food; it’s great if I myself can just have those.

However, I ended up doing computing and electronics which was a solution for my thirsty in the research and development field, or in a more clear language - my interest in learning new things. Even though I’m quite happy with what I have achieved now I’m wondering whether I made the right decision, it’s really doubtful. Is this the thing that I really wanted?

Of course, it won’t be easy for me to live in a world without internet, without email as my primary source of communication (since I don’t use a cell phone, people have to use emails to get in touch with me), but I guess it would be fun.

Now everything in the computing world is becoming more and more boring in my life. Even with the web 2.0 concepts, the same things coming over and over again, for example just look at a link sharing site, it’s the same kind of the links over and over again.

My instincts tell me something, but what is really stopping from I’m believing my own instincts is the computer itself. It’s a known concept in the computing that “Never trust your instincts when it comes to algorithms” or in other words “Don’t fall into the coolness trap”.

Are you addicted? I am.

Friday, March 30th, 2007

When we (people who are born in mid 80’s) were small kids, our culture led us to the TV addictions. It was a nice entertainment gadget that everyone had; started by addicting to the cartoon series, then to the young adventure drama series like “spell binder”, “ocean girl”. When we were growing bit by bit, the cartoon series faded out from the life, but never the TV. However, about 5 years back, the TV itself began to fade out. The quality of the content is so poor now and I barely find a guy who is still watching TV like the old days (I know one guy who is so much into watching Maha Gedara - mata me kanen pennana puluwan - www dot nuwanbando dot com).

Even though we stopped watching TV, we never stopped watching TV series :D. Thanks to bittorrent, every popular TV series is an addiction now. Star Gate (10 SG1 seasons and 3 Atlantis seasons), Prison Break (2 seasons), Heroes(1), Jericho and much more. Some people might think that we are wasting our time and this addiction is really really bad; but the truth is it’s really fun to watch those and talk about them, more to the point, it’s good stress releasing system. So, if you haven’t started watching those, start it today itself; I bet you’ll never regret.

IOI Site is back

Tuesday, March 13th, 2007

Today, after going through a lot, I managed to get the ioi site running. Just drop in there if you are interested in programming.

The grader is written in C++, and the interface is written in PHP using AJAX. This whole project is open source, you can download it from the sourceforge project page. Current release version is bit old, hopefully I’ll upload the current working version tonight.

My Life so far

Sunday, February 25th, 2007

It’s about 20 years, hell of a lot of time has passed. I was just looking back on my life, and my mind was filled by thoughts. Were those thoughts of a coder? I don’t know, but as a matter of fact, It’s how I think!

Age 0 - 5 :

Usually, people says it should be 1 - 5, but as programmers, we should always start counting from zero ;-). lol… never mind.. It’s blackout. I can’t remember much about my very young ages.

5 - 10 :

Let me tell you, either I was playing games on dad’s network, or I was on a tree with my brothers. Yeah, I can still remember I spent half of my life climbing trees, and I finished all the outstanding games on those years, Wolf3D, Prince of Persia, etc..

10 - 15 :

This might be my first step to the real computer world, coding.. Started with writing small batch files in DOS. Then VB, VB Script, HTML, Javascript. And other than programming, I was doing few graphics, like 3D Max.

15 - Now :

I started going IOI. Learned many other programming languages including Pascal, C, C++ and also Assembler. Learned many algorithms and implementation skills got very high compared to earlier ages. Switched to linux as the primary OS. Started hacking and cracking. Started open source development. and much more other things. Meanwhile, did science days/astrology days at school. This might be the golden era of my life.

Let’s just wait for another few years, well of course only if I’m alive :P.

New photos

Tuesday, January 23rd, 2007

I uploaded some of the photos of the trip.

Trip to Nuwaraeliya

Monday, January 22nd, 2007

Last week, we did few simple projects with php and one of them is a voting site. Basically a simple voting engine and the theme is similar to fear factor. The main text of my site says “Imagine a world where your greatest fears become reality. Welcome to ……” (Taken from a quote) and “Next stunt : Spend a week without using a computer… Are you ready?”..

After all these coding stuff I had to do it.. went four days trip to katharagama & nuwaraeliya with keshan, nuwan, banu, kasun and vpj, and amazingly it was not difficult at all, eventhough i spent few hours cleaning my huge inbox and replying to the emails.oh! god.. now i’m thinking how to start the remaining work… i just dont know where to start, and thinking whether it’s possible to keep on trying the stunt.

I’ll upload some photos ASAP.