Showing posts from 2011

DirectAdmin Upgrading CSF Firewall

(This post is meant for DirectAdmin beginners, like me.)

Finally got the chance to play with one of the production server - to upgrade the CSF Firewall.

For this, I have to SSH to the server because upgrading CSF needs root access.
Due to restrictions in "DirectAdmin you must login to the root shell" to upgrade csf using
csf -u
So I SSH-ed to the server and ran the command "csf -u". But this time, I get the following error.
-bash: csf: command not found
Okay, the path to CSF is not correct, so just need to
cd /usr/sbin/
Then gain root access,
su -
That's it, can upgrade CSF using the command "csf -u" automatically!


Convert SimpleXMLElement to Array

Ok, I know this is simple, but it took me a while to realize this simple method to convert SimpleXMLElement to an array. (I even tempted to write a function to parse and convert the XML tree).

Its simple actually, to just just the default PHP functions

$xml = <tag>content</tag>print_r(json_decode(json_encode($xml), TRUE));

Samsung Galaxy S2 variants

During trip back at Malaysia, I realize the Galaxy S2 variant there is i9100T. Which makes me wonder what are the difference.

[UPDATE, Jan 19] CyanogenMod wiki has a better list of SGS2 variants with support status comments.

After Googling around, I came to conclusion that all the variants have:

SAME hardware Specifications

and the DIFFERENCES are:
The I9100 supports 3G 900/2100Mhz and the I9100T supports 3G 850/2100Mhz The difference in SAR value, as shown in Samsung Website.
GT-I9100P - 0.362 W/kg
GT-I9100 - 0.338 W/kg
GT-I9100M - 0.338 W/kg
GT-I9100T - 0.285 W/kg
GT-I9100G - 0.247 W/kg (different processor - OMAP SoC)
Quote from Samsung Website:
This phone meets European Union (EU) requirements concerning exposure to radio waves. Your mobile phone is a radio transmitter and receiver. It is designed and manufactured so as not to exceed the limits for exposure to radio-frequency (RF) energy, as recommended by the EU Council. These limits are part of comprehensive guidelines and establis…

Notes from BlackBerry DevCon Asia 2011 #BBDevCon

Event: BlackBerry DevCon Asia 2011
Date: 2011-12-08

Updates: The speakers mentioned that the slides are available online. But I'm still not able to find 'em anywhere.

DEV846 – Advanced Web Rendering: webGL, Canvas and Gaming


Charles Wei, Technical Director, Torch Mobile (Beijing) Co. Ltd.
Robin Cao [robin.cao[at]], Senior Software Engineer, Torch Mobile (Beijing)

Tips and Tricks
- Avoid creating non-power of two images
- Avoid reading back from canvas

GLSL Shader
- WebGL - Matrices to represent states

Three.js, PhiloGL,
Khronos wiki,

DEV825 – Powering Immediacy: Putting Push Data to Work for You

Pratik Sapra, Application Development Consultant, Research In Motion
BlackBerry Push - push thru BB internet service - 8kb data - dedicated port - push service plus/ push service essential - mode : - point to point, - multicast, - broadcast. push request - PAP standard
Server Side Application Standalone approac…

Fat-Free Framework - Blank Page Error

Was trying getting started with Fat-Free just now, but found that the page wasn't loading at all, or more accurately, a blank page was shown.

I added a dummy echo before the template echo,
echo "Hello World!"; echo Template::serve('welcome.htm');
and found that the echo is printed, but not everything else in the welcome.htm

After debugging, I found out that its caused by
{{ Web::minify('ui/',array('style.css'),FALSE) }}
The page displays correctly, without css style, after removing that line, and clear the cache.

To solve this, its relatively easy.

Just need to enable
php_sockets in you PHP extension.

Then clear the /cache folder.

Hope that save the your time for some of you out there as well! :)

[i9000] Flashing CyanogenMod for Beginners

UPDATE (2011-11-27): After flashed to CyanogenMod and tested for a few days, I think that CyanogenMod is GREAT, i9000 users should just flash to it since Samsung firmware support for i9000 isn't that great, and slow. :)

The guide can be found from But its not complete with all the downloadables, there are few missing steps.

1. Installing the ClockworkMod Recovery

Before you begin, follow Step 1 & Step 2 from CyanogenMod to get the drivers installed.

Downloadables & Installation Guide

Heimdall Firmware Packages -
(As of now, XXJVT is the latest version)

