Tuesday, September 06, 2011

CentOS install node.js

Basically, follow the installation guide in the node.js GitHub wiki page. I use the "Building from source" guide. Then install npm, follow the guide too, just easy type with "curl http://npmjs.org/install.sh | sh"

When I test nmp installation (install express), I found that I should type 'npm install -g express', and the express will be installed in the directory which I want. Otherwise, nmp will install locally (such as: ./node_modules/).

Wednesday, August 31, 2011

Install PHPUnit on Windows 7

First you need install a Zend Server in C:\Zend folder

Install Pear

Run commands below

# pear channel-update pear.php.net
# pear upgrade pear
# pear channel-discover pear.phpunit.de
# pear channel-discover pear.symfony-project.com
# pear channel-discover components.ez.no
# pear clear-cache
# pear update-channels
# pear install --alldeps phpunit/PHPUnit

DONE!

Friday, August 26, 2011

32bit 系統下 json_decode 遇到 BIGINT 的問題

在 32bit 系統下處理 Facebook 的 uid 時, 一定會遇到 json_decode 時, php 把 uid 轉成 float 的情形, 大部分的情形只要把 uid 轉成 string 就能做其他的事了, 以下是正確的轉型技巧

$json = '{"uid":100000123456789}';
$arr = json_decode($json, true);
// $arr = array(1) {
//   ["uid"]=>
//   float(1.0000012345678E+14)
// }
$s2 = sprintf ( "%.0f", $arr['uid'] );
// $s2 = string(15) "100000123456789"

Thursday, August 11, 2011

How to login with Administrator account in Thinkpad

単純にadminでログインしたいだけであれば以下の手順でできます。

  1. 「ユーザーアカウント制御設定の変更」からUACを無効化
  2. OS再起動
  3. コマンドプロンプトを起動し以下を入力
    net user administrator /active:yes
  4. 「ユーザーアカウント」にadminが出ることを確認

resource: http://bbs.kakaku.com/bbs/K0000092865/SortID=11470155/

Monday, August 08, 2011

jQuery file upload plugin: AjaxFileUpload

We can use AjaxFileUpload make a file upload process.

Basic usage:
function ajaxFileUpload()
{
  $.ajaxFileUpload({
    url:'upload.php',
    secureuri:false,
    fileElementId:'fileToUpload',
    data:{name:'logan', id:'id'},
    success: function (data, status) {
      alert($(data).text());
    }
  });
  return false;
}

Official Guide have more detail usage.

Wednesday, July 20, 2011

CentOS install Zend Server CE

Follow the official guide "RPM Installation (RHEL, CentOS, Fedora and OEL)" first.

I install Zend Server CE with "Manually Installing Zend Server" guide. But my Zend Server repository is downloaded from here, enter the Linux tab, download the "Zend Server (DEB/RPM Installer Script)" package. Use the "zend.rpm.repo" repository file.

Then, you can finish the installation with "yum install zend-server-ce-php-5.3"

Link the /usr/bin/php to /usr/local/zend/bin/php
ln -s /usr/local/zend/bin/php /usr/bin/php
Or use "ln -f -s /usr/local/zend/bin/php /usr/bin/php"

Troubleshooting:
1. "Cannot load /usr/local/zend/lib/apache2/libphp5.so into server"
    solution: close SELINUX, /etc/selinux/config >> SELINUX="disabled"