pretty code

2016年8月24日 星期三

npm uninstall all

使用 node.js 時,如果想要一口氣刪除所有的 module,可以使用下列方式

進到 node_modules 資料夾
使用 PowerShell 執行下列命令
npm uninstall (Get-ChildItem).Name

2016年8月19日 星期五

nginx 設定 PHP

假設在 nginx 設定 php 遇到奇怪的問題
比如 query string , path info 等值取不到
大部份都是設定檔的問題
其中順序也會影響
留著備忘參考

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
    return 404;
}

fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;

fastcgi_read_timeout 3610;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9090;

Golang on Ubuntu

假設在 Ubuntu 安裝完 Golang
可以用 go env GOROOT
來確定 golang 安裝的路徑

接著執行下面指令,就可以開始使用 golang 了

export GOROOT=/usr/loca/golang-1.6(假設查出來是此目錄)
export GOPATH=$HOME/GoHome
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

2016年8月16日 星期二

Alternate Domain Names

一般來說,在設定 CDN 時有 2 種方式:

1. 直接將 CDN 給的 domain 拿來做 URL,假設 CDN 的 domain 是 abc.com,則要做 CDN 的檔案的 URL 都是 abc.com/xxxx。
2. 仍然使用自己的 domain,假設自己的 domain 是 def.com,需要在 DNS 服務提供者建立一筆 CNAME record,此時 def.com/xxx 的 URL 便會導向到 abc.com/xxx。