2. Root your Phone
There are few options to root your phone.
Gingerbreak by ChainFire.CF-Root by ChainFire (works for XXJVT)
I used CF-Root and it worked.
Just a small note, if Odin cannot detect the phone, you can always reinstall the driver by running Kies device troubleshoot.

3. Flashing CyanogenMod

Finally, follow the Flashing CyanogenMo…

DirectAdmin Cron

If your hosting provider blocked you from running PHP files from command line (for security reason).

cd /home/<user>/domains/<>/cron_scripts/; /usr/local/bin/php script.php
Then the alternative would be using lynx, and access the files via url :)

lynx -dump http://www.<domain>.com/path/script.php > /dev/null 2>&1

RE: Android Orphans: Visualizing a Sad History of Support

A very good summary about Android environment. Very well summed-up and visualized the two rival ecosystem.

Root of problems - Hardware Manufacturers

Android suppose to be an open source project.By the default nature of an open-source, it is bound to lure all the hackers around the world to get their hands dirty on the project. Yet hardware manufacturers tries very hard to be in control of both the hardware and the software (firmware).
".. there’s no incentive for smartphone manufacturers to update the OS: because manufacturers don’t make any money after the hardware sale... The hacker community (e.g. CyanogenMod, et cetera) has frequently managed to get these phones to run the newer operating systems, so it isn’t a hardware issue." Despite realizing that they can't make money after hardware sale, and they are resource tight to keep up with the pace of the OS development, they still want to be in control. They even demanded takedown of the roms [1], which the hackers used…


Got this weird error of browser (Chrome) changing ajax/json data passed to server. This "isChromeWebToolbarDiv" DIV was appended at the end of the call.

<div id="isChromeWebToolbarDiv" style="display:none"></div>
This question has been brought up in stackoverflow. But so far there is no answer to it.

As expected, its caused by one of the Chrome/Firefox extension, mentioned in I guess next time whenever someone (or your customers) faces this issue, just ask them to disable extensions one by one.

[DirectAdmin] Clear Frozen Mail

Using Script to clear mail

/usr/sbin/exim -bpr | grep frozen | awk {'print $3'} | xargs /usr/sbin/exim -Mrm

Set cronjob in DirectAdmin
/bin/sh /home/<user>/domains/<url>/cron/

Put cronjob in


[DirectAdmin] Setting up Cronjob for Joomla jNewsletter

Method 1: URL access method

curl http://<>/index.php?option=com_jnews&act=cronwget -O - http://<>/index.php?option=com_jnews&act=cron >/dev/null 2>&1lynx -dump http://<>/index.php?option=com_jnews&act=cron >/dev/null 2>&1

If you use 'wget' is better to add the '-O -' option for don't get writed the downloaded file to the disk, only to 'stdout' and if your file is in one protected dir you can add the options '--http-user=USERNAME --http-password=PASS', see bellow:

wget -O - --http-user=USERNAME --http-password=PASS http://<>/index.php?option=com_jnews&act=cron >/dev/null 2>&1
wget, lynx or curl doesn't work?

If you having trouble getting lynx or wget to work. This may be the case if "localhost" is not permitted. Then wget, lynx or curl won't work on the local machine. Read more here

Alternatively, …

[Joomla] Check If user logged in

Just realize there this $my variable that conveniently lets you access the user id of a (logged in) user on the site.

