[Linux Kernel] 撰寫簡單 Hello, World module (part 1).

來筆記如何在 Kernel 撰寫 hello world! module,在 Ubuntu Kernel 2.6.31-14 環境下撰寫,其實不難啦,首先先進入 Kernel 目錄,請在 /usr/src 底下看自己的系統版本,或者是利用 uname -r 來知道 Kernel 版本,底下是在 Ubuntu Kernel 2.6.31-14 Kernel 實做: 進入 Kernel 目錄 # # cd Kernel directory # cd /usr/src/linux-headers-2.6.31-14-generic-pae 建立 hello 目錄 # # mkdir directory # mkdir hello 建立 Makfile 以及 hello.c hello.c: #include /* pr_info 所需 include 檔案*/ #include #include /* 所有 module 需要檔案*/ #include MODULE_DESCRIPTION("Hello World !!"); MODULE_AUTHOR("Bo-Yi Wu "); MODULE_LICENSE("GPL"); static int __init hello_init(void) { pr_info(" [Read More]

WordPress 3.0 Release “Thelonious”

WordPress 在6月17日 Release 3.0 版本名稱:Thelonious,官方部落格 WordPress 3.0 “Thelonious”,使用者可以在這裡下載,或者是利用後台方式升級,這次更新了 1,217 bug 修正以及功能增加,可以看底下官方網站影片:

大家可以參考 3.0 版本更

詳細介紹,以及 long list of issues in Trac。感謝 218 位 contributors 為 3.0 的貢獻,目前官方也繼續開始邁向 3.1 的開發。

[phpBB3 外掛] 根據使用者文章數目限制簽名檔顯示

前一篇提到:『[教學] phpBB3 使用者簽名檔 url 連結加上 rel=”nofollow”』,本篇會將其做成後台,方便管理者可以從後台管理,這次加上一個新功能:『限制使用者顯示簽名檔』,根據使用者文章數量來決定是否顯示簽名檔,可以避免想要來打廣告的新註冊使用者,限制文章數量是一種方式,但是也不是最好的方式,phpBB3 本身可以在後台限制是否顯示使用者簽名檔,不過我想各大站長都會開放此功能,好讓使用者可以放個人網站或者是部落格,底下是外掛安裝方式: 安裝 打開 includes/acp/acp_board.php 找尋 # # Find # 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 後面加上 # # after add # 'max_sig_post_count_limit' => array('lang' => 'MAX_SIG_POSTS_LIMIT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true), 打開 viewtopic.php 找尋 # # Find # if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) 取代 # # Replace # if (($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs') && $row['user_posts'] >= $config['max_sig_post_count_limit']) || (isset($user->data['session_admin']) && $user->data['session_admin'])) 中文化 打開 language/zh_cmn_hant/acp/board. [Read More]

[教學] phpBB3 使用者簽名檔 url 連結加上 rel=”nofollow”

