Question of the day…

April 30, 2007 § Leave a comment

What’s the different between DLL Hell


JAR Hell?


The Zen of Python

April 30, 2007 § Leave a comment

Here is the excerpt of the Zen of Python:

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!

This might come across as a joke first time, but I found it more and more relevant to agile programming (& my coding style). And, totally applicable to different programming languages.

Now, let’s talk about simplicity and readability:

For example, in the JAVA world I keep finding myself swimming around Interface classes which only be used once. Or to be exact, this type of relationship: Interface -> Yet another Interface -> Yet one more Interface -> Abstract Class -> Concrete Class.

Obviously that drives me mad. This type of codes is clearly complex, whether such abstraction is intended or not that’s different story. But, in short, overly complex and disturb readability. Especially in debug mode. Imagine gazillion lines of stack dump, yeah…. you know what I’m talking about.

Another example, which one you prefer?

  1. Having polymorphisms of Entity Beans, each of the methods in them doing things slightly different…
  2. Or have a general ORM class, capable of handling all of those methods? (Of course in such case, you need to define the methods more carefully)

Obviously, 50% of earth’s developers prefer no. 1 and the rest prefer no.2. Either way would work, but

no.1. would have a lot more verbose stack dump. Depending on what kind of developers you are, too much verbosity might hurt your eyes.

no.2, if implemented wrongly, might hurt your eyes as well. But once implemented correctly, you always know that table_object.insert() always perform the same way regardless what kind of table_object you are talking about.

Verbosity aside,

For people who have passion in building a product, getting it done as simple as possible is definitely the better approach. Thus, the Zen of Python would apply beautifully.

For people who work for big corporations, with zillions of legacy code and funky scalability… The Zen of Python might fail to guide you miserably.

In short, read the Zen… think about it… sleep over it… and try to apply it given your context. Who knows, you might have an enlightenment.

It’s been 1 week…

April 27, 2007 § Leave a comment

Since I got my Mac for course. I think this beautiful thing is ready for its first review.

So, let’s hear it:

  • As I proved it last week, Mac can still crashed. (-0.001)
  • PHP and Apache2 installation was such a breeze. (+9.99)
  • PHP is not pre-installed. (-0.00456)
  • UPDATE: PHP4 is pre-installed, I should have checked. (0.0)
  • Somehow was broken and I need to re-install again. (-0.0007)
  • Photo Booth rocks. I’m now addicted to it. (+67.41)
  • Fink didn’t install my SVN correctly. (-2.1)
  • Installing SVN binary was so easy. (+4.2)
  • Python & easy_install was easy to install. (+33.33)
  • Locate is simply doing such a GREAT job. (+4581.43)
  • Plain old terminal is always great, but iTerm is even better. (+129387.134)
  • DesktopManager open source is awesome, since I use multiple desktop on my Ubuntu. (+24.643145)
  • One of the best SVN GUI (svnX), crashed 3 times in 3 days. Not good. (-345.23)
  • TextMate is fabulous. (+3.14)
  • For some unknown reasons, Eclipse IDE run faster than its Windoze counterpart. (+1.2)
  • Local Apache instance being called “Personal Web Sharing” is hard to get used to. (-3.1)
  • Not having Ctrl, Fn, & Alt buttons for my right hand really sucks big time. Imagine holding a donut on your left hand and coding at the same time. (-99.9999999999)
  • Safari tab wasn’t set as default. That’s sooo IE. (-23.41)
  • Camino and Safari don’t display some of Google applications correctly. (-Googol)
  • It’s been 1 week and I still didn’t have to run Microsoft Office. Yes, you heard that right! 1 week fasting without Microsoft products. I will talk about this more later. (+Googol)
  • Only have 1 music player, iTunes, is great. I sucks at having too many choices. (+1.01)
  • Expose is indispensable. Now I cannot live without it. (+pi)
  • Most of the tools I use on Ubuntu, I can still have it on the Mac. (+831.45)
  • The keyboard felt soft, is this good or bad? (0.00)
  • Ruby is installed by default. Dynamic language? The more the better. (+34,21)
  • Java is pre-installed. (+0.00000000000000002345)
  • The screen is simply bright, at least brighter than HP laptop. Is it brighter than all Windoze screens? I don’t know. (+2.01)
  • No right click… That’s me being cheap not wanting to buy mouse. (0.00)
  • MagSafe? Very useful. Could have tripped the MacBook 3 times without it. (+891.873)
  • AirPort? Hella easier to setup than any Windoze wireless. (+1.034)
  • Being shunned by Linux fans? That sucks. (-132.65)
  • Being shunned by Windoze fans? (Priceless)

CakePHP and “Headers already sent… on session.php”

April 25, 2007 § 10 Comments

O boy… I’m in trouble now…

CakePHP project is probably the easiest project I’ve ever done in my life. Until I have to debug it…

