Latest from thislab

Class naming convention in Zend Framework makes life harder

First of all, not all parts of the Zend Framework enforce the class naming convention, at least not upon calling ‘em. For example, view helpers are called directly by the ‘chopped’ class name:

// actual class name:
class Path_To_The_CustomViewHelper {}

// calling it in the view:
$this->CustomViewhelper();

Also, models are both named, and called by their class names without any paths (but yes we have to include them in the include paths).

You would think that in most cases calling the classes by their full names (with paths) should work, right?

Wrong.

Read the rest of this entry »

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags: , ,

Zend Framework, where do you want to go tomorrow?

Two weeks ago I started working with Zend Framework at work. I chose to use Zend Framework for one primary reason: Zend. Even though I have plenty of experience with CodeIgniter and Kohana, I simply could not take any risks using them for a rather large project at a company I had just joined.

My experience so far is mixed. Probably because I am so used to the way CodeIgniter and Kohana do things, Zend Framework just appears utterly complicated and difficult to work with (at the beginning).

Read the rest of this entry »

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags: , ,

Variable methods and accessors in Ruby

Yeah I am a lame PHP guy who hasn’t gotten too deeply into Ruby yet. ;)

In PHP I often use variable methods, for example:

$foo = new Foo();

$funcname = 'dynamic_method';
$foo->$funcname();
// Same as calling $foo->dynamic_method();

$varname = 'dynamic_accessor';
$foo->$varname = 'some value';
// Same as calling $foo->dynamic_accessor = 'some value';

Now, because Ruby does not prefix $ in front of variables, it is impossible to use variable methods the way we do in PHP.

I am sure for Ruby gurus it’s pretty obvious but for me, I just spent more than 30 minutes searching for an alternative other than evil eval, and I finally found one.

We use the PHP call_user_func and call_user_func_array equivalent in Ruby: send or __send__.

Luckily accessors in Ruby are methods, so we are able to use the send method for both methods and accessors.

For example we can set a variable accessor like this:

foo = Foo.new

funcname = 'dynamic_method'
foo.send "#{funcname}"
# same as calling foo.dynamic_method

varname = 'dynamic_accessor'
foo.send "#{varname}=", 'some value'
# same as calling foo.dynamic_accessor = 'some value'

I wish in future versions of Ruby, we can somehow assign accessor values the way we do in PHP. :)

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags: , ,

Ruby on Rails, Passenger (ModRails) vs CodeIgniter and Kohana

Disclaimer: This is a very simple, ‘Hello World’ benchmark which has no impact to any real world applications. A more thorough benchmark test (by building two real world applications) is planned. :)

Disclaimer 2:I apologise for posting such a useless benchmark (I certainly didn’t expect it to hit the DZone front page), but I think most of you missed the point. I merely posted this as a result of surprise (to me anyway). At a later stage I will conduct a much more meaningful comparison between some of the frameworks. Until then, please ignore this post. :)

Last few days I have been playing with Ruby and Rails, again.

Today, when someone was asking on a forum about the efficiency of web frameworks, I thought I’d give the few frameworks I work with some more benchmark testing.

So I went ahead and benchmarked CodeIgniter, Kohana and Rails, using a simple ‘Hello World!’ page. Now before I post any benchmark results, you should know that I have previously done a benchmark test on CodeIgniter, Kohana and CakePHP. CodeIgniter and Kohana shared similar results.

Read the rest of this entry »

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags: , , , , , , , , ,

SyntaxHighlighter Plus: Now Supports Bash and Wordpress MU

A while ago Tim and Nick Anderson have submitted their patches to me (big applause to them!), today I finally have the time to include the patches to the official Wordpress repository.

Please head to the plugin page or the Wordpress page for more information.

Caution: If you have altered your CSS file, make sure you back it up if you’re going to use Wordpress 2.5’s automatic plugin upgrade.

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags: , , ,

Firefox on OS X and Linux: Spell Check and Mouse Gestures

Since I fully switched from Windows platform to OS X, I noticed that the spell check in Firefox no longer works. A quick google search revealed that the problem is caused by All-in-One Gestures and persists on both OS X and Linux.

I have been using All-in-One Gestures on Firefox for a very long time (primarily on Windows). Fortunately I only use the two very basic gestures: back and forward, so it’s okay to ditch it and find an alternative.

There are only two alternatives to date: Mouse Gestures and FireGestures. The former has not been updated since 2006 and breaks the spell check at least on my system. So I gave FireGestures 1.0.5 (the current version on the Firefox Extension website) a try, sadly it breaks the spell check too. I then went to the developer’s website and found out that there is a 1.1 dev version, and it has what I have been looking for: [Linux][Mac] Fixed bug: Breaks inline spell checker (Alternative words is not showing).

Downloaded, installed, and sweet, the spell check is back! :)

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags: , , , , ,