Tuesday, June 12, 2007

A Useful Command Prompt Tip

netstat -an |find ":80"

The above command I use so frequently. It really helps me out figure if there is a webserver running on the machine (ie. listening on port 80).

Actually, this command is a combination of two commands. The first is netstat which displays a boring long table.

The second is find "XX" which ignores all strings that dont contain "XX".

The '|' is the pipe operator. Now the command simply pipes the output of 'netstat' into 'find', the result is the line that contains the string "80".

If you're from a linux background, you'll find this post a bit too obvious. Since we're used to using the 'grep' command (which is similar to 'find' on windows).

Sunday, June 03, 2007

Microsoft PowerToys

Add convenience to your life ...

Try these free tools:

1. Alt-Tab Replacement
When using Alt-Tab, this will show you a small thumbnail of the program you are switching too. Very helpful when switching to multiple instances of the same application.

2. Power Calculator
Enhanced calculator for your OS.

3. Open Command Window Here
Allows you to open the command window for any folder you are currently in.

4. Image Resizer
Resize images on the spot.

5. ClearType Tuner
This PowerToy lets you use ClearType technology to make it easier to read text on your screen, and installs in the Control Panel for easy access.

Download any or all at:
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

Friday, June 01, 2007

Who Said You Cant Learn Karate From A Book?

You can learn anything from books. A good book with good illustrations and a comprehendable language style can teach you anything.

The only extra large step you need is to continually practice. If you dont, then most probably you're dropping everything you've read.

Now wait a second, I know what you're thinking... but watch out for what I said; I said 'you can learn', but I didn't say 'its the best way!'. So lets face it, someone whom read a book about Karate will definitely know more than someone who haven't read (assuming both initially start in the same state).

Here's my evaluation of the different ways to learn ordered from best to worst:

1. Let an expert teach you, practice well, see what other experts teach, read about it, apply, understand the different schools on the same subject.

2. Let an expert teach you and practice well.

3. Read a book, and practice.

4. Read a book.

5. Do nothing.

Please note that I'm writing this post without any pre-research or good analysis on the subject. Therefore, please forgive my 'hardly scratching the surface analysis' (abbreviated HSTSA) on this subject.

Monday, May 28, 2007

File System Storage Versus BLOB Objects

Document Management Systems nowadays are heading towards storing all documents as BLOB objects in the database. You rarely find any server side applications that deal with documents as files.

Whether its a... Document, Content, Bug, Project, Knowledge Management System, they're all implementing document storage using BLOB objects.

Why it that then?

Well...

1. The first advantage of having everything stored in the database is the ease of backups and restorations. You no longer need to backup the database then backup your document's directory, then make sure they are synchronized.

2. The second advantage is that the documents are stored the same way on all platforms and partitions. Whether its FAT32, NTFS, or any other filesystem, you can store them all in the same way.

3. The third advantage is, you have full control of versioning documents, storing interesting information like diffs, dates, users performing on them.

4. The fourth advantage is that third party applications that connect to the database need only to have the database port available. No need to provide extra ftp access to acess the documents.

Thats it. Bottom line...

If you're building some kind of server application, consider a Database File System.

Wednesday, May 23, 2007

The 3arabeezy Habit

In the old university days, whenever I met someone speaking half english half arabic, I usually felt so intimidated of such personalities. I used to think of them as people whom try their best to show off by mixing sophisticated english terminology with verbal mingled arabic pronounced english sounding words. At those days, 3arabeezy for me was a 100% Yukk.

Today, I became one of them (A 3arabeezist). I just cant stop it, I keep mixing english and arabic whenever I speak, I dont know how it came up to be, it just happened. Gradually, I started substituting english words for words that I cant find an arabic alternative for, and vice versa.

It seems that mixing two languages makes me feel smoother. Its not only in verbal languages. Its also in computer languages. You need to write Embedded C in Java code for certain functionalities, and to write PHP extensions using C in others, or even assembly in some C code, mixing languages could be an advantage.

However, mixing arabic and english proves that you are proficient in using both simultaneaously, but very weak in utilizing one at at time.