Why all the sudden I got “Headers already sent… on session.php”?

Folks at Google Group had lots of talk about it. Most suggested that I have strange character or spaces before or after <?php ?> tag.

Nada… No such problem here in my code, double checked it three times.

Man, not even Google Group can help me this time.

Anyone of you kind souls out there willing to help this poor lad?


Ahsan comments make me to double check my cake’s php files. It turns out that i have a SINGLE white space on my /app/webroot/index.php. Man… a single whitespace… This is why I shouldn’t do initial development on Windoze machine.

Thanks Ahsan! 

There ARE Games for OS X.

April 24, 2007 § Leave a comment

Rumor has it, Macintosh is always lacking games. I was told “Good luck finding games on THAT thing!”. Alright, that wasn’t very nice. But that lead my adventure in search of GREAT games for Mac OS X.

In search for enlightenment I found this: Exult! It is open source engine for running Ultima VII on modern operating systems. How lovely! Ultima VII is the love of my life in RPG realm. No games has ever matched its open-ended environment. 15 minutes after the download, I’m off reminiscing my youth solving the case of a dead gargoyle.

Further expedition lead me to even better discoveries: FreeCol and openTTD! Super awesome! Being the sole conqueror of America as well as the monopolist of transportation industry would certainly satisfy the Bill Gates in me.

Wheew… These 3 games would certainly fills up a whole month of my free time.

See! There ARE games for Mac OS X!

note: You know… there’s always chess app on your application folder. In case you didn’t see it.


Downloaded Armagetron. This Tron game is simple KICK ASS! Lot’s of fun.

Mmmmm…. Cake….

April 24, 2007 § Leave a comment

CakePHP is a nice Ruby on Rails clone. There, I’ve said it. On my Windoze machine it was delicious. On my Ubuntu, it tastes even better. Now it’s about time for OS X to taste the cake.

  1. Download the cake!
  2. Untar it.
  3. copy the whole folder to /User/{username}/Sites directory.
  4. Edit your Apache httpd.conf:
    • Add new port for the following <Virtualhost> tag.
    • Create new <Virtualhost *:{new_port_number}> tag. See example below:
  5. Restart Apache daemon (run: /usr/local/apache2/bin/apachectl restart)

Sample of VirtualHost:

<VirtualHost *:2000>
ServerName {make up some name}
DocumentRoot “/Users/{username}/Sites/{your_cake_folder}/app/webroot”
<Directory “/Users/{username}/Sites/{your_cake_folder}/app/webroot”>
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
DirectoryIndex index.php index.html index.thtml index.htm

There you have it! Yet another easy tutorial to make Mac OS X the ultimate Web Development machine.

Configuring Apache2 and PHP on Mac OS X for Development

April 23, 2007 § 4 Comments

This article would serve as public cheat sheet on how to configure everything from scratch. Again…

  1. Grab the latest Apache 2.0 / 2.2 as well as PHP5
  2. Unzip them with this command: tar -xzf [your_file].tar
  3. Go to the created httpd directory (for apache) or php directory.
  4. Run: sudo ./configure. This is the crucial part. It is better to set installation path here instead of fiddling around later.

Sample .configure for PHP5:

$prompt: ./configure –with-curl=/usr –with-mysql=/usr/local/mysql –with-apxs2=/usr/local/apache2/bin/apxs

As you can see from –with-apxs2 flag, I installed apache2 on default location. It’s easier to find help and online documentation if you keep most installation on default location, IMHO.

The biggest problem with installing Apache is the httpd.conf monkey work. Below are things you might want to set:

  • Listen 80 (and/or other port number. This is needed for VirtualHost setup)
  • DocumentIndex index.php index.htm (add more if you need them, e.g. index.rhtml)
  • DocumentRoot /Users/{username}/Sites/{your_project} (This path is accessible by default)
  • <Directory /Users/{username}/Sites/{your_project}> </Directory>
  • AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
  • <VirtualHost *:{your port number}> {This tag can handle almost all Apache’s directives} </VirtualHost>

Mac OS X has Apache1.3 by default. That can be seen as both blessing and curse :P. If you would like to run Apache2 this is what you might do:

  • Stop Personal Web Sharing via System Preferences…
  • type: sudo /usr/local/apache2/bin apachectl start

AGAIN and AGAIN… If that aggravates you then this is what you could do:

  • cd /usr/sbin
  • mv apachectl apachectl1.3 {–> This rename default apache1.3/apachectl command}
  • ln -s /usr/local/apache2/bin/apachectl apachectl {–> This creates symlink for Apache2/apachectl command}

Quick Note: Symlink is something like Alias or Shortcut on the GUI realm.

There you have it. Hope the list is handy for you.

Where Am I?

You are currently viewing the archives for April, 2007 at RAPD.