Nginx + PHP-FPM on Ubuntu Precise

Previous post: Nginx – Installation on Ubuntu Precise

Most of the time we would like to run PHP on our web server. After you have installed Nginx following the post above. We can now enable PHP.

1. Install the PHP packages.

apt-get install php5-fpm
apt-get install php5-cli
apt-get install php5-gd
apt-get install php-pear

Continue reading Nginx + PHP-FPM on Ubuntu Precise

Nginx – Installation on Ubuntu Precise

I have heard Nginx for several years and finally i got the motive to start playing with it. Here the steps to install Nginx on Ubuntu 12.04.01 LTS server (Ubuntu Precise).

1. Update the repositories with the root privilege.

apt-get update

Continue reading Nginx – Installation on Ubuntu Precise

Javascript – Get YYYY-MM-DD string from a Date object

The following piece of code shows you how to get the YYYY-MM-DD formatted string from a Javascript Date Object.

// GET CURRENT DATE
var date = new Date();

// GET YYYY, MM AND DD FROM THE DATE OBJECT
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth()+1).toString();
var dd  = date.getDate().toString();

// CONVERT mm AND dd INTO chars
var mmChars = mm.split('');
var ddChars = dd.split('');

// CONCAT THE STRINGS IN YYYY-MM-DD FORMAT
var datestring = yyyy + '-' + (mmChars[1]?mm:"0"+mmChars[0]) + '-' + (ddChars[1]?dd:"0"+ddChars[0]);

 

Done =)

Reference: StackOverflow – Get String in YYYYMMDD format from JS date object?

陶傑 – 絕症

強國的貪污和腐朽,已成癌症末期的絕症。原因是什麼,陳皮的濫調:因為信仰真空,道德淪亡

一個民族要正常生存,要有一點基本的信仰。因為人性有貪婪、腐惡、仇恨的原罪,信仰是約束人性陰暗面的白血球。

當然,信仰若趨向極端,就如同白血球過多,開始變成血癌。塔利班何嘗不是由可蘭經的信仰開始?

鄰近地區何時起沒有了信仰?由他們的領袖「解放」了強國,繼而發動「文革」開始。毛帝用人類史上最無法想像的暴政摧毀了他統治的國家,一人力量有限,他靠的是基因,千年的一個奴才集團和億萬的愚民幫助他執行。毛帝和他的強國人民,另行建立了一個走火入魔像邪教般的信仰系統,直到鄧小平出來,「貧窮不是社會主義」,把強國人從邪夢叫醒。
Continue reading 陶傑 – 絕症

陶傑 – 看臉色的學問

中國副總理李克強先生訪問香港大學,香港警方保安過度,內部有指示,稱保安的程度一定不可以令李克強「難堪」。

這句話被監警會主席翟紹唐駁斥,指為多餘。

翟主席是律師,提出這句話有問題,很有見地。問題在哪裏?在於警方無法揣摩李克強副總理在什麼時候才覺得難堪。
Continue reading 陶傑 – 看臉色的學問

Drupal 7 – Render Views Exposed Filter programmatically

Update at 2015-04-27: Another suggestion by Petu which could render the filter as a block programmatically.

Update at 2014-09-18: An simpler way to do that is to enable the Exposed form in block in the view settings and then render the block as suggested by plano.com.

The following piece of code render the Views Exposed Filter.

$view = views_get_view('<view name>');
$display_id = 'page';
$view->set_display($display_id);
$view->init_handlers();
$form_state = array(
  'view' => $view,
  'display' => $view->display_handler->display,
  'exposed_form_plugin' => $view->display_handler->get_plugin('exposed_form'),
  'method' => 'get',
  'rerender' => TRUE,
  'no_redirect' => TRUE,
);
$form = drupal_build_form('views_exposed_form', $form_state);
print drupal_render($form);

 

Done =)

Reference:

Drupal 7 – Get Facebook Page feeds by Aggregator

You can get the Facebook Page content by the following URLs:

RSS 2.0
http://www.facebook.com/feeds/page.php?format=rss20&id=[fb-page-id]
Atom 1.0
http://www.facebook.com/feeds/page.php?format=atom10&id=[fb-page-id]

 

Where the [fb-page-id] could be found by browsing your Facebook Page -> Edit Page. That URL should have the following format.

https://www.facebook.com/pages/edit/?id=%5Bfb-page-id%5D&sk=basic

Continue reading Drupal 7 – Get Facebook Page feeds by Aggregator

Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

We talk about how to generate a taxonomy term selection list in the following post.
Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

So we continue to add the jQuery/Javascript code such that when the term is selected, the browser will open the corresponding term page.

The following piece of jQuery/Javascript is redirect you to the selected term page.
Continue reading Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

Next: Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 2

I want to create a HTML selection list which contains the taxonomy terms of a vocabulary. When a option is selected, the browser will go to the selected term page. In this post, i would like to share how to generate a selection list by PHP.

I have a vocabulary which has terms in 2-level. The selection list could generated as follow.
Continue reading Drupal 7 – Create a taxonomy term selection list of a specific vocabulary @ 1

Dream BIG and go for it =)