Apr 21, 2011

No gcc on ec2 instance

notepad

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 »
Apr 4, 2011

Quick Note 040411

notepad

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 »
Mar 2, 2011

Order by field

mysql1

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 »
Feb 1, 2011

jQuery open external link in new window

jquery

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 »
Jan 31, 2011

max_execution_time vs default_socket_timeout

php

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 »
Jan 25, 2011

406 error to retrieve jquery.cookie.js file

notepad

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 »
Jan 25, 2011

PHP Memory Error

memory

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 »
Jan 24, 2011

PHP Perl Syntax Check

notepad

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 »
Jan 15, 2011

Step by Step to Post to Facebook Wall using PHP

facebook-apps

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 »
Jan 14, 2011

Some important notes of html form

html-icons-veerle

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 »
Pages:12345»