2011-05-23 17:07

CSS Selector 優先權計算表

資料來源:小繁的blog
2011-05-19 13:16

Hotmail, Yahoo!Mail, Gmail 郵件CSS樣式表

轉載自:
Guide to CSS support in email clients - Articles & Tips - Campaign Monitor
CSS support in HTML emails of Hotmail, Yahoo! Mail and Gmail

style element Gmail Hotmail Yahoo! Mail
<style> element in the <head> No No Yes, but...
<style> element in the <body> No Yes, but... Yes, but...
link element Gmail Hotmail Yahoo! Mail
<link> element in the <head> No No No
<link> element in the <body> No No No
CSS selector Gmail Hotmail Yahoo! Mail
* untestable Yes Yes, but...
e untestable Yes Yes, but...
e > f untestable No Yes, but...
e:link untestable Yes Yes, but...
e:active, e:hover untestable Yes Yes, but...
e:focus untestable No Yes, but...
e:lang© untestable No Yes, but...
e+f untestable Yes Yes, but...
e[foo] untestable Yes Yes, but...
e.className untestable Yes Yes, but...
e#id untestable Yes Yes, but...
e:first-line untestable Yes Yes, but...
e:first-letter untestable Yes Yes, but...
CSS property Gmail Hotmail Yahoo! Mail
background-color Yes Yes Yes
background-image No Yes, but... Yes
background-position No No No
background-repeat No Yes Yes
border Yes Yes Yes
border-collapse Yes Yes Yes
border-spacing Yes No Yes
bottom No Yes Yes
caption-side Yes No Yes
clear No Yes Yes
clip No Yes, but... Yes, but...
color Yes Yes Yes
cursor No Yes Yes
direction Yes Yes Yes
display No Yes Yes
empty-cells Yes No Yes
filter No No Yes
float No Yes Yes
font-family No Yes Yes
font-size Yes Yes Yes
font-style Yes Yes Yes
font-variant Yes Yes Yes
font-weight Yes Yes Yes
height No Yes Yes
left No Yes Yes
letter-spacing Yes Yes Yes
line-height Yes Yes Yes
list-style-image No Yes, but... Yes
list-style-position Yes No No
list-style-type Yes Yes Yes
margin Yes No Yes
opacity No No Yes
overflow Yes Yes Yes
padding Yes Yes Yes
position No No No
right No Yes Yes
table-layout Yes Yes Yes
text-align Yes Yes Yes
text-decoration Yes Yes Yes
text-indent Yes Yes Yes
text-transform Yes Yes Yes
top No Yes Yes
vertical-align Yes Yes Yes
visibility No Yes Yes
white-space Yes Yes Yes
width Yes Yes Yes
word-spacing Yes Yes Yes
z-index No Yes Yes
Others Gmail Hotmail Yahoo! Mail
@import untestable No No
IE Mac hack No No Yes
javascript in url() No No No
url() No No Yes
Inline comments No No Yes
2011-05-19 12:06

[JavaScript] zerofill 以零填滿指定位數

function zerofill(num,length){
    num=""+num;
    while(num.length<length){num="0"+num;}
    return num;
} 
2011-04-19 09:54

[Oracle] PDO-OCI 的 DSN 連接字串

最近重裝我的開發環境,結果連 oracle 一直連不上,出現了以下幾種訊息,最後是因為我的 TNS listener 沒設好,或是我的 DSN 錯誤,整理出我試過的幾個 DSN 連接字串:

ORA-12154: TNS:could not resolve service name
ORA-06401: NETCMN: invalid driver designator
ORA-12514: TNS:listener could not resolve SERVICE_NAME
ORA-12505: TNS:listener could not resolve SID given in connect descriptor

$DSN="oci:dbname=jaxdb;charset=utf-8";

$DSN="oci:dbname=127.0.0.1:1521/jaxdb;charset=utf-8";

$DSN = "oci:dbname=(
    DESCRIPTION = (
        ADDRESS_LIST = (
            ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)
        )
    )(CONNECT_DATA=
        (SID = jaxdb)
    )
);charset=utf8";
    
$DSN = "oci:dbname=(
    DESCRIPTION = (
        ADDRESS_LIST = (
            ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)
        )
    )(CONNECT_DATA=
        (SERVICE_NAME = jaxdb)
    )
);charset=utf8";
2011-04-15 13:16

[PHP] 計算時間的秒數

/*計算時間的秒數*/
function timeStrToSecs($timeStr) {
    return strtotime($timeStr)-strtotime('today');   
}

/*show*/
var_dump(timeStrToSecs('00:01:22'));
2011-04-10 23:46

Facebook 推文按鈕 失效了

之前寫過Blogger 的標題加上 Facebook 官方的推文按鈕這篇文章
最近 blogger 加了新功能用 ajax 換頁
結果 Facebook 推文按鈕在第二頁就完全不會動了

Google 一下找到 保留 Blogger Ajax 換頁功能,觸發自訂 JS 功能做法這篇文章

在範本中加入以下程式碼就好了:
<img onload='if(FB){FB.Share.stopScan();}' src='http://www.blogblog.com/1kt/transparent/white80.png' width='0' />
2011-04-07 17:25

[轉載][Shell] if 條件式選項列表

轉載自:利用 test 指令的測試功能 - 鳥哥的 Linux 私房菜 -- 學習 Shell Scripts