if ($my->id) { // Do something here }
Not something fantastic. I just realize this. :p

DirectAdmin Reset Folder Recursively

(This is just a not for myself.)

Parameters to append to links to reset folders recursively.

[jQuery] Mouseover Fade for all Children Element

Heres a very simple script for those who looking for jQuery script that
Applies mouseover / mouseout fade,For all elements in a container. Note: Just need replace the parent-class-to-apply-effect with the class of the parent container that you want to apply to.

jQuery(document).ready(function() { jQuery.each(jQuery('.parent-class-to-apply-effect').children(), function() { jQuery(this).mouseover(function() { jQuery(this).fadeTo('slow', 0.8); }).mouseout(function() { jQuery(this).fadeTo("slow", 1.0); }); }); });

[Zend] 'Plugin by name 'JQuery' was not found in the registry

Got this error while trying around with Zend.
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'JQuery' was not found in the registry; used paths:Zend_View_Helper_:
Zend/View/Helper/:/public_html/staging/app/views/helpers/:/public_html/staging/app/modules/default/views/helpers/' in /public_html/staging/lib/Zend/Loader/PluginLoader.php:412
Stack trace: #0
/public_html/staging/lib/Zend/View/Abstract.php(1174): Zend_Loader_PluginLoader->load('JQuery') #1
/public_html/staging/lib/Zend/View/Abstract.php(610): Zend_View_Abstract->_getPlugin('helper', 'jQuery') #2
/public_html/staging/lib/Zend/View/Abstract.php(336): Zend_View_Abstract->getHelper('jQuery') #3
/public_html/staging/app/modules/default/layouts/public.phtml(19): Zend_View_Abstract->__call('jQuery', Array) #4
in/public_html/staging/lib/Zend/Loader/PluginLoader.php on line 412

Googled around and found out tha…

[Eclipse] Zend PDT installation error

Got this error while trying to install Zend PDT plugin for Eclipse:
An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.zend.php.debug.debugger,5.3.18.v20110322
No repository found containing: osgi.bundle,org.zend.php.debug.debugger.win32.x86,5.3.18.v20110322
No repository found containing: org.eclipse.update.feature,org.zend.php.debug_feature,5.3.18.v20110322
Googled around and found the workaround to solve this. Apparently, we just need to get the features jar, the plugin jar and the platform specific plugin. And all these are available on Zend download sites.

Missing files - Feature
Download org.zend.php.debug_feature_<required-version> from the feature jar into "/features" folder of eclipse folder.

Missing files - Plugins
Download org.zend.php.debug.deb…

The Manual Way to Hide / Remove reCaptcha Audio

Was trying to disable the audio option for reCaptcha, but couldn't find the official way to do so.

So in the end, I used the old-school javascript + CSS method to hide the buttons.

Hiding the buttons

Add this code snipped anywhere after the reCaptcha code.

<script type="text/javascript"> jQuery(document).ready(function(){ document.getElementById('recaptcha_switch_audio_btn').style.display="none"; document.getElementById('recaptcha_reload_btn').style.display="none"; document.getElementById('recaptcha_whatsthis_btn').style.display="none"; }); </script>

Filling ackground color

Now  we have a empty space in the column where the buttons are. So just use CSS to replace the color.

#recaptcha_table tr {background:#dfdfdf;}

There you go, a reCaptcha with no audio option.


[Tutorial] Getting Started Zend Framework 1.11

Note: This guide is still at the initial writups.
This tutorial is intended to guide beginners through the basic steps to setup a database driven website (without using Zend_tools command).


Zend Framework 1.11.10+ FullPHP 5.3+(Optional) Zend Eclipse Plugin / Zend Studio (30-days trial)  
The tutorial is divided into the following sub-sections
1. Download and Zend Framework setup.
2. Modularize directory structure
3. Database(s) setup
4. Account component
5. Helpers

1. Setting up Subversion SVN




Fat-Free Framework

There are many frameworks out there that help to speed up web development. However, many frameworks has grown too complex and fat because there are too many unused classes and functions in it.

Heres a good write-up on the comparison between various PHP framework, and the memory that they used.

Came across this particular framework, called Fat-Free Framework.

It is interesting because its

designed ground up for PHP5.3, in-built ORM DB support, (i.e. SQL)in-built NoSQL support, (i.e. MongoDB)super small footprint,  Will do a write-up again after hands-on with this new framework.

[Magento] Create Contact Form with Dynamic Recipient

There are many ways of creating contact forms to email to multiple recipient. I'm going to describe a way that uses Javascript a the frontend to change the target recipient.

Advantage of this method:
Easy to add in new emails in the future.Disadvantage of this method: For those who are particularly concern email privacy, you might not want to use this method. You can modify the email checking to the backend (controller) instead.

Okay enough talking, lets get started.

Step 1: Set up HTML form fields

I'm going to use an example of drop down select to change the email. Of course, this is fairly easy to modify with other forms as well.

Open up app/design/frontend/default/<theme>/template/contacts/contacts.phtml
Insert the following snippets anywhere between the <form>...</form> tag.

<select name="interest" id="interest" title="<?php echo Mage::helper('contacts')->__('Please select department to contact') ?>" va…

[Magento] Default Search / Mini Search returns 0 results

Was debugging this weird problem with a client's Magento site.

The Mini Search (and the default search - is not returning the correct result.

Surprisingly the advanced search is working fine.

After trying out all sort of methods, finding and editing the .phtml, .xml files. I found out that its one of the core files that causes this issue.


Open up app/code/core/Mage/CatalogSearch/Block/Result.php

Uncomment line 149 and 150
//        $this->getListBlock()
//           ->setCollection($this->_getProductCollection());

Then change line 172
$this->_productCollection = $this->getListBlock()->getLoadedProductCollection(); to
$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();
That solves the search problem.


Acajoom Installation Error Fix

Was upgrading Acajoom GPL 3.2.7 to Acajoom 5.2.0 and encountered the following errors.

JInstaller::install: SQL Error. DB function failed with error number 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 35 SQL=CREATE TABLE IF NOT EXISTS `z1ck_acajoom_lists` ( `id` int(10) NOT NULL auto_increment, `list_name` varchar(101) NOT NULL default '', `list_desc` text NOT NULL, `list_type` tinyint(2) NOT NULL default '0', `sendername` varchar(64) NOT NULL default '', `senderemail` varchar(64) NOT NULL default '', `bounceadres` varchar(64) NOT NULL default '', `layout` text NOT NULL, `template` int(9) NOT NULL default '0', `subscribemessage` text NOT NULL, `unsubscribemessage` text NOT NULL, `unsubscribesend` tinyint(1) NOT NULL default '1', `auto_add` tinyint(1) NOT NULL default '0', `user_choose` tinyint(1) NOT N…

[Android] Market 3.0.26

The new Android Market version 3.0.26 is out in But too bad, as usual, Google limits it by devices.

Google Announced it on July 12. But until today, its still not available for my SGS and SGS2.

Google says "The new Android Market will be rolling out in the coming weeks to Android 2.2 and higher phones around the world". But for those who wants to try it now, you can download it HERE.


(In case you decides to use the old market, you can do so by uninstall in Settings -> Manage Applications -> select Market App -> Uninstall)

Raspberry Pi - Alpha board in production

There are progress on Raspberry Pi - the alpha boards are in production!

For those who don't know about this $25 PC, can read about it here:

I was very excited when saw the official announcement of the board production.

Imagine the possibilities this project/product opens up - Smart home, smart appliances... You can turn almost everything into "smart" devices, with just $25.

The spec is good enough for small application to run off.

700 MHz ARM processor.256MB RAM. That's even better than some of the smartphones out there!
Can see that this would be a hot cake for a lot of developers out there!

Google Plus Android APK

UPDATE 28th July - The official app is available in most countries already. So download from Android market instead.

The official Google+ Android is only available in certain regions.

But, fear not, XDA member sacredsoul, has got his hand on the unofficial Google Plus APK for international Android users.

I've tried it on my Galaxy S i9000, and it works perfectly fine.

Get yours from XDA forum

[Virtuemart] Refused to set unsafe header "Connection"

While I was working on a Joomla 1.5.18, Virtuemart 1.1.4 website, I encounter this problem of "not able to add to cart" problem with Virtuemart.

When "Inspect Element" in Chrome, I got the following error
Refused to set unsafe header "Connection"
XMLHttpRequest cannot load Origin is not allowed by Access-Control-Allow-Origin.
Apparently, after debugging for a while, I found out that for Ajax calls, and are considered different domain, thus the considered as unsafe "Connection"


The solution for this is pretty straight forward - make sure you are at the correct domain. To do this, create/add the following code in the .htaccess file in your public_html directory.
RewriteEngine on
RewriteCond %{http_host} ^$ [nc]
RewriteRule ^(.*)$$1 [r=301,nc] Note: Replace with your domain.

That is by far the easiest way to solve th…

[Virtuemart] Error: $("vmlp_search_str").addEvent is not a function

Got this error while working on a Joomla 1.5.18, Virtuemart 1.1.4 website.

Error: $("vmlp_search_str").addEvent is not a function
Source File:
Line: 110
After debugging for a while. I found out that apparently there are conflicts between jQuery and Mootools (or other scripts).

To solve this, just need to add in the following scripts after jQuery import.
<script type="text/javascript">jQuery.noConflict();</script>
Hope that helps those who new to HTML, Javascript.

Samsung Galaxy S i9000 Gingerbread (Android 2.3) Flashing Guide

Important Note:
The following guide is for Indonesia, Malaysia, Singapore, Thailand, Vietnam.Please remember that flashing your mobile phone is fully on your own risk. If the process is interupted (power failure, disconnected cable, software failure) your phone might be very dificult to revive.Don't confuse this guide for Samsung Galaxy S II. This is for the old old Samsung Galaxy S I.
Make sure you disabled any "lag fix" that you've applied to your phone.

Step 1

Download the firmware and Odin (flashing program)
Firmware + Odin. (May 15, 2011 - I9000DXJV9 Mirror 1 | Mirror 2)
Step 2

Prepare the flashing program.
Extract the above file.Run Odin3 v1.82.exeClick on PDA, select the file JV9_JV9_JV9.tarMake sure only "Auto Reboot" and "F. Reset Time" is selected.
Step 3

Prepare you phone in "Download Mode"
Turn off your phone.Press "Volume Down" + "Home" + "Power" buttons together.(You should see the following …

[Solution] Google 550 Authentication required

Was having issue with Google Apps email recently. The email kept on bounce back with the following error.
Delivery to the following recipient failed permanently:

Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the recipient domain. We recommend contacting the other email provider for further information about the cause of this error. The error that the other server returned was: 550 550 authentication required (state 14).
Step 1 : (Basic) Check your MX record.

This is probably the basic step that most people already did. Skip if you have already setup.
Check your MX records - Google Mail records -

Step 2 : Google SPF TXT record

For me, this help solves my problem. Although I'm not entirely sure why some of my other Google Apps email works without this TXT record.
Check your TXT records - Googl…


Been having problem with Facebook Apps auto-resize and tried to remove annoying vertical scrollbar.

After Googled for a while, found the following snippet. Its a simple hack that works perfectly!

<div id="fb-root"></div> <script src=""></script> <script> FB.init({ appId : 'YOUR-APP-ID-HERE', status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); </script> <script type="text/javascript"> window.fbAsyncInit = function() { FB.Canvas.setSize(); } // Do things that will sometimes call sizeChangeCallback() function sizeChangeCallback() { FB.Canvas.setSize(); } </script>

New Gingerbread Update for Samsung Galaxy S Leaks

Yup, despite Sammy’s apparent inability to roll out Froyo updates on time, download links have popped up all over the internet this week, which provide access to a leaked official Gingerbread update to the I9000 model of its Galaxy S family.
This may not be the first Gingerbread update to have been leaked for the device but the release is great news for developers and owners of the device alike, as it means that Android 2.3.3 has been tailored by Samsung specifically for its phones and that the update should roll out to all devices shortly... more

Although the thread is now closed, but the ROMs already leaked far into many ROM chefs' hand.

So, I would still expect custom Gingerbread ROM for Galaxy S to be out in a month time. Excited :)

[Excel] Formula to extract email from a cell

This is a useful formula to extract an email out from the string in a cell.

=TRIM(MID(SUBSTITUTE(" "&$A1&" "," ",REPT(" ",40)),FIND(REPT("@",COLUMNS($A1:A1)),SUBSTITUTE(SUBSTITUTE(" "&$A1&" "," ",REPT(" ",40)),"@",REPT("@",COLUMNS($A1:A1)),COLUMNS($A1:A1)))-40,80))

Landing Page -

This infographic from Formstack shows the 10 key landing page features that draws users attention on your site.

Magento Connect Error

Was trying to install Magento Extensions and found out that the extensions key were not working for Magento Connect 1.0.

After searching for a while, found out that you can actually prepends "" to the extension name (source).

From: magento-community/Fontis_Wysiwyg
And that is actually the extension key for Magento Connect 2.0.

Guess both extension keys works!

The 20 Countries With the Highest Per Capita Cell-Phone Use


Find that the slides are hard to read or compare. So decided to consolidate the statistic under a single post.

Mobile-phone penetration: 233 percent
Population: 4.6 million
Subscriptions: 10.7 million
Annual growth 2004-2009: 24 percent
Ratio of mobile to fixed line: 6.8:1
Estimated Internet users per 100 people: 75

Mobile-phone penetration: 210 percent
Population: 620,000
Subscriptions: 1.3 million
Annual growth 2004-2009: 22 percent
Ratio of mobile to fixed line: 7.5:1
Estimated Internet users per 100 people: 45

Mobile-phone penetration: 185 percent
Population: 540,000
Subscriptions: 1 million
Annual growth 2004-2009: 19 percent
Ratio of mobile to fixed line: 6.1:1
Estimated Internet users per 100 people: 50

Mobile-phone penetration: 181 percent
Population: 60,000
Subscriptions: 108,700
Annual growth 2004-2009: 26 percent
Ratio of mobile to fixed line: 3:1
Estimated In…

Samsung Kies is out

Grab it here!