2014年6月30日 星期一

APACHE 2.4 with PHP-FPM on Debian

Packages:

apache=2.4.9-2
apache-mpm-worker=2.4.9-2
libapache2-mod-fastcgi
php5=5.6.0
php5-cgi=5.6.0
php5-fpm=5.6.0


enable required modules

sudo a2enmod fastcgi alias actions


Start php5-fpm service

sudo service php5-fpm start

Config apache


Create the php-fpm configuration file.

Either:
1. put the snippet in conf-available/php-fpm.conf
    and use a2enconf php-fpm
or
2. put the snippet in conf.d/<your-file-name>
    and include it in your virtual host

Use phpinfo(); to Make sure apache is using PHP-FPM

2013年12月31日 星期二

Big Endian vs Little Endian

Data stores in memory split in Bytes

Endianness:Order of bytes (of data) in memory

Big Endian stores Most significant byte First
Little Endian stores Least significant Byte First

Network: Big Endian
PCM: Little Endian
X86: Little Endian
Src:http://www.raywenderlich.com/12910/how-to-make-a-simple-playing-card-game-with-multiplayer-and-bluetooth-part-3/big-endian-vs-little-endian

2013年12月2日 星期一

PHP uninitialized variable evaluation


php > $user;
php > print var_dump(!$user);
PHP Notice: Undefined variable: user in php shell code on line 1
bool(true)
php > print var_dump($user);
PHP Notice: Undefined variable: user in php shell code on line 1
NULL

php > print var_dump(empty($user));
bool(true)




uninialized variable evaluates to NULL (with notice)

!$var evaluates to True

empty($var) evaluates to True

2013年11月27日 星期三

Python String Encoding Conversion (UTF-8/ANSI)

**Python String are recorded in UNICODE internally

Reading file encoded in UTF-8:


with open(fileName,'r') as f:
    for line in f.readlines():
        print line.decode("UTF-8")




2013年9月12日 星期四

Bind bash keyboard shortcut to delete word to slash

add the following line in ~/.bashrc


bind '\C-f:unix-filename-rubout'


Ctrl+F is bound to delete till previous slash