Archive for the ‘Uncategorized’ Category

In order to allow developer to use translator instance into validators, Zend Framework 2.2 add a new service call MvcTranslator, as quoted in documentation:

“A new service has also been registered with the MVC, MvcTranslator, which will return this specialized, bridge instance.

Most users should see no issues, as Zend\Validator\ValidatorPluginManager has been modified to use the MvcTranslator service internally, which is how most developers were getting the translator instance into validators in the first place. You will only need to change code if you were manually injecting the instance previously.”

However, we used to set the locale by a manually injected translator to allow users switching to different languages. After upgraded to 2.2.2 or later (the latest version at this time is 2.3.1), the switching languages function is no longer working properly.

In order to make sure function works properly no matter the version is, I updated the code to something like:

    public function setLocale($locale) {
        $sm = $this->getServiceLocator();
            $this->translator = $sm->get('mvcTranslator');
        }else if($sm->has("Translator")){
            $this->translator = $sm->get('translator');

Read Full Post »

Some content on this page was disabled on March 8, 2018 as a result of a DMCA takedown notice from Yahoo!. You can learn more about the DMCA here:


Read Full Post »


Read Full Post »

If you have installed mac port, it’s normal to install python and django under macport.


The latest python installed by macport should be 2.7.3, thus command for installation of python and django are:


sudo port install python
sudo port install py27-django

If you have installed previous version of python through macport, you should make sure which one is active, you can use the following command to check:


port select --list python

The result should be similar to the following:

Available versions for python:
	none (active)

If you want to ask macport to select the python 2.7.3 provided by macport as default python interpreter, you should use the following command:

如果你想指定用macport所提供的python 2.7,你需要用到以下的指令:

sudo port select python python27

If you want to see if you have set the active python interpreter correctly, type the following command to check the path of python:

如果你想測試之前能否成功地指定python interpreter,可以用以下的指令查看python的路徑:

which python

If you selected macport’s python, the path should be:


Try to repeat the previous steps if you find the path is different.

Now, please check your path to django-admin.py:

which django-admin.py

In my computer, the result is:


If you execute django-admin.py, you will find out that python cannot find django.core. The problem is caused from the first line of django-admin.py


from django.core import management

if __name__ == "__main__":

The first line tell shell to use the python installed by mac os instead of using the python provided by macport. Thus, we should use the following command to change the first line:
第一句告知shell使用由mac os所提供的python而不是macport 所提供的python。所以我們須用以下的指令更改第一句:

sudo nano /usr/local/bin/django-admin.py

The updated source code should look like:

from django.core import management

if __name__ == "__main__":

Then, you can ran django-admin.py properly.

However, next time if you update django, please repeat the process again.

Read Full Post »

One of my colleague using Internet Explorer 10 to emulate IE 8 Standard mode. During calling slice() method for a String object. It shows the error “slice not found in object”.

我有位同事用Internet Explorer 10去模擬IE 8標準模式。在一句指令中,字串物件上執行slice()方法時,卻發生了問題,Internet Explorer顯示”slice not found in object”

This problem in weird since in microsoft website, it stated that string’s slice method is existed in all versions. (http://msdn.microsoft.com/en-us/library/ie/s4esdbwz(v=vs.94).aspx)
這是個奇怪的情況,因為在微軟的網站內寫著所有版本Internet Explorer都有String slice。

In order to avoid any similar problem, I wrote a custom slice() method whenever slice() is not found as default:

if(typeof String.prototype["slice"]==="undefined"){String.prototype.slice=function(s,e){var l=this.length;return this.substr(s=s<0?l+s:s,typeof e==='number'?(e<0?l+e:e)-s:l-s)}}

Read Full Post »

最近工作桌的那部電從Ubuntu 12.10升級到Ubuntu 13.04突然發現無法使用phpmyadmin。

Recently, I’ve upgraded my desktop in my working place from Ubuntu 12.10 to Ubuntu 13.04. After installation had finished, I found phpmyadmin couldnot operate properly.

從WebBroswer自到代碼500。於是我查看Apache 2 log:

There was 500 server error found in my webbrowser. So, I decided to check the Apache2 log:

cat /var/log/apache2/error.log

From the log, I found the followings:

[Mon May 20 10:23:07 2013] [error] [client] PHP Stack trace:
[Mon May 20 10:23:07 2013] [error] [client] PHP   1. {main}() /usr/share/phpmyadmin/index.php:0
[Mon May 20 10:23:07 2013] [error] [client] PHP   2. require_once() /usr/share/phpmyadmin/index.php:13
[Mon May 20 10:23:07 2013] [error] [client] PHP   3. require() /usr/share/phpmyadmin/libraries/common.inc.php:614
[Mon May 20 10:23:26 2013] [error] [client] PHP Fatal error:  require_once(): Failed opening required './libraries/php-gettext/gettext.inc' (include_path='.') in /usr/share/phpmyadmin/libraries/select_lang.lib.php on line 370

看似是找不到gettext library。經網上查証,只要更改phpmyadmin所提供的apache.conf,在php_admin_value一行,末端加入:/usr/share/php/php-gettext/

It seemed to be an error when the web page tried to look up the gettext library. I found a solution from the internet that requires me to add /usr/share/php/php-gettext/ to the line of php_admin_value in my apache.conf (the one that provided by phpmyadmin). The updated conf file should look like:

<Directory /usr/share/phpmyadmin>
	Options FollowSymLinks
	DirectoryIndex index.php

	<IfModule mod_php5.c>
		AddType application/x-httpd-php .php

		php_flag magic_quotes_gpc Off
		php_flag track_vars On
		php_flag register_globals Off
		php_admin_flag allow_url_fopen Off
		php_value include_path .
		php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
		php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/

After I had restarted my apache 2:

sudo /etc/init.d/apache2 restart

Wow.. phpmyadmin became normal again!

Read Full Post »



我決心要處理這些真菌蚋(蚊滋)。在網上有位年輕的太太在其blog上介糿用tumble dryer sheets。

我在兩天前乘車時,曾在思考如果為樹木殺滅埃及吹棉介殼蟲(見本人的Facebook內提及天水圍樹木被埃及吹棉介殼蟲為患一文)。想到了用freeze spray。今早,我以Freeze spray將真菌蚋(蚊滋)的成蟲殺滅了。真菌蚋成蟲被Freeze Spray急凍之下,最初還有活動能力,相信其腹部不能禦寒,一分鐘內變得無法行動,然後死去。

我會更換受真菌蚋(蚊滋)幼蟲感染的泥土,亦會為泥土噴上Freeze Spray,研究一下Freeze Spray對真菌蚋(蚊滋)幼蟲的影響。

如果能對真菌蚋(蚊滋)幼蟲有效,我會試用Freeze Spray去對付 埃及吹棉介殼蟲。

Read Full Post »

Older Posts »