No gcc on ec2 instance
What I picked is Basic 32-bit Amazon Linux AMI 2011.02.1 Beta (AMI Id: ami-6af08e38) Try to install mysql-python using easy_install, but get the following error, unable to execute gcc: No such file or directory error: command ‘gcc’ failed with exit status 1 Finally figure out there is not gcc on the instance I picked. The solution is easy, yum install gcc Cheers!
Continue Reading »Quick Note 040411
Use smarty function to check if a smarty variable has been set. if($smarty->get_template_vars(‘some_var’) == ‘off’) //do something if ($smarty->get_template_vars(‘some_var’) === null) //mean smarty variable, some_var is not set use === or !== instead of == or != Says, $foo = true; $foo != ‘hello world’ is not true. So you have to do the following, $foo = true; if($foo !== ‘hello_world’){ echo $foo; }
Continue Reading »Order by field
Ordering by the order of values in a SQL IN() Clause, which can be done by ‘order by field(id, [ids from first])’. For example, $enames = array(‘a’,'b’,'d’); $sql = “SELECT name from employees WHERE name in (‘” . implode(“‘,’”,$enames) . “‘) ORDER BY FIELD(name, ‘” .implode(“‘,’”,$enames). “‘)”; Nice! Ref – http://stackoverflow.com/questions/396748/ordering-by-the-order-of-values-in-a-sql-in-clause
Continue Reading »jQuery open external link in new window
I hate every links on a web page to open in a new window like most Chinese websites do. But I also believe it should be a standard that the external link should open in a new window. Because if you don’t do that, after visitors click an external link, they will jump out of your website, and then the only way to go back to your website is clicking back button. If they close [...]
Continue Reading »max_execution_time vs default_socket_timeout
The default setting in php.ini, max_execution_time = 30 default_socket_timeout = 60 For example, your script need to do socket based streams, which takes 45 seconds, will script timeout because the max_execution_time is 30 seconds? The answer is NO, because max_execution_time is not affected by system calls or stream operation. Another important note is that default_socket_timeout is counting before socket responds, as long as it gets response, it will wait forever.
Continue Reading »406 error to retrieve jquery.cookie.js file
In a project, I need to use jquery.cookie.js file. It’s weird that this file is already uploaded to the server, and I just could not retrieve it, but got 406 Error. The following is the message I got from Firefox: Not Acceptable An appropriate representation of the requested resource /wocai/jquery.cookie.js could not be found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. [...]
Continue Reading »PHP Memory Error
Got PHP fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in /usr/share/pear/Zend/Search/Lucene/Field.php on line 98 Which is not necessary happened to Lucene Script, and it could happen to any script requiring a ton of memory to run, for example parsing a large of XML file. If you see this error, first check your php.ini file. Looking for “memory_limit”, Mine was set to 128M, which is pretty high already. But [...]
Continue Reading »PHP Perl Syntax Check
You can do PHP or Per syntax check under Command line as the following, Check PHP Syntax php -l filename.php Too bad, by -l option, you can see the details, but “Errors parsing filename.php”. To see the detail, you can look into the error log, usually it is phpapplication.log under /var/log/httpd/. Another note is that if display_errors is set to off in your php.ini file, you will not able to see the phrase error even [...]
Continue Reading »Step by Step to Post to Facebook Wall using PHP
Set up new App Go at http://www.facebook.com/developers/, which requires some verification, either using your cell phone or your credit card. And then follow the instruction, you should be able to get FB_APIKEY and FB_SECRET keys. Download Facebook API Library The API library (facebox-platform) used in this tutorial is kinda old. Looks like Facebook has removed it. You can get it at Github. Get Permission Before your App can access to any Facebook account, you need [...]
Continue Reading »Some important notes of html form
enctype if you don’t specify the enctype, then it uses “application/x-www-form-urlencoded” by default. If you cannot figure why your form cannot upload file, first thing you need to check is if you have set enctype to “multipart/form-data”. Yes, “mulipart/form-data” is a required enctype to upload your file. Seems there is not different between “application/x-www-form-urlencoded” and “plain/text”, although W3School says, in the case of the former, all characters are encoded before sent, and in the case [...]
Continue Reading »








