<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6731706408679122900</id><updated>2024-09-25T19:09:07.802-07:00</updated><category term="Linux"/><category term="PHP"/><category term="Obj-c"/><category term="jQuery"/><category term="JavaScript"/><category term="VIM"/><category term="CSS"/><category term="Facebook"/><category term="Mongo"/><category term="Nginx"/><category term="TabBar"/><category term="TableView"/><category term="UIImage"/><category term="UIText"/><category term="git"/><category term="tmux"/><title type='text'>Programming Note</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>31</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-5524055565381104653</id><published>2012-05-31T01:51:00.000-07:00</published><updated>2012-07-08T04:54:43.188-07:00</updated><title type='text'>jQuery placeholder</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushJScript.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;p&gt;HTML 所支援的tag &quot;placeholder&quot; 在IE上並不支援，所以只好尋求jQuery的幫助，之前找了很多但是一直都不合用，所以今天又找了一下，終於找到了一個不錯用的。&lt;/p&gt;
&lt;a href=&quot;https://github.com/danielstocks/jQuery-Placeholder&quot;&gt;jQuery Placeholder plugin Download&lt;/a&gt;
&lt;p&gt;下載後，把他引入，然後這樣使用&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
$(&#39;input[placeholder] textarea[placeholder]&#39;).placeholder();
&lt;/pre&gt;
&lt;p&gt;這樣就可以使用了&lt;/p&gt;

&lt;p&gt;不過我自己都習慣每個元件就設定一次，像這樣:&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
$obejct.placeholder()
&lt;/pre&gt;
&lt;p&gt;如果要在js中建立元件又要讓他支援placeholder的話，那就這樣做就可以了&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/5524055565381104653/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/05/jquery-placeholder.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5524055565381104653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5524055565381104653'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/05/jquery-placeholder.html' title='jQuery placeholder'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-8627468637253802958</id><published>2012-04-30T02:48:00.002-07:00</published><updated>2012-04-30T02:49:41.244-07:00</updated><title type='text'>[jQuery] ajax 要注意的事情</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushJScript.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;p&gt;今天在修Issue的時候，有個issue是這樣的，ajax資料清除在重整後，資料依然存在，害我百思不得其解，最後在同事的點提下，發現jQuery ajax時會cache，如果有不需要cache時，記得要把cache關掉&lt;/p&gt;
&lt;p&gt;※IE 比較會遇到這種狀況&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
$.ajax({
    cache: false
})
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/8627468637253802958/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/04/jquery-ajax.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8627468637253802958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8627468637253802958'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/04/jquery-ajax.html' title='[jQuery] ajax 要注意的事情'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-4051696519810314596</id><published>2012-04-22T20:40:00.000-07:00</published><updated>2012-04-22T20:40:50.149-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>如何正確的unserialize()</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;
&lt;p&gt;今天在修Bug時，發現到一個問題，在PHP常常會用到 serialize() &amp; unserialize() 這個函式，但是假如今天存進去的資料格式不正確，要如何驗證資料的正確性真且安全的反解出來，我今天就遇到了這個&quot;Notice: unserialize(): Error at offset 0 of 63 bytes &quot;的訊息，代表資料格式不正確，無法正確的反解資料，於是我去PHP官網找到了別人寫的一個function。&lt;/p&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
function safe_unserialize($serialized) {
    // unserialize will return false for object declared with small cap o
    // as well as if there is any ws between O and :
    if (is_string($serialized) &amp;&amp; strpos($serialized, &quot;\0&quot;) === false) {
        if (strpos($serialized, &#39;O:&#39;) === false) {
            // the easy case, nothing to worry about
            // let unserialize do the job
            return @unserialize($serialized);
        } else if (!preg_match(&#39;/(^|;|{|})O:[0-9]+:&quot;/&#39;, $serialized)) {
            // in case we did have a string with O: in it,
            // but it was not a true serialized object
            return @unserialize($serialized);
        }
    }
    return false;
}
&lt;/pre&gt;
&lt;p&gt;這樣應該就可以驗證假如存入資料不正確時，可以正確的回傳一個值，而不跑出error。&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/4051696519810314596/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/04/syntaxhighlighter.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/4051696519810314596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/4051696519810314596'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/04/syntaxhighlighter.html' title='如何正確的unserialize()'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-4030795337774053446</id><published>2012-04-17T21:02:00.000-07:00</published><updated>2012-04-17T21:03:32.997-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>[PHP] 將Object轉成Array</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;
&lt;p&gt;由於最近都改用物件的方法在寫程式，所以大都也用物件的方法取得變數，但是有時候需要回傳為json的資料型態時，PHP必須使用json_encode的函式將array轉成json，這時候就必須將物件的所有資料轉成一個array，就找到了網路上有人這樣做。&lt;/p&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
function objectToArray($object)
{
    if(is_object($object))
        $array = get_object_vars($object);
    return $array;
}
&lt;/pre&gt;

&lt;p&gt;不過需要注意的地方是:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;假如是在object內轉出array則不必注意變數型態(連private都會讀取)&lt;/li&gt;
&lt;li&gt;如果是在外部將object轉出array則必須將變數設為public才行，否則無法取得變數&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;例如:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;內部&lt;/p&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
class Student{
    public      $name;
    protected   $height;
    private     $weight;

    function toArray()
    {
        if(is_object($this)
             $array = get_object_vars($this);
        return $array;
    }
}

var_dump($student-&gt;toArray());
// Array(&#39;name&#39; =&gt; XX, &#39;height&#39;=&gt; 170, &#39;weight&#39; =&gt; 48)
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;外部&lt;/p&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
class Student{
    public      $name;
    protected   $height;
    private     $weight;


}
function objectToArray()
{
   if(is_object($this)
        $array = get_object_vars($this);
   return $array;
}
var_dump(objectToArray($student));
// Array(&#39;name&#39; =&gt; XX)
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;需注意其中的差異&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/4030795337774053446/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/04/php-objectarray.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/4030795337774053446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/4030795337774053446'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/04/php-objectarray.html' title='[PHP] 將Object轉成Array'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-7101263201047391216</id><published>2012-04-15T00:24:00.002-07:00</published><updated>2012-04-15T00:25:01.743-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>[PHP] 取得使用者正確IP</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;pre class=&quot;brush: php&quot;&gt;
        function getIp()
        {
                if(empty($_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;]))
                {
                        $proxyIp        = split(&#39;,&#39;, $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;]);
                        $UP             = $proxyIp[0];
                }
                else
                {                        $ip     = $_SERVER[&#39;REMOTE_ADDR&#39;];
                }
                return $ip;
        }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/7101263201047391216/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/04/php-ip.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/7101263201047391216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/7101263201047391216'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/04/php-ip.html' title='[PHP] 取得使用者正確IP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-7386014107206320978</id><published>2012-04-13T01:35:00.000-07:00</published><updated>2012-04-13T01:35:32.374-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><title type='text'>[javascript] 使用正規表示法驗證URL</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushJScript.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;
&lt;p&gt;這兩天再寫案子的時候突然要用到regular expresion(正規表示法)驗證URL的正確性,所以就來記錄一下好了&lt;/p&gt;

&lt;pre class=&quot;brush: js&quot;&gt;
function validateURL(url){
     var regUrl = /^(((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:%_\+.~#?&amp;//=]+$/;

     if(regUrl.test(url))
         return true;
     else
         return fale;
}
&lt;/pre&gt;

&lt;p&gt;如果URL正確的話就會回傳TRUE值&lt;p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/7386014107206320978/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/04/javascript-url.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/7386014107206320978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/7386014107206320978'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/04/javascript-url.html' title='[javascript] 使用正規表示法驗證URL'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-1088822239301976964</id><published>2012-04-03T03:06:00.003-07:00</published><updated>2012-04-08T08:14:58.803-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>[PHP] 如何用timestamp計算年紀?</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;pre class=&quot;brush: php&quot;&gt;
$birthday = time();
$now      = time();
$age      = floor(($now - $birthday)/(60*60*24*365));
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/1088822239301976964/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/04/php-timestamp.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/1088822239301976964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/1088822239301976964'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/04/php-timestamp.html' title='[PHP] 如何用timestamp計算年紀?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-3813840114641227424</id><published>2012-03-14T01:39:00.000-07:00</published><updated>2012-04-13T01:36:03.121-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>[jQuery] 在plugin內加入function</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushJScript.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;p&gt;今天再寫plugin的時候，發現在要把一些區塊獨立出來，但是又不知道如何在plugin內再獨立使用function，然後我就自己測試看看，發現這樣子可行。&lt;/p&gt;
&lt;h3&gt;範例程式碼&lt;/h3&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
(function($){
    var helps = {
        question: function(){
            ...
        }.
        answers: function(){
            ...
        }
    };
   
    $.fn.qa = function(){
        helps.question();
        helps.answers();
    }
})(jQuery);
&lt;/pre&gt;
&lt;p&gt;這樣就可以使用了&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/3813840114641227424/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-pluginfunction.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3813840114641227424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3813840114641227424'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-pluginfunction.html' title='[jQuery] 在plugin內加入function'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-8675930633982070083</id><published>2012-03-12T01:52:00.000-07:00</published><updated>2012-03-14T03:09:29.325-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>[jQuery] textarea auto expand(文字區塊自動延展)</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushJScript.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;jQuery plugin: autoResize&lt;/h1&gt;
&lt;p&gt;其實之前一直有再找類似的套件，facebook樣式的textarea auto expand，不過一直沒有找到不錯的，今天在尋找的時候找到一個不錯的plugin「autoResize」&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;&lt;a href=&quot;http://james.padolsey.com/demos/plugins/jQuery/autoresize.jquery.js&quot;&gt;autoresize.jquery.js&lt;/a&gt;&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;&lt;a href=&quot;http://james.padolsey.com/demos/plugins/jQuery/autoresize.jquery.min.js&quot;&gt;autoresize.jquery.min.js&lt;/a&gt;&lt;/h2&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;自己選擇下載喜歡的檔案格式&lt;/p&gt;
&lt;h1&gt;Script&lt;/h1&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
$(&#39;textarea#comment&#39;).autoResize({
    // On resize:
    onResize : function() {
        $(this).css({opacity:0.8});
    },
    // After resize:
    animateCallback : function() {
        $(this).css({opacity:1});
    },
    // Quite slow animation:
    animateDuration : 300,
    // More extra space:
    extraSpace : 40
});
&lt;/pre&gt;
&lt;h1&gt;HTML&lt;/h1&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
&lt;textarea id=&quot;comment&quot;&gt;&lt;/textarea&gt;
&lt;/pre&gt;

&lt;p&gt;這樣就可以使用了 :)&lt;/p&gt;
&lt;p&gt;不過他還有一些選項可以選擇使用，日後有用到再介紹。&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;http://james.padolsey.com/javascript/jquery-plugin-autoresize/&quot;&gt;來源網站&lt;/a&gt;&lt;/h2&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/8675930633982070083/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-textarea-auto-expand.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8675930633982070083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8675930633982070083'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-textarea-auto-expand.html' title='[jQuery] textarea auto expand(文字區塊自動延展)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-460707059019221362</id><published>2012-03-10T02:47:00.000-08:00</published><updated>2012-04-01T22:43:23.678-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>[jQuery] jQuery Plugin 寫法</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushJScript.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;p&gt;由於網頁設計目前用到jQuery的機率越來越高，常常寫了一段程式碼需要重複使用，於是決定把它製作成模組使用&lt;/p&gt;
&lt;h1&gt;建立一個Plugin&lt;/h1&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
(function($){
    $.fn.helloworld = function(){
        alert(&#39;Hello World&#39;);
    }
})(jQuery);
&lt;/pre&gt;
&lt;p&gt;照jQuery文件說明，是可以這樣寫&lt;/p&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
jQuery.fn.helloworld = function(){
    alert(&#39;Hello World&#39;);
}
&lt;/pre&gt;
&lt;p&gt;不過一方面為了方便使用「$」字號，且不與其他函式庫衝突，所以就使用外層包著，這樣就可以在裡面使用「$」字號，不會衝突。&lt;/p&gt;

&lt;h1&gt;this代表的意義&lt;/h1&gt;
&lt;p&gt;假設我們這麼寫了一段程式碼&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
(function($){
    $.fn.showbox = function(){
        this.fadeIn(&#39;slow&#39;);
    }
})(jQuery);
&lt;/pre&gt;
&lt;p&gt;然後我們只要這樣使用&lt;/p&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
$(&#39;div&#39;).showbox();
&lt;/pre&gt;
&lt;p&gt;div就會依照Plugin內的程式碼去執行，this就等於div這個物件，不需再另外再去指定。&lt;/p&gt;

&lt;h1&gt;保持鏈結(Maintaing Chainability)&lt;/h1&gt;
&lt;p&gt;下面有個範例&lt;取自jQuery網站&gt;&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
(function( $ ){

  $.fn.lockDimensions = function( type ) {  

    return this.each(function() {

      var $this = $(this);

      if ( !type || type == &#39;width&#39; ) {
        $this.width( $this.width() );
      }

      if ( !type || type == &#39;height&#39; ) {
        $this.height( $this.height() );
      }

    });

  };
})( jQuery );
&lt;/pre&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
$(&#39;div&#39;).lockDimensions(&#39;width&#39;).css(&#39;color&#39;, &#39;red&#39;);
&lt;/pre&gt;
&lt;p&gt;照上面的範例，因為這個物件必須接著下面繼續的動作，所以在lockDimensions這個plugin必須回傳this，才能繼續接著.css()這類其他jQuery的函式，要是沒有回傳this的話，就會接不到物件，而後面動作都沒有效果。&lt;/p&gt;

&lt;h1&gt;設定預設值和選項(Defaults and Options)&lt;/h1&gt;
&lt;p&gt;許多功能性較複雜的plugin，會給予使用者很多選項去選擇所需的功能，來符合自己的需求，而這些選項必然需要預設值來確保plugin的運作正常，當使用者忘記給予一些參數時，預設值能自動替補上去，來讓程式運行正常。&lt;/p&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
(function( $ ){

  $.fn.box = function( options ) {  

    //設定選項和預設值
    var settings = $.extend( {
      &#39;width&#39;         : &#39;200px&#39;,
      &#39;height&#39;        : &#39;200px&#39;,
      &#39;background-color&#39; : &#39;blue&#39;
    }, options);

    return this.each(function() {        
       alert(settings.width);
    });

  };
})( jQuery );
&lt;/pre&gt;
&lt;pre class=&quot;brush: js&quot;&gt;

$(&quot;div&quot;).box();
//200px


$(&quot;div&quot;).box(
    {
        &#39;width&#39;: 300px
    }
};
//300px                   
&lt;/pre&gt;
&lt;p&gt;在沒有給予選項狀態下，plugin預設會使用程式碼編寫時的預設值。&lt;p&gt;
&lt;p&gt;預設值是一個非常重要的東西，常常再編寫程式碼時忘記給予參數造成程式掛點，如果有設定預設值，就算忘記給予參數，也可以讓程式順利執行。&lt;/p&gt;
&lt;h1&gt;命名(Namespacing)&lt;/h1&gt;
&lt;p&gt;這段是jQuery文件中提到的，我也非常認同好的且正確的命名plugin是應該做的事情，其實這也不也僅限於jQuery Plugin而已，在任何程式碼中正確的命名都是必須的，最好用幫自己小孩取名子的心態下去取，總不會把自己的小孩叫a,b,c這類的名稱吧，文件中提到正確的命名可以將名稱衝突的機率降到最低，避免太多隻plugin一起引入時，因為不好的命名結果造成覆蓋，程式無法正確執行，另一方面，正確的命名可以方便開發者快速的追蹤問題，這是非常重要的，畢竟時間就是金錢，因為今天自己的命名不小心結果造成要花更大的成本去檢查錯誤，最後發現命名衝突，這該有多嘔。&lt;/p&gt;

&lt;h1&gt;多種方法(Plugin Methods)&lt;/h1&gt;
&lt;p&gt;有的時候我們在寫一隻plugin，會有許多方法可以讓使用者可以選擇，但是每種方法都寫一隻plugin又太多餘，且難以維護管理，且互相都有相依性，這時候就可以這樣寫。&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
(function($){
    var methods = {
        init : function( options ) { 
            var settings = $.extend({
                &#39;width&#39;: &#39;200px&#39;
            },options);
            this.css(&#39;width&#39;, settings.width); 
        },
        show : function( ) {
            this.show();
        },
        hide : function( ) { 
            this.hide();
        },
        spin : function( content ) { 
            alert(content);
        }
     };

     $.fn.box = function( method ) {
         // Method calling logic
         if ( methods[method] ) {
             return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
         }else if( typeof method === &#39;object&#39; || ! method ) {
             return methods.init.apply( this, arguments );
         }else{
             $.error( &#39;Method &#39; +  method + &#39; does not exist on jQuery.tooltip&#39; );
         }    
     };
})(jQuery);
&lt;/pre&gt;
&lt;p&gt;然後可以這樣使用&lt;/p&gt;
&lt;pre class=&quot;brush:js&quot;&gt;
$(&quot;div&quot;).box();
//call init function;
//set box width 200px.

$(&quot;div&quot;).box({width: &#39;377px&#39;});
//call init function with options
//set box width 377px.

$(&quot;div&quot;).box(&#39;hide&#39;);
//call hide funtion
//div hide

$(&quot;div&quot;).box(&#39;spin&#39;, &#39;This is box.&#39;);
//call spin function with argument
//This is box.
&lt;/pre&gt;
&lt;p&gt;這樣就可以依照參數的不同去執行不同的動作，然後又屬於同一隻plugin內，不需要為每種動作都建立一個plugin，我覺得很方便。&lt;/p&gt;

&lt;h1&gt;事件(Events)&lt;/h1&gt;
&lt;p&gt;在寫plugin時，一定會用到許多事件問題，常常要綁定一些事件，例如:「click」「blur」這類的事件要處理，在有些情況下，必須要讓這些事件停止動作，我們就必須「unbind」這些事件。所以我們常常會這樣:&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
(function($){
    var methods = {
        init: function() {  
            return this.each(function(){
                 $(window).bind(&#39;click&#39;, methods.start);
                 //未加入namespacing
            );  
        },  
        stop: function() {  
            return this.each(function(){
                 $(window).unbind(&#39;click&#39;);
                 //有可能干擾到其他相同類型事件
            });  
        },
        start: function(){
             ..........
        }  
    }

    $.fn.runner = function( method ) {   
        if ( methods[method] ) {
            return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === &#39;object&#39; || ! method ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( &#39;Method &#39; +  method + &#39; does not exist on jQuery.tooltip&#39; );
        }     
    };
})(jQuery);
&lt;/pre&gt;
&lt;p&gt;如果照上面那樣寫的話，在初始化runner這個物件時，會綁定click事件，這沒有甚麼太大問題，但是當執行stop時，避免unbind「click」時干擾到其他事件，所以我們可以這樣寫:&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
    var methods = {
        init: function() {  
            return this.each(function(){
                 $(window).bind(&#39;click.runner&#39;, methods.start);
                 //加入了namespacing
            );  
        },  
        stop: function() {  
            return this.each(function(){
                 $(window).unbind(&#39;click.runner&#39;);
                 //或是 $(window).unbind(&#39;.runner&#39;);
                 //這樣就不會影響其他的事件
            });  
        },
        start: function(){
             ..........
        }  
    }

    $.fn.runner = function( method ) {   
        if ( methods[method] ) {
            return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === &#39;object&#39; || ! method ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( &#39;Method &#39; +  method + &#39; does not exist on jQuery.tooltip&#39; );
        }     
    };
&lt;/pre&gt;
&lt;p&gt;這樣寫的話就可以緊限於這個物件的事件，而不去影響到其他plugin物件的運作。&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/460707059019221362/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-jquery-plugin.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/460707059019221362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/460707059019221362'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-jquery-plugin.html' title='[jQuery] jQuery Plugin 寫法'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-8733600185828734529</id><published>2012-03-08T02:28:00.001-08:00</published><updated>2012-03-08T02:28:18.904-08:00</updated><title type='text'>[javascript] 多檔上傳 - 使用SWFUpload</title><content type='html'>&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.swfupload.org/&quot; target=&quot;blank&quot;&gt;官方網站&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;最近因為工作需求而必須使用到多檔上傳的工具，雖然說jQuery有個
&lt;a href=&quot;http://blueimp.github.com/jQuery-File-Upload/&quot; target=&quot;blank&quot;&gt;jQuery File Upload&lt;/a&gt;
的Plugin但是『file[]』這個多檔選擇必須在HTML支援的瀏覽器下才能作用，結果就在(爛)IE不完全支援HTML 5的情況下，只好放棄使用
&lt;a href=&quot;http://blueimp.github.com/jQuery-File-Upload/&quot; target=&quot;blank&quot;&gt;jQuery File Upload&lt;/a&gt;
這個工具，另尋其他的多檔上傳工具，
&lt;a href=&quot;http://www.swfupload.org/&quot; target=&quot;blank&quot;&gt;SWFUpload&lt;/a&gt;
這套工具我想應該也是行之有年(不過我就是不是很喜歡Flash)，整個事件處理也算是完整，為了工作的順暢，就來用
&lt;a href=&quot;http://www.swfupload.org/&quot; target=&quot;blank&quot;&gt;SWFUpload&lt;/a&gt;
來執行多檔上傳的工作吧。&lt;/p&gt;

&lt;h4&gt;1.首先我們要先下載SWFUpload 的核心檔案&lt;a href=&quot;http://code.google.com/p/swfupload/downloads/list&quot;&gt;[ 點此進入下載頁面 ]&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;未完待續&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/8733600185828734529/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/javascript-swfupload.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8733600185828734529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8733600185828734529'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/javascript-swfupload.html' title='[javascript] 多檔上傳 - 使用SWFUpload'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-6262170916720201182</id><published>2012-03-05T00:41:00.001-08:00</published><updated>2012-03-05T00:45:53.937-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery"/><title type='text'>[jQuery] facebook Lightbox樣式 -- facebox</title><content type='html'>&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://defunkt.io/facebox/&quot; target=&quot;blank&quot;&gt;官方網站&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/defunkt/facebox&quot; target=&quot;blank&quot;&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/6262170916720201182/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-facebook-lightbox-facebox.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/6262170916720201182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/6262170916720201182'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/jquery-facebook-lightbox-facebox.html' title='[jQuery] facebook Lightbox樣式 -- facebox'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-840639857181877826</id><published>2012-03-04T22:06:00.000-08:00</published><updated>2012-03-14T01:46:54.648-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CSS"/><title type='text'>[CSS] 子物件置底</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushCss.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;
&lt;p&gt;今天為了這個問題google了好久，原來是這樣子用阿，之前一直不知道只會用padding來控制，現在終於了解了。&lt;/p&gt;
&lt;h3&gt;CSS&lt;/h3&gt;
&lt;pre class=&quot;brush: css&quot;&gt;
.father{position:relative;}
.child{position:absolute; bottom: 0;}
&lt;/pre&gt;

&lt;h3&gt;HTML&lt;/h3&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
&lt;div class=&quot;father&quot;&gt;
    &lt;div class=&quot;child&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;p&gt;父系物件的position必須設定為&lt;span style=&quot;color:green;&quot;&gt;relative&lt;/span&gt;，子物件position設定為&lt;span style=&quot;color: green;&quot;&gt;relative&lt;/span&gt;
&lt;p&gt;使用這樣的方式，就可以使「child」類別的物件置於「father」的底部。&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/840639857181877826/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/css.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/840639857181877826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/840639857181877826'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/css.html' title='[CSS] 子物件置底'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-5493963502338859511</id><published>2012-03-04T03:15:00.000-08:00</published><updated>2012-03-05T00:39:42.698-08:00</updated><title type='text'>[PHP] 正規表示法驗證密碼</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;驗證密碼&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;至少有一個數字&lt;li&gt;
&lt;li&gt;至少有一個小寫英文字母&lt;li&gt;
&lt;li&gt;至少有一個大寫英文字母&lt;li&gt;
&lt;li&gt;字串長度在 6 ~ 30 個字母之間&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
function valid_password($password)
{
    if(preg_match(&quot;/^(?=.*\d)(?=.*[a-z]).{32,64}$/&quot;, $string))
        return TRUE;
    else
        return FALSE;
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/5493963502338859511/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/03/php.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5493963502338859511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5493963502338859511'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/03/php.html' title='[PHP] 正規表示法驗證密碼'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-3936554788838391680</id><published>2012-02-28T20:23:00.000-08:00</published><updated>2012-03-04T22:07:50.353-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>[PHP] DataMapper 範例寫法</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;建立User model&lt;/h1&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
class User{

    protected name;

    public function __construct(array $options = null)
    {
        if (is_array($options)) {
            $this-&gt;setOptions($options);
        }
    }
 
    public function __set($name, $value)
    {
        $method = &#39;set&#39; . $name;
        if ((&#39;mapper&#39; == $name) || !method_exists($this, $method)) {
            throw new Exception(&#39;Invalid guestbook property&#39;);
        }
        $this-&gt;$method($value);
    }
 
    public function __get($name)
    {
        $method = &#39;get&#39; . $name;
        if ((&#39;mapper&#39; == $name) || !method_exists($this, $method)) {
            throw new Exception(&#39;Invalid guestbook property&#39;);
        }
        return $this-&gt;$method();
    }
 
    public function setOptions(array $options)
    {
        $methods = get_class_methods($this);
        foreach ($options as $key =&gt; $value) {
            $method = &#39;set&#39; . ucfirst($key);
            if (in_array($method, $methods)) {
                $this-&gt;$method($value);
            }
        }
        return $this;
    }

    public function setName($text)
    {
        $this-&gt;name = (string) $text;
        return $this;
    }

    public function getName()
    {
        return $this-&gt;name;
    }
}
&lt;/pre&gt;

&lt;h1&gt;建立User mapper&lt;/h1&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
class UserMapper{
    public function fetch($ID, $User)
    {
        $result = $SQL ...
        //自行設定
        $User-&gt;setOptions($result);
        //OR
        $result = $this-&gt;setup($result);
        $User-&gt;setOptions($result);
        //欄位名稱必須與Model定義的變數名稱相同。
    }
    
    public function setup($result)
    {
        $data = array(
           ...
        );
        return $data;
    }
}
&lt;/pre&gt;

&lt;h1&gt;Controller 的使用&lt;/h1&gt;
&lt;pre class=&quot;brush: php&quot;&gt;
function user()
{
    $User = new User();
    $userMapper = new UserMapper();
    $userMapper-&gt;fetch($ID, $User);
    
    echo $User-&gt;getName();
}

//Output
//Ciao Chiang(Name)
//看資料庫的資料是甚麼
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/3936554788838391680/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/02/phpdatamapper.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3936554788838391680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3936554788838391680'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/02/phpdatamapper.html' title='[PHP] DataMapper 範例寫法'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-2083842718246691038</id><published>2012-02-22T19:51:00.001-08:00</published><updated>2012-02-22T19:52:17.024-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="VIM"/><title type='text'>[Linux] VIM color(VIM顏色)</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushBash.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/css/blogger.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;安裝&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;先建立目錄&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
mkdir ~/.vim/colors/
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;將下載好的COLOR_SCHEME.vim檔放入colors目錄中&lt;/li&gt;
&lt;li&gt;編輯 ~/.vimrc&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;加入以下程式碼&lt;p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
colorscheme COLOR_SCHEME #(scheme的檔案名稱)
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;設定支援256色環境&lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
set t_Co=256
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/2083842718246691038/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-vim-colorvim.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/2083842718246691038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/2083842718246691038'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-vim-colorvim.html' title='[Linux] VIM color(VIM顏色)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-3036601759985337288</id><published>2012-02-19T23:53:00.000-08:00</published><updated>2012-02-20T01:54:56.594-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Nginx"/><title type='text'>[Linux] Nginx</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushBash.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/css/blogger.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;需求環境&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;Install Indeed Repository&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
## EPEL Repository
rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm

## Remi Repository
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;Add Nginx Repository&lt;/h2&gt;
&lt;h3&gt;Cent OS&lt;/h3&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;安裝&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;Install Client Package&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
yum --enablerepo=remi install nginx php php-fpm php-common
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;啟動Nginx&lt;/h2&gt;
&lt;h3 class=&quot;notice&quot;&gt;※需停止Apache(httpd)服務&lt;/h3&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
/etc/init.d/nginx start
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;/ul&gt;

&lt;h1&gt;Nginx設定&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;設定開機啟動Nginx&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
#關閉httpd開機啟動
chkconfig httpd off

#設定Nginx開機啟動
chkconfig --add nginx
chkconfig --levels 235 nginx on
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;防火牆設定&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;編輯iptables設定檔&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
vim /etc/sysconfig/iptables
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;加入規則&lt;/h2&gt;
&lt;li&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;重啟iptables&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
 /etc/init.d/iptables restart
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;



http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/
&lt;p&gt;日後再來整理文章&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/3036601759985337288/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-nginx.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3036601759985337288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3036601759985337288'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-nginx.html' title='[Linux] Nginx'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-3911257537967245553</id><published>2012-02-19T23:41:00.000-08:00</published><updated>2012-02-20T00:30:17.074-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Mongo"/><title type='text'>[Linux] Mongo DB</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushBash.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/css/blogger.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;安裝&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;Add Repository&lt;新增MongoDB資料源&gt;&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
vim /etc/yum.repos.d/10gen-mongodb.repo
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;加入以下程式碼&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
&lt;/pre&gt;
&lt;ul&gt;
&lt;p&gt;可依個人系統需求調整路徑&lt;/p&gt;
&lt;li&gt;Mongodb-repo for Fedora 16/15/14/13/12/11&lt;/li&gt;
&lt;li&gt;CentOS 6/5.7 and Red Hat (RHEL) 6.1/6/5.7 on x86_64 (64-bit)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;將Repository設定好後，就可以直接使用yum安裝Mongo DB了。&lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
yum install mongo-10gen mongo-10gen-server
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;設定&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;Edit /etc/mongod.conf file&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
vim /etc/mongdb.conf
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;確認路徑及調整個人設定&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;啟動Mongo DB&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
/etc/init.d/mongod start
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;設定開機啟動Mongo DB&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
chkconfig --levels 235 mongod on
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;防火牆&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;iptables 設定條件開放&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
vim /etc/sysconfig/iptables

#加入以下程式碼
-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;iptables 重啟&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
iptables restart
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/3911257537967245553/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-mongo-db.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3911257537967245553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/3911257537967245553'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-mongo-db.html' title='[Linux] Mongo DB'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-5455581845140100229</id><published>2012-02-19T22:37:00.000-08:00</published><updated>2012-02-22T19:31:06.839-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>[Linux] git</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushBash.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/css/blogger.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;



&lt;h1&gt;安裝流程&lt;/h1&gt;
&lt;h2&gt;Centos 安裝&lt;/h2&gt;
&lt;p&gt;由於yum本身就有這類的套件可以直接安裝，所以直接使用yum安裝即可。&lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
yum -y install git
&lt;/pre&gt;

&lt;h1&gt;設定&lt;/h1&gt;
&lt;h2&gt;基本設定&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
git config --global user.name &quot;Ciao Chiang&quot;
git config --golbal user.email &quot;ciao@test.com&quot;
&lt;/pre&gt;

&lt;h2&gt;顏色設定&lt;/h2&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global color.log auto
&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;color.diff: git diff 顯示顏色。&lt;/li&gt;
&lt;li&gt;color.status: git status 顯示顏色。 &lt;綠色或紅色&gt;&lt;/li&gt;
&lt;li&gt;color.branch: git branch 顯示顏色。 &lt;Highlight目前branch&gt;&lt;/li&gt;
&lt;li&gt;color.log: git log --graph 顯示顏色。 &lt;Highlight Commit版本及流程&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;分享設定&lt;/h2&gt;
&lt;p&gt;將以建立的Repository對群組分享&lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
git config core.sharedRepository group
&lt;/pre&gt;
&lt;p&gt;或者是建立Repository時可以輸入這樣:&lt;p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;
git init --shared=group
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/5455581845140100229/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-git.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5455581845140100229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5455581845140100229'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-git.html' title='[Linux] git'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-1662714467750453912</id><published>2012-02-19T18:40:00.000-08:00</published><updated>2012-03-05T20:16:12.287-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>[Linux] EPEL Repository Install</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushBash.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/css/blogger.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;下載最新EPEL安裝軟體&lt;/h1&gt;
&lt;h2&gt;CentOS 6 安裝EPEL&lt;/h2&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
&lt;/pre&gt;

&lt;h2&gt;CentOS 5.X 安裝EPEL&lt;/h2&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;
wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
&lt;/pre&gt;

&lt;h1&gt;執行安裝&lt;/h1&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;
rpm -Uvh epel-release-6-5.noarch.rpm
&lt;/pre&gt;

&lt;p&gt;如果有需要其他版本可以到&lt;a href=&quot;http://fedoraproject.org/wiki/EPEL&quot; target=&quot;blank&quot;&gt;fedora EPEL&lt;/a&gt;下載.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/1662714467750453912/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-epel-repository-install.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/1662714467750453912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/1662714467750453912'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/02/linux-epel-repository-install.html' title='[Linux] EPEL Repository Install'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-5128006543317621140</id><published>2012-01-07T21:09:00.000-08:00</published><updated>2012-02-22T19:53:21.710-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="tmux"/><title type='text'>[Linux] tmux</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushBash.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;安裝&lt;/h1&gt;
&lt;ul&gt;

&lt;li&gt;
&lt;h2&gt;安裝需求&lt;/h2&gt;
需先安裝EPEL套件-請參考這篇&lt;a href=&#39;http://ciao-note.blogspot.com/2012/02/linux-epel-repository-install.html&#39;&gt;EPEL Repository Install&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;h2&gt;安裝方式&lt;/h2&gt;
執行程式碼
&lt;pre class=&quot;brush: bash;&quot;&gt;
yum -y install tmux
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;分享畫面(share view)&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;當使用同一帳號登入，且tmux attach畫面時，畫面就會共享。&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/5128006543317621140/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/01/tmux.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5128006543317621140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/5128006543317621140'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/01/tmux.html' title='[Linux] tmux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-8563101068098710814</id><published>2012-01-06T20:56:00.000-08:00</published><updated>2012-02-22T19:52:34.231-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="VIM"/><title type='text'>[Linux] VIM Indent(VIM縮排)</title><content type='html'>&lt;div style=&quot;margin-bottom: 30px;&quot;&gt;
&lt;h1&gt;安裝流程&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;下載 &quot;html(indent).vim&quot;&lt;/li&gt;
&lt;li&gt;在.vim目錄下建立資料夾 &quot; ~/.vim/indent&quot;&lt;/li&gt;
&lt;li&gt;將&quot;html.vim&quot;放進indent資料夾&lt;/li&gt;
&lt;li&gt;編輯 &quot;~/.vimrc&quot; 檔案&lt;/li&gt;
&lt;li&gt;新增 &quot;filetype indent on&quot; 這行程式碼就可以了!!&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;


&lt;div&gt;
&lt;h2&gt;HTML Indent&lt;/h2&gt;
&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2075&quot; target=&quot;blank&quot;&gt;&lt;點此下載 Download HTML Indent&gt;&lt;/a&gt;
&lt;/div&gt;


&lt;div&gt;
&lt;h2&gt;PHP Indent&lt;/h2&gt;
&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1120&quot; target=&quot;blank&quot;&gt;&lt;點此下載 Download PHP Indent&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/8563101068098710814/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2012/01/vim-indent.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8563101068098710814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8563101068098710814'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2012/01/vim-indent.html' title='[Linux] VIM Indent(VIM縮排)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-4234889248128642521</id><published>2011-10-26T07:47:00.001-07:00</published><updated>2012-02-15T21:57:35.401-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Obj-c"/><title type='text'>[Obj-c] UNIX Timestamp 轉換成 NSDATE</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushObjC.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;Code&lt;/h1&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;
NSDateFormatter*dateFormat = [[NSDateFormatter alloc] init];

[dateFormat setDateFormat:@&quot;YYYY-MM-dd HH:mm:ss&quot;];

unsigned long long timestamp = [[[messages objectAtIndex:indexPath.row] objectForKey:@&quot;timestamp&quot;] longLongValue];
NSDate *date = [NSDate dateWithTimeIntervalSince1970:timestamp];
NSString *dateStr = [dateFormat stringFromDate:date];
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/4234889248128642521/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2011/10/obj-c-timestamp-convert-to-nsdate.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/4234889248128642521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/4234889248128642521'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2011/10/obj-c-timestamp-convert-to-nsdate.html' title='[Obj-c] UNIX Timestamp 轉換成 NSDATE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-7940959585099132673</id><published>2011-10-24T03:25:00.000-07:00</published><updated>2012-02-15T21:32:49.310-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>[PHP] Coordinate Translate(經緯度轉換)</title><content type='html'>&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shCore.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://tools.fanilist.com/scripts/shBrushPhp.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://tools.fanilist.com/styles/shCoreDefault.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;SyntaxHighlighter.all();&lt;/script&gt;

&lt;h1&gt;Code&lt;/h1&gt;

&lt;pre class=&quot;brush: php;&quot;&gt;
function CovertCoordinate($Position){
  $deg = floor($Position);
  $min = floor(($Position - $deg)*60);
  $sec = round((((($Position - $deg)*60) - $min)*60),3);
  return ($deg * 3600000) + ($min * 60000) + ($sec * 1000);
}

function RevertCoordinate($Position){
  $deg = floor($Position/3600000);
  $min = floor(($Position - ($deg * 3600000))/60000);
  $sec = (($deg * 3600000) - ($min * 60000))/1000;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
  return $deg + ($min / 60) + ($sec / 3600);
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/7940959585099132673/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2011/10/php-coordinate-traslate.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/7940959585099132673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/7940959585099132673'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2011/10/php-coordinate-traslate.html' title='[PHP] Coordinate Translate(經緯度轉換)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6731706408679122900.post-8228546064234711916</id><published>2011-10-17T01:08:00.000-07:00</published><updated>2011-10-17T01:40:18.603-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook"/><title type='text'>[Facebook] Search Place by Latitude &amp; Longitude</title><content type='html'>&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
require &#39;./src/facebook.php&#39;;&lt;br /&gt;
&lt;br /&gt;
// Create our Application instance (replace this with your appId and secret).&lt;br /&gt;
$facebook = new Facebook(array(&lt;br /&gt;
&amp;nbsp; &#39;appId&#39; =&amp;gt; &#39;2249678xxxxx&#39;,&lt;br /&gt;
&amp;nbsp; &#39;secret&#39; =&amp;gt; &#39;2374aebcxxxxxxxxxxx&#39;,&lt;br /&gt;
));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Get User ID&lt;br /&gt;
$user = $facebook-&amp;gt;getUser();&lt;br /&gt;
&lt;br /&gt;
$lat = &#39;25.066667&#39;;&lt;br /&gt;
$lng = &#39;121.583333&#39;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #6fa8dc;&quot;&gt;$location = $facebook-&amp;gt;api(&#39;/search?type=place&amp;amp;center=&#39; . $lat . &#39;,&#39; . $lng . &#39;&amp;amp;distance=1000&#39;);&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;// distance =&amp;gt; Search Range&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
print_r($location);&lt;br /&gt;
&lt;br /&gt;
if ($user) {&lt;br /&gt;
&amp;nbsp; try {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Proceed knowing you have a logged in user who&#39;s authenticated.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $user_profile = $facebook-&amp;gt;api(&#39;/me&#39;);&lt;br /&gt;
&amp;nbsp; } catch (FacebookApiException $e) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; error_log($e);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $user = null;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Login or logout url will be needed depending on current user state.&lt;br /&gt;
if ($user) {&lt;br /&gt;
&amp;nbsp; $logoutUrl = $facebook-&amp;gt;getLogoutUrl();&lt;br /&gt;
} else {&lt;br /&gt;
&amp;nbsp; $loginUrl = $facebook-&amp;gt;getLoginUrl();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://ciao-note.blogspot.com/feeds/8228546064234711916/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://ciao-note.blogspot.com/2011/10/facebook-search-place-by-latitude.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8228546064234711916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6731706408679122900/posts/default/8228546064234711916'/><link rel='alternate' type='text/html' href='http://ciao-note.blogspot.com/2011/10/facebook-search-place-by-latitude.html' title='[Facebook] Search Place by Latitude &amp; Longitude'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04523387119782150072</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>