jQuery search element and count

參考: http://api.jquery.com/contains-selector/

$("div:contains('james')").length

jQuery UI Dialog button id

參考: http://jqueryui.com/demos/dialog/


$("dialog").dialog({
    buttons: [
        {
            id: "close-btn",
            text: "Close",
            click: function(){...}
        }
    ]
});

FreeBSD Git Step

設定Repo初始專案

  1. 先在git/repo底下建立專案
    git/repo/tms.git
  2. 初始並指定為工作程式庫
    git init --bare
  3. 初始程式將程式上傳至tms.git, 假設程試放在 usr/loca/www/tms 進入該目錄下以下指令.
    git init
    git add .
    git commit -m 'Init TMS'
    git remote add tms git@james.tw:cms/tms.git(第一次使用)
    git push tms master



GITWEB
http://james.tw/git/

git 網址
git://james.tw/cms/tms.git

開始版本控制
1. 先裝git, 啟用git.
2. 假設放在www底下, 先切到/usr/local/www底下然後拷貝一份回來
git clone git://james.tw/cms/tms.git [rename]
3. 拷貝完後會產生tms資料夾, 進去先到.git/config新增user資料, 這樣當你在push到master時就會出現是誰改的.
[user]
   name  = James Li
   email = jamesycli@james.tw
4. 現在新增一個remote假設叫james那我就鍵入以下指令, 你也可以保持原本的origin, 也可以用專案名來設定, 叫tms
git remote add james git@james.tw:cms/tms.git
如果你想查看remote有誰只要打git remote就會看到有幾個remote
5. 每次要上傳資料前先把資料從伺服器拉回來更新”pull”, 假設要同步master就鍵入以下指令
git pull tms master
它會把資料從tms.git抓master回來和你的資料更新.
6. 然後你要現在要新增資料, 要更新資料回伺服器. 首頁先用”add”,
git add .
這個指令是指全部資料夾都更新, 注意有一個”點”在最後面
git add index.php
這個指令則指定某檔案, 指定完要新增commit 這樣才不會忘了做了什麼.
git commit –m ‘Update Index.php’
最後要push它們上git server啦, 鍵入以下指令.
git push tms master
這樣你add的檔案就會同步到git server了
7. 如果你不想同步某個檔案/資料夾, 在tms底下新增一個.gitignore然後輸入你不想同步的檔案或資料夾
tms/index.php
!tms/index.php
如果有加驚嘆號, 應該是排除要不同步的意思吧~

W3C驗證, GZIP驗證



測試網站HTML, CSS是否正確符合WWW規範.
http://validator.w3.org/


測試網站是否開啟GZIP
http://www.gidnetwork.com/tools/gzip-test.php

Apache 設定網頁快取, 壓縮

為了幫首頁減肥, 
除了更改HTML, CSS, JavaScript外
還要壓縮這些檔


今天我們要設定 Apache 的快取和壓縮
確定以下模組有安裝

mod_deflate.so
mod_expires.so
mod_headers.so


然後網站目錄的 .htaccess 加入以下
# 這裡設定快取的類型和快取時間

<IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/gif A604800
        ExpiresByType image/png A604800
        ExpiresByType image/jpg A604800
        ExpiresByType image/jpeg A604800
        ExpiresByType image/x-icon A604800
        ExpiresByType application/x-javascript A604800
        ExpiresByType application/javascript A604800
        ExpiresByType text/javascript A604800
        ExpiresByType text/css A604800
        ExpiresByType text/html A604800
</IfModule>
# 這裡設定壓縮
<IfModule mod_deflate.c>
        SetOutputFilter DEFLATE
        AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpg image/jpeg image/png application/x-javascript text/javascript application/javascript
</ifModule>

FreeBSD phpDocumentor 安裝


phpDocumentor
讓你要交接程式時可以快速了解你的程式碼.
  1. 更新 ports
    cvsup -g -L 2 ports-supfile
  2. 安裝  PEAR
    /usr/port/devel/pear
    make install clean
  3. 利用 PEAR 安裝 PhpDocumentor 使用以下指令
    pear install PhpDocumentor
  4. 完成安裝, 使用使用 phpdoc 下指令.

參考網址:
http://www.phpdoc.org/