May 26th, 2008
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. :)
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: eval, variable accessor, variable method
Posted in PHP, Ruby | 2 Comments »
May 26th, 2008
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 »
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: Apache, benchmark, CodeIgniter, framework, Kohana, ModRails, Passenger, PHP, Rails, Ruby
Posted in CodeIgniter, Kohana, Rails | 9 Comments »
April 22nd, 2008
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.
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: Bash, SyntaxHighlighter, SyntaxHighlighter Plus, Wordpress
Posted in Wordpress | 2 Comments »
April 12th, 2008
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! :)
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: All-in-One Gestures, Firefox, FireGestures, mouse gesture, Mouse Gestures, spell check
Posted in General | 3 Comments »
April 1st, 2008
Magento 1.0 is out.
Last time I checked (when it was 0.8 beta) I couldn’t install because my host doesn’t have pdo_mysql. Since then I requested pdo_mysql to be compiled and now is a great time to give it another spin. ;)
It should be very interesting because Magento is built on Zend Framework.
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: Magento, pdo_mysql, Zend Framework
Posted in General | No Comments »
March 27th, 2008
Total usage: 7 hours (1h WIFI, 10m calls, 30 SMSes, the rest were all video playback)
Standby time: 4 days and 18 hours
Remaining battery: 12%
I think this is quite impressive. :)
UPDATE @ 15th April 2008:
Battery ran out completely today, with the following usage data:
Total usage: 10 hours (1h WIFI, 30min calls, the rest were all video playback)
Standby time: 6 days
Impressive! :)
These icons link to social bookmarking sites where readers can share and discover new web pages.
Tags: battery, iPhone
Posted in iPhone | 4 Comments »