Even when trying to talk completely in English... one or more 'ya3neeez' have to slip through the conversation. And when I talk in complete Arabic, one or more 'simply', 'basically', 'soon enough', 'I think' have to slip in between.

In funny cases, I'm also starting to use the plural form of arabic words in english form... examples are 'Raheeebz', 'Raw3az', '7abaaaybax' and 'Jee3aanz'.

Lets jump to the lessons learned of this post. I guess there's one really serious lesson to mention. 3arabeezy aint that bad, but could make you look REALLY bad in first impressions. So here's my advice:

1. When introduced to new people, dont use 3arabeezy whatsoever. Stick to one language. Talk professionaly. Dont mix. It will only leave an impression of either a show-off or an improficient talker.

2. In public speech, dont use 3arabeezy unless the audience are people you've worked with before.

3. When dreaming, feel free to use 3arabeezy. Totally acceptable.

4. Sometimes you need to use 3arabeezy when talking to people who know neither arabic or english. This raises the chances that there could be an arabic or english word that sound something similar to their native language.

5. Only use 3arabeezy if you feel that a certain word has a better alternative in the other language that will ease up understanding. Again, this proves weakness in the former language.

Till then, we'll meet again in a next epi-post of 'Lost in the Code Carribeans'.

Monday, May 14, 2007

The Long Easy Way Versus the Short Hard Way

Today I had a small discussion with a good technical friend of mine ;) The discussion started with trying to handle an SQL Query with one shot.

The SQL Query got a bit too complicated to handle and needed some extra research, reading and thinking to figure out the correct way to do it. It took two technical brains, good MySQL experience, about forty minutes of work, and at the end some testing. It resulted with a long SQL statement.

Through our work we had another solution, its a very easy solution, get the data you need through multiple SQL statements. Thus, a long but easier way to do it.

We felt so proud that we were able to tackle the short difficult path, but at the end, considering the long easy path we missed, I felt a bit unrelaxed, but as soon as that happened, I was reminded with an important wisdom (by my amigo):

"If you keep choosing the easy and long path, you'll hardly learn anything. It's the difficult short path that provides you with extra skill and power."

Now imagine the amount of skill and power you can gain by choosing the long difficult path. Hmmmm, cool as long as no fatal mistakes takes place.

There's always alternate wisdom supplements when twisting different stories around.

The 'Call Super' Antipattern

A common design problem that is usually solved using the 'Call Super' antipattern (also referred to as code-smell). Simply stated, the problem occurs when the subclass needs to share the implementation of the super classes over-ridable methods.

In such case, 'Call Super' anti-patten is usually used by calling the over-ridden methods from within the subclass's over-riding methods.

I'll show a 'Call Super' code sample, then show a much better and neater solution (proposed by Martin Fowler).

The Bad Solution (Using the 'Call Super' AntiPattern):

class Penguin {
public void intoduceYourSelf() {
System.out.println("Hi, I'm classified as a penguin.");
}
}

class EmperorPenguin Extended Penguin {
public void introduceYourSelf() {
super.introduceYourSelf();
System.out.println("My real name is Emperor Penguin");
}
}
A Better Solution
A much better solution is to have an abstract method in the super class for the extra actions the subclasses will perform. And thus, the subclass only needs to implement that abstract method:

class Penguin {
public void introduceYourSelf() {
System.out.println("Hi, I'm classified as a penguin.");
talkAboutYourselfMore();
}


abstract public talkAboutYourselfMore();
}


class EmperorPenguin extends Penguin {
public void talkAboutYourselfMore() {
System.out.println("My real name is Emperor Penguin");
}
}



Thats it. A neat alternative solution that I love to use.

Wednesday, May 09, 2007

Curiosity Never Killed The Cat...

... it was Boredom which did.

The amount of boredom I've been through in the past three days has been killing me softly.

Unfortunately, this time it's the result of practicing a boring repititive task; writing code that tests code. You just keep on writing code and checking the result, then writing another line and checking the result, then another line, and checking the result.

Trying my best to be creative with this task, I only modified the code a bit to show errors in red color and success in green color. Thats about it.

Wisdom of the day:

Ok, curiosity might have killed the cat. But boredom will kill anything!