1. 關於某個檔名的『檔案類型』判斷
標誌意義範例
-e$FILE 是否存在?(常用)if[ -e $FILE ]; then
-f$FILE 是否存在且為檔案(file)?(常用)if[ -f $FILE ]; then
-d$FILE 是否存在且為目錄(directory)?(常用)if[ -d $FILE ]; then
-b$FILE 是否存在且為一個 block device 裝置?if[ -b $FILE ]; then
-c$FILE 是否存在且為一個 character device 裝置?if[ -c $FILE ]; then
-S$FILE 是否存在且為一個 Socket 檔案?if[ -S $FILE ]; then
-p$FILE 是否存在且為一個 FIFO (pipe) 檔案?if[ -p $FILE ]; then
-L$FILE 是否存在且為一個連結檔?if[ -L $FILE ]; then

2. 關於檔案的權限偵測,如 -r $FILE 表示可讀否 (但 root 權限常有例外)
標誌意義範例
-r偵測該檔名是否存在且具有『可讀』的權限?if[ -r $FILE ]; then
-w偵測該檔名是否存在且具有『可寫』的權限?if[ -w $FILE ]; then
-x偵測該檔名是否存在且具有『可執行』的權限?if[ -x $FILE ]; then
-u偵測該檔名是否存在且具有『SUID』的屬性?if[ -u $FILE ]; then
-g偵測該檔名是否存在且具有『SGID』的屬性?if[ -g $FILE ]; then
-k偵測該檔名是否存在且具有『Sticky bit』的屬性?if[ -k $FILE ]; then
-s偵測該檔名是否存在且為『非空白檔案』?if[ -s $FILE ]; then

3. 兩個檔案之間的比較
標誌意義範例
-nt(newer than)判斷 $FILE1 是否比 $FILE2 新if[ $FILE1 -nt $FILE2 ]; then
-ot(older than)判斷 $FILE1 是否比 $FILE2 舊if[ $FILE1 -ot $FILE2 ]; then
-ef判斷 $FILE1 與 $FILE2 是否為同一檔案,
可用在判斷 hard link 的判定上。
主要意義在判定,兩個檔案是否均指向同一個 inode 哩!
if[ $FILE1 -ef $FILE2 ]; then

4. 關於兩個整數之間的判定
標誌意義範例
-eq兩數值相等 (equal)if[ n1 -eq n2 ]; then
-ne兩數值不等 (not equal)if[ n1 -ne n2 ]; then
-gtn1 大於 n2 (greater than)if[ n1 -gt n2 ]; then
-ltn1 小於 n2 (less than)if[ n1 -lt n2 ]; then
-gen1 大於等於 n2 (greater than or equal)if[ n1 -ge n2 ]; then
-len1 小於等於 n2 (less than or equal)if[ n1 -le n2 ]; then

5. 判定字串的資料
標誌意義範例
-z判定字串是否為 0 ?若 $STR 為空字串,則為 trueif[ -z $STR ]; then
-n判定字串是否非為 0 ?若 $STR 為空字串,則為 false。
註: -n 亦可省略
if[ -n $STR ]; then
=判定 $STR1 是否等於 $STR2 ,若相等,則回傳 trueif[ $STR1 = $STR2 ]; then
!=判定 $STR1 是否不等於 $STR2 ,若相等,則回傳 falseif[ $STR1 != $STR2 ]; then

6. 多重條件判定
標誌意義範例
-a(and)兩狀況同時成立if[ -r $FILE -a -x $FILE ]; then
-o(or)兩狀況任何一個成立if[ -r $FILE -o -x $FILE ]; then
!反相狀態if[ ! -x $FILE ]; then
2011-04-06 13:03

[JSX] 開啟檔案到圖層

這個程式會將選取的圖檔開啟,並全部複製到一個新的圖片文件中。

//#target photoshop 

function copyDoc(toDoc, fromDoc){
    app.activeDocument=fromDoc;
    
    /*如果背景不存在,則標記左上角的 1px*/
    if(!fromDoc.backgroundLayer){
        var white = new SolidColor();
        white.rgb.hexValue = 'FFFFFF';
        
        art.selection.select([ [1,0],[1,1],[0,1],[0,0],[1,0] ]);
        art.selection.fill(white, ColorBlendMode.NORMAL, 1);// 填滿    
    }

    //複製圖層
    fromDoc.selection.selectAll()
    fromDoc.selection.copy()

    //貼上圖層
    app.activeDocument=toDoc;
    return toDoc.paste();
}


function main(){
    /*取得多個的檔案路徑*/
    var filePathList = File.openDialog("開啟圖檔","*",true);
    if(filePathList.length == 0){return;}
    
    //新增 Temp 文件
    var newDoc = app.documents.add(
        1, 1, 72,
        "temp",
        NewDocumentMode.RGB,
        DocumentFill.TRANSPARENT
    );
    var maxWidth=1, maxHeight=1;    
    var filePath, i=0;
    while(filePath=filePathList[i++]){
        /*開啟圖檔*/
        try {
            var atDoc=open(new File(filePath));
        } catch (e) { continue; }

        /*最大高度&寬度*/
        if(maxWidth<atDoc.width){ maxWidth=atDoc.width;}
        if(maxHeight<atDoc.height){ maxHeight=atDoc.height;}

        /*複製檔案*/
        copyDoc(newDoc, atDoc);
        
        /*關閉檔案*/
        atDoc.close(SaveOptions.DONOTSAVECHANGES);
    }
    
    /*變更圖片尺寸*/
    app.activeDocument=newDoc;
    newDoc.resizeCanvas(maxWidth, maxHeight, AnchorPosition.TOPLEFT);
}


//把Photoshop推到最上層
app.bringToFront();
//設定使用的單位為「像素(Pixel)」
app.preferences.rulerUnits = Units.PIXELS;
//執行主程式
main();