基於 Moztw 討論區 有大陸使用者註冊之後,在簽名檔加入一些廣告連結,為了降低 Google Page Rank,所以我們必須指示搜尋引擎「不要前往此網頁上的連結」或是「不要前往此連結」,可以參考 關於 rel=“nofollow”,phpBB3 編輯三個檔案就可以了,此修改不影響文章內容,只有針對簽名檔作用,底下是 patch 程式碼,可以參考看看 includes/bbcode.php --- phpBB3/includes/bbcode.php 2010-03-06 04:37:23.000000000 +0800 +++ www/includes/bbcode.php 2010-06-10 20:58:02.000000000 +0800 @@ -2,7 +2,8 @@ /** * * @package phpBB3 -* @version $Id$ +* @version $Id: bbcode.php 9461 2009-04-17 15:23:17Z acydburn $ +* @log 2010-06-10 appleboy $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @@ -48,7 +49,7 @@ /** * Second pass bbcodes */ - function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = false) + function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = false, $bbcode_is_sig = false) { if ($bbcode_uid) { @@ -110,6 +111,13 @@ } $message = preg_replace($preg['search'], $preg['replace'], $message); + + /* + * 2010. [Read More]

[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter

之前介紹過 javascript FireFox Debug 工具 FireBug (Using firebug for firefox 除錯 javascript),今天來介紹 PHP 除錯工具 FirePHP,它可以輸出 PHP 資料到 FireBug console 介面,方便解決 PHP 相關問題,而不會去影響線上網站的畫面,安裝方式非常簡單,請先安裝 FireFox addon for FirePHP,重新啟動 FireFox 這樣就安裝成功了,接下來就是 include FirePHP Library 檔案,就可以正常使用了。另外還會介紹如何安裝到 CodeIgniter PHP Framework Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843 FirePHP: https://addons.mozilla.org/en-US/firefox/addon/6149 底下先看畫面: $array = array("a" => "1", "b" => "2"); $firephp->info($array, "info"); $firephp->warn($array, "warn"); $firephp->error($array, "error"); Install FirePHP 安裝 Ref : http://www.firephp.org/HQ/Install.htm 在 Zend Framework 已經有開發完成,可以參考:FirePHP and Zend Framework 1.6 下載檔案:Download FirePHPCore library version 0. [Read More]

[Linux Kernel] built-in vs. module

在編譯 Android Linux Kernel 2.6.29 Driver,常常遇到該把 Driver 用 built-in 或者是編譯成 module 呢?這其實看人習慣,就跟問你編輯器是用 Vim 或者是 emacs 是同樣意思,這兩者是有很大的差異,built-in 用在開機自動讀取載入,所以直接編譯成 uImage 檔案給嵌入式系統,像是 SCSI 或者是 SATA Driver 都建議編譯成 built-in 的方式,反而是一些音效驅動程式,可以編譯成 module,NTFS 就是可以編譯成 module,等您需要的時候在動態載入就可以,這樣可以減少 Kernel Image 的使用空間。 如果不想用 built-in 編譯,開機又需要驅動程式,那就需要透過 initrd 方式來啟動。底下整理兩者差異:

built-in:

開機自動載入,不可移除 Linux Kernel Image 大 需要重新 Compile

module:

可動態載入 Linux Kernel Image 小 不需要重新 Compile reference: [gentoo-user] kernel: built-in vs. module

[Ubuntu/Debian] 使用系統設定全域 http Proxy

如果想讓 Ubuntu/Debian 不管是 http 或者是 ftp 都可以透過 Proxy 去取得資料,就必須要設定系統 Proxy,目前任職公司就必須這樣設定,當然也可以透過其他方式出去(ex. ssh tunnel) 可以搜尋其他文章,底下分成兩種方式設定。 1. 利用 command line 方式設定

export http_proxy=http://username:password@proxyserver.net:port/
export ftp_proxy=http://username:password@proxyserver.netport/
寫入 ~/.bashrc
source ~/.bashrc 
2. 利用 Desktop 介面設定
Settings-> Preference -> Network
系統\偏好設定\代理伺服器
reference:

How to use apt-get behind proxy server (Ubuntu/Debian) Ubuntu Proxy的設定

[C/C++] count 1 bits of input value by shifting.

之前寫了一篇:『[C/C++] 計算二進位任意數含有多少個位元為1?』,裡面用 n &= (n - 1); 的方式來計算二進位數字總共會得到多少 bit,這次來紀錄利用 shift 方式也可以得到總共含有多少 bit 數目,函式如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #include <stdio.h> #include <stdlib.h> int count_1_bit_count(unsigned int); int main(){ int count = 0, a; a = 1023; count = count_1_bit_count(a); printf("%d有%d個位元為1\n\n", a, count); system("pause"); return 0; } int count_1_bit_count(unsigned int n) { int count = 0; for(count = 0; n ! [Read More]

[筆記] iframe 父頁子頁呼叫函式 parent call function

紀錄 iframe 如何呼叫子頁或者是父頁函式,iframe 在現今 Web 2.0 時代已經不流行了,因為有很多問題的存在,例如對於 SEO 搜尋引擎也沒有幫助,但是也是很多人在使用,底下筆記心得,說不定之後會 google 到自己的文章,哈哈。 父頁(主視窗)呼叫子頁函式:

/* iframeID 是 iframe ID*/
window.iframeID.formSubmit();
/* ifr 是 iframe ID */
document.getElementById('ifr').contentWindow.formSubmit();
子頁(iframe)呼叫父頁(主視窗)函式:
parent.formSubmit();
如果有兩層
parent.parent.formSubmit();
注意 timing issue,等 iframe 視窗 load 完之後才可以呼叫 iframe function。至於如果取主視窗跟 iframe 的變數 value,可以利用 jQuery $("#ID") 方式來得到。 reference:

【程式】JS : parent , iframe function call Access child function from iframe

[jQuery] 解決 IE6 PNG 透明背景 (Supersleight jQuery Plugin for Transparent PNGs in IE6)

今天無意間看到 Drew McLellan 在 2007 年寫了這篇 Transparent PNGs in Internet Explorer 6,真的是太晚發現這篇了,之前自己寫到一篇:『[CSS] IE 6, 7, 8 FireFox hack 支援透明背景圖 background or img javascript』,雖然 Google 官方網站宣佈完全不支援 IE6 瀏覽器,打算只支援 Microsoft Internet Explorer 7.0+, Mozilla Firefox 3.0+, Google Chrome 4.0+, Safari 3.0+,可是我們這些 Web Developer 還是需要考慮客戶的瀏覽器阿,因為客戶才是最大的,尤其是在一些學術機構,安裝好 XP,預設就是 IE6,從 Google 分析裡面,IE6 也是網站的客戶大群。 先來介紹 Drew McLellan 寫的一支好用 js 來改善所有 png 透明圖檔,最主要是修正 background-image 跟 img tag 所包含的 png 圖檔 先下載:Download SuperSleight,解壓縮放到 js 資料夾 針對 IE6 瀏覽器寫入 html [Read More]