Posted in AJAX, CodeIgniter, jQuery on Aug 26th, 2010
好久沒寫相關 CodeIgniter 文章,針對於剛入門 CI 的新手們,此篇教學如何使用 jQuery AJAX 搭配 CI 來驗證使用者帳號及相關資訊,本篇教學帶您如何在 CI 中發出 AJAX request 給伺服器端。 請先在網頁 header 自行 include jQuery 檔案,或者可以使用 Google AJAX CDN 方式來讀取,將底下程式碼放到 之前: $(document).ready(function() { /* 先停止讀取狀態 */ $(’#Loading’).hide(); /* 填寫好 email 欄位,按下 Tab 會進行讀取 */ $(’#email’).blur(function(){ /* 讀取 email 欄位 */ [...]
Read Full Post »
Posted in www on Aug 25th, 2010
Update 2010.08.28: Pspad 轉換既有 Tabs to Spaces by bootleq 為了統一 Windows 跟 Linux 底下的編輯器在使用 Tab 功能相同,所以調整了 Vim 及 Pspad(我常用編輯器)的設定,底下是針對 Vim 及 Pspad 的解決方法。首先當大家使用 Vim 編輯器撰寫程式,常常會使用 Tab 來縮排程式碼,我們可以使用 expandtab 來插入空白鍵(Space)取代 Tab: :set expandtab 控制插入 Tab 時所需要的空白鍵(Tab)字元數,例如用4個空白鍵取代 Tab: :set tabstop=4 在我們設定完 expandtab 之後,所有的 Tab 鍵將會被 Space 所取代,但是原本在檔案文件中的 Tab 將不會改變,為了取代原有的 Tab 到新的設定,我們必須鍵入: :retab 針對程式縮排所需要的 Space 個數,我們可以使用 shiftwidth 選項 [...]
Read Full Post »
Posted in apache, CSS, javascript, jQuery on Aug 23rd, 2010
今年在 COSCUP 大會上最主流的議題就是 Html5,今天看到一個網站 HTML5 Boilerplate,這網站提一個全新 html 5 模板,自從離開 Dreamweaver 樣板軟體,利用 Pspad 手動撰寫 html,此網站就發揮非常大的用處,提供全新 html,CSS 以及 javascript,支援了底下很多功能: 跨瀏覽器 (IE6…) 支援多種 html5 Tag Compress 和 cache html 檔案 CSS IE6 , IE7 Hack IE6 Png Fix (連這個都幫忙解決了) 支援 CDN jQuery,避免在 local 端沒讀取到檔案 你還可以根據自己需要的功能做添加或者是減少,CSS reset、跨瀏覽器 CSS、robots.txt、Apache .htaccess cache 壓縮也有支援,如果不需要的功能,也可以參考看看,對於初學者也是非常好的學習例子。
Read Full Post »
Posted in Git on Aug 20th, 2010
這次來介紹一下 git reset 的用法,為什麼會介紹這指令呢?因為今天想要看專案狀態,用 git status 觀看,發現被我玩爛了,所以出現了底下錯誤訊息: $ git status error: bad index file sha1 signature fatal: index file corrupt 解決此問題非常簡單,要先刪除 index 檔案,請先砍掉 .git/index,恢復此 index 請用 git reset 這行指令相當於 git reset –mixed HEAD,或者是可以用 git read-tree 來取代 git reset,當然 git reset 不只是有這功能而已,假如您已經建立了 commit 訊息,也可以將此訊息拿掉,重新在 commit,或者是您修改過的檔案在暫存區,git 也可以幫您恢復到未暫存,或者是不想要這次的修改,也可以恢復到未修改的檔案喔。 取消已經暫存的檔案 假如我們有兩個檔案需要 commit,但是不小心按到 git add * 全部加入到暫存區,那該怎麼恢復呢? # On branch [...]
Read Full Post »
Posted in Git on Aug 18th, 2010
相信大家對 Git 並不陌生,這次在升級 Moztw 的討論區,從 3.0.5 升級到 3.0.7 p1,過程由其他 Moztw 成員升級,我在將最後程式 commit 到 github,因為兩個版本差異性很大,所以有新增多個檔案,commit 過程出現了錯誤訊息:「You have some suspicious patch lines」,這是因為 git 會檢查每行程式碼最後是否有多餘空白或者是 Tab 按鍵,為瞭解決此問題,可以去修改 .git/hooks/pre-commit,將底下程式碼: if (s/^\+//) { $lineno++; chomp; if (/\s$/) { bad_line("trailing whitespace", $_); } if (/^\s* \t/) { [...]
Read Full Post »
Posted in C/C++ on Aug 4th, 2010
串接函式 strcat strcat 此函式用來連接兩字串合併成單一字串,直接看底下範例: /* strcat example */ #include <stdio.h> #include <string.h> int main () { char str[80]; strcpy (str,"these "); strcat (str,"strings "); strcat (str,"are "); strcat (str,"concatenated."); puts (str); return 0; } output: these strings are concatenated. 看一下 strcat 原始碼: char * strcat(char * __restrict s, [...]
Read Full Post »
Posted in C/C++ on Aug 3rd, 2010
strstr 這次介紹 C 語言常用 string 函式:strstr,主要是針對兩個輸入參數做比對,Parameters 1 是輸入字串,Parameters 2 是找尋字串,strstr 會先將頭一次比對成功的 pointer 回傳,也就是如果要找尋 appleboyappleboy 字串中的 boy,函式會回傳第一次比對成功的 boy pointer,而並非回傳最後一個比對到的,底下是一個參考範例: /* strstr example */ #include <stdio.h> #include <string.h> int main () { char str[] ="This is a simple string"; char * pch; /* 找尋 simple 字串 */ pch = strstr (str,"simple"); /* [...]
Read Full Post »