Setting virtual host on Mac Leopard

This is a note for adding a friends phpbb forum on my Mac mini which running Leopard.

Upload the phpbb3.0 to "/Library/WebServer/Documents". This folder is as "/var/www" on Ubuntu.

Modified the apache configuration:
$> sudo vim /etc/apache2/extra httpd-vhosts.conf

Add the virtual host setting:


   DocumentRoot "/Library/WebServer/Documents/phpbb"
   ServerName your.url

Then restart the apache server:
$> sudo /usr/sbin/apachectl restart

On Dabian: 新增使用者並且啟動個人網頁

安裝好 Debian,要如何新增使用者 xyz,並啟動 xyz 的個人網頁?

新增使用者

$> adduser xyz

設定密碼則輸入

$> passwd xyz

這時候,在 /home 底下會出現一個 xyz 目錄。

新增 public_html 目錄

進入 /home/xyz 目錄,新增 public_html 目錄

$> cd /home/xyz
$> mkdir public_html

Debian Apache2 加 UserDir

加 links

$> sudo ln -s /etc/apache2/mods-available/userdir.conf /etc/apache2/mods-enabled/userdir.conf
$> sudo ln -s /etc/apache2/mods-available/userdir.load /etc/apache2/mods-enabled/userdir.load

重新啟動 apache2[Read more]

jQury + Ajax : load()

jQuery 裡頭寫 Ajax 比原始的寫法簡單些。我十分需要有從外部載入文件(xml 檔案、html 文件,或是 cgi 程式傳回來的資料)的功能,
load(url, params, callback)
這個功能可以將遠端的 HTML 檔案插入成為目前網頁的一個 DOM 物件。

底下的範例是一個簡單 html 網頁,同樣的,利用 $(fn)。而它所描述的情景就是說:
當 id 為 generate 的元素被點選之後($("#generate").click(fn)),就開始載入不同來源的遠端文件,並且塞入不同 id 的區塊。
$("#phpecho").load("http://localhost/withjs/script.php");
$("#loadxml").load("http://localhost/bibleTest/genesis.xml");
$("#loadhtml").load("http://localhost/happy.html");

這三行都一樣,翻譯成人可以懂的話:jquery 找到 id 為 phpecho、loadxml、loadhtml 三個區塊,然後載入指定網址的內容。

需要提醒的是,Ajax 不允許跨 domain 存取資料,因此,若是您要的遠端在別人家裏,那就要寫 proxy。[Read more]

中文的直式書寫與閱讀

Image of 玄奘西遊記

《玄奘西遊記》作者錢文忠教授在台灣版自序中,有一段關於堅持台灣版必須直式排版的有趣說明「對於出版台灣版,作為書的作者,我反覆強調一個願望,那就是,我堅持要求《玄奘西遊記》的台灣版必須直排。這個要求裡面當然隱含著我對中國文化傳統的珍愛和追慕,我想,這是兩岸讀書人都不難理解的。同時,卻也還有一點小小的原因...」

錢教授提到,「曾經有一位大學者,早年曾向熊十力先生請教。他對熊十力先生滔滔不絕的批評自己讀過的一部古書。不料,熊十力先生拍案大怒:你讀書應該先讀出書的好來,還沒讀透就肆意,難道這算是讀書嗎!?」[Read more]

jQury: when DOM is ready

當 HTML 文件的 DOM 準備好之後,有趣的事情就要發生,怎麼做呢?把要做的東西放到下面 "do stuff when DOM is ready" 的地方:

$(document).ready(function() {
   // do stuff when DOM is ready
 });

不過這樣寫也可以,也就是所謂 $(fn) 的方式,"fn" 指的就是一個 javascript function

$(function() {
   // code to execute when the DOM is ready
 });

我當然是選後者來用。

Ruby on Rails tutorial

I think I need a good online reference for coding ROR. The followings are what I have found:
http://www.tutorialspoint.com/ruby-on-rails/index.htm
http://www.meshplex.org/wiki/Ruby/Ruby_on_Rails_programming_tutorials

檢查目前正在使用的 Rails 環境版本

How to check the versions of Rails components of your developing applications are using?
如何檢查正在開發的應用程式所使用的 Rails 元件的版本?

It's is quiet easy. Open your terminal panel and enter the application folder you're developing.
這很簡單。打開的 terminal 視窗,進入正在開發的應用程式目錄。

Then enter: $ > ruby script/about . It will show all the information you need
然後輸入: $ > ruby script/about 。所要的訊息就會顯示。[Read more]