2008年12月31日 星期三

blogger有奇怪的空格問題

剛剛發現...應該是blogger的bug吧...

當你在建立或修改文章時
每行文字開頭如果是空白
在切換 修改Html 和 撰寫 後,前頭的空白會自動少一個
少到最後就沒有空白了
但是如果開頭有tag,則不會有這個狀況發生...

例如以下的html

你切換個幾次 修改Html 和 撰寫 就會變成

前面的空白就不見了

這樣就不會


I'm having spacing issues in my posts
http://groups.google.com/group/blogger-help-publishing/browse_thread/thread/3c7094c3f16842c4
I have had a similar space problem.

While editing the blog, there's two tab named "modify html" and
"write"(I use the Chinese interface, so I'm not sure the exact name of
this two tab)

Whenever there are lines leading with spaces (spaces at the beginning
of the line), switching between the two tab would remove one leading
space of these lines, until no space at the beginning of the line.

Why does kernel set the obsolete bit?

For unknown reason, kernel set the obsolete bit in both device control register and device register, and never used.

Device Control Register


Device/Head Register


include/linux/ata.h

ATA_DEVICE_OBS  = (1 << 7) | (1 << 5), /* obs bits in dev reg */
ATA_DEVCTL_OBS = (1 << 3), /* obsolete bit in devctl reg */
ATA_BUSY = (1 << 7), /* BSY status bit */


drivers/ata/libata-core.c
/**
* ata_port_alloc - allocate and initialize basic ATA port resources
* @host: ATA host this allocated port belongs to
*
* Allocate and initialize basic ATA port resources.
*
* RETURNS:
* Allocate ATA port on success, NULL on failure.
*
* LOCKING:
* Inherited from calling layer (may sleep).
*/
struct ata_port *ata_port_alloc(struct ata_host *host)
{
struct ata_port *ap;

DPRINTK("ENTER\n");

ap = kzalloc(sizeof(*ap), GFP_KERNEL);
if (!ap)
return NULL;

ap->pflags |= ATA_PFLAG_INITIALIZING;
ap->lock = &host->lock;
ap->flags = ATA_FLAG_DISABLED;
ap->print_id = -1;
ap->ctl = ATA_DEVCTL_OBS;
ap->host = host;


include/linux/libata.h
static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)
{
memset(tf, 0, sizeof(*tf));

tf->ctl = dev->link->ap->ctl;
if (dev->devno == 0)
tf->device = ATA_DEVICE_OBS;
else
tf->device = ATA_DEVICE_OBS | ATA_DEV1;
}

drivers/ata/libata-core.c

/**
* ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
* @tf: Taskfile to convert
* @pmp: Port multiplier port
* @is_cmd: This FIS is for command
* @fis: Buffer into which data will output
*
* Converts a standard ATA taskfile to a Serial ATA
* FIS structure (Register - Host to Device).
*
* LOCKING:
* Inherited from caller.
*/
void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis)
{
fis[0] = 0x27; /* Register - Host to Device FIS */
fis[1] = pmp & 0xf; /* Port multiplier number*/
if (is_cmd)
fis[1] |= (1 << 7); /* bit 7 indicates Command FIS */

fis[2] = tf->command;
fis[3] = tf->feature;

fis[4] = tf->lbal;
fis[5] = tf->lbam;
fis[6] = tf->lbah;
fis[7] = tf->device;

fis[8] = tf->hob_lbal;
fis[9] = tf->hob_lbam;
fis[10] = tf->hob_lbah;
fis[11] = tf->hob_feature;

fis[12] = tf->nsect;
fis[13] = tf->hob_nsect;
fis[14] = 0;
fis[15] = tf->ctl;

fis[16] = 0;
fis[17] = 0;
fis[18] = 0;
fis[19] = 0;
}



http://www.nntpnews.net/f3455/re-patch-09-18-ide-add-set_irq-method-3125152/
http://www.spinics.net/lists/linux-ide/msg26882.html

2008年12月30日 星期二

[Browser] Cache Viewer

某些網頁的圖被層層javascript包圍就是不讓你點下載,關掉javascript就連圖也看不到 (哪些網頁?? ㄟ~~我現在能舉的例子都會讓本blog變18禁。孩子,等你遇到的時候就知道了)(謎之聲: 越萌的網頁越有機會)。針對這種 症頭,最簡單的解決方式就是從cache裡抓

用 IECacheView 檢視所有快取檔案 (Mozilla, Opera 和 Chrome 也有對應版本)
http://blog.joaoko.net/archives/945
IE的沒什麼大問題,因為它的Cache就是在某個目錄下,我的W2k是在C:\Documents and Settings\user\Local Settings\Temporary Internet Files,直接就是原來的檔案改個名字,直接去那個目錄直接看也行

MozillaCacheView v1.16 - View the cache files of Mozilla/Firefox browsers
http://www.nirsoft.net/utils/mozilla_cache_viewer.html
可能是因為firefox的Cache還多了一層index的關係,所以在index還沒寫入map檔的時候,cache viewer會讀到不正確的index
實際使用時常有有缺少檔案,或Cache都產生也看到了,開cache viewer也看不到或是只看的到部份,使用時最好把firefox關掉,以強迫index寫入檔案,再開cache viewer,會比較沒問題

地道的 Firefox 下載ニコニコ動画
http://saki117.wordpress.com/2008/06/29/%E5%9C%B0%E9%81%93%E7%9A%84-firefox-%E4%B8%8B%E8%BC%89%E3%83%8B%E3%82%B3%E3%83%8B%E3%82%B3%E5%8B%95%E7%94%BB/

不用跳進垃圾堆喇~CacheViewer 幫到你
http://saki117.wordpress.com/2008/07/28/%E4%B8%8D%E7%94%A8%E8%B7%B3%E9%80%B2%E5%9E%83%E5%9C%BE%E5%A0%86%E5%96%87%EF%BD%9Ecacheviewer-%E5%B9%AB%E5%88%B0%E4%BD%A0/
Mozilla/Firefox Cache
http://www.pyflag.net/cgi-bin/moin.cgi/Mozilla_Cache_Format

合作金庫銀行 定儲指數利率

台灣銀行
12/5 2.185%
12/15 1.535%

合作金庫12/15的定儲指數利率是2.210%
因為是用12/5的利率算的,那時候還在2.2左右
照這樣算,利率要到3/15才會掉到1.5左右

總覺得被婊到了...... \_/

http://www.tcb-bank.com.tw/tcb/abouttcb/brief_introduction/exloan.htm

本行「定儲指數利率」定義
依台銀、土銀、華銀、彰銀、一銀及本行等六家銀行一年期定期儲蓄存款機動利率之平均利率訂定之。

「定儲指數利率」計算方式、調整期間與調整日期
「定儲指數利率」調整方式:每三個月檢討調整一次,其公告生效日(即牌告調整日)為每年三月十五日、六月十五日、九月十五日及十二月十五日,並依生效日當月五日中央銀行公告上開六家銀行之一年期定儲機動利率以算數平均法計算平均利率訂定(小數點後取三位以下四捨五入),如生效日遇假日以次營業日為生效日。


各銀行的利率網頁
(馬的...還真難找...沒事東藏西藏幹麻....)
合作金庫
http://www.tcb-bank.com.tw/wps/WPS_PA_901/jsp/html/NTDInterestMore.jsp
第一銀行
http://www.firstbank.com.tw/A5.1.1.1.html
彰化銀行
https://www.chb.com.tw/chbib/faces/po/po01005/PO01005_1.jsp
華南銀行
https://ibank.hncb.com.tw/netbank/pages/jsp/T_RateQuerym/NTDIntRate.html
土地銀行
https://ebank.landbank.com.tw/infor/infor.aspx
台灣銀行
http://www.bot.com.tw/DPLNRate/DPLNBody.asp

2008年12月29日 星期一

[Greasemonkey script] 瀏覽男子漢的部落格必備

http://blog.kej.tw/2008-11/15/gm-script-fix-img-width-on-lucifer-blog/
*必須使用 firefox 瀏覽器

// ==UserScript==
// @name fix image width in lucifer's blog
// @namespace lucifer
// @include http://blogs.myoops.org/lucifer.php*
// ==/UserScript==

function shrinkPic(){
var friendlyPicWidth = 475;
var imgs = document.getElementsByTagName('img');
for(i = 0; i < imgs.length; i++){
if(imgs[i].width > friendlyPicWidth){
imgs[i].height = imgs[i].height * friendlyPicWidth / imgs[i].width;
imgs[i].width = friendlyPicWidth;
}
}
}

setTimeout(shrinkPic, 5000);



http://blogs.myoops.org/lucifer.php/2008/12/29/shimakou
這兩張圖是用來驗證 針對性 的效果嘛
尤其是那 奇美...看到了我就一整個不幸福
上了Greasemonkey script就好多了

雖然深知神器的效果
可這種 可遠觀不可褻玩焉 的 效果
還是看小點的圖好了.......

http://blogs.myoops.org/lucifer.php/2009/01/09/busdriver
http://blogs.myoops.org/lucifer.php/2009/01/09/busdriver#c50177
一直在想
到底為什麼要放這麼大的圖
而且非得清晰到 有幾顆痣都算的出來 不可

突然靈光一閃...
難道這是 朱大 與 大濕 們的用心良苦ㄚ
要戳破正妹的 面具 XX膜 化妝品...
告訴我們這些 小宅宅 們

有些 正妹 遠遠看就好
靠太近 一個不小心
正妹 是會變身 恐龍妹 的

只要突破限制
你就能正式脫離 小宅宅 升級成頂天立地的 男子漢 了嗎

2008年12月28日 星期日

台灣食物的英文

http://tw.dictionary.yahoo.com/search?ei=UTF-8&p=%E6%B3%A1%E8%8F%9C

泡菜
1. Chinese pickled vegetables; pickles


台灣食物~~英文怎麼說~~
http://www.wretch.cc/blog/lingotoo/20385778

一些台灣食物英文名
http://rainyblues.blogspot.com/2007/10/blog-post.html

台灣食物的英文
http://diary.blog.yam.com/imshock/article/4575713

火鍋英文 --中國火鍋和西洋火鍋歷史
http://www.wretch.cc/blog/ininlo/12028693
中國的火鍋
hot pot


世界是你的蚵仔 (火鍋料英文)
http://blog.sina.com.tw/popenglish/article.php?pbgid=26103&entryid=113068

印度人 的 吃

印度人吃飯的時間都比較晚
午餐大約一點吃
晚餐大約九點吃

吃素 的 印度人
有的人是素的就好...
但是也有人是不吃 蛋 根莖類 如蘿蔔,馬鈴薯 之類的

吃葷 的 印度人
也不是什麼都能吃
大多人只吃雞肉、紅肉(如羊肉)、海鮮
但不吃豬、牛肉

在台灣你吃葷的話很難去避免吃到豬肉
炒菜可能用豬油,吃麵吃飯甚至會加在菜裡的 肉燥


第八章 弘扬印度素食文化(3)
http://travel.163.com/06/1123/11/30K1O74500062319.html

印度素食者约占人口一半 印度教徒忌食牛肉
http://2008.sohu.com/20080415/n256296658.shtml

加拿大航空公司 不同类型的素餐
http://www.ivu.org/chinese/faq/travel_gb.html
VGML - 严格素食或纯素 - 非奶素 - 严格素食主义素食。“严格素食主义者或纯素者不吃任何种类的肉及肉制品,不吃鱼、家禽及含有猪油或明胶的食品。也不吃乳制品、蛋和蜂蜜。”

VLML - 奶蛋素 - 西方素食(Western Vegetarian)。“奶蛋素不吃任何种类的肉及肉制品,不吃鱼、家禽及含有猪油或明胶的食品。可以吃乳制品和蛋。奶酪必须是尽可能不含凝乳酶的(Rennet)。”

AVML–东方素食 - 亚洲/印度素食 - 穆斯林或印度教素食。亚洲/印度素食可能含有辣椒或其它香料,也可能含有少量奶制品。”

RVML - 生食者 - “生蔬菜,包括新鲜水果和(或)蔬菜。”

2008年12月27日 星期六

什麼鬼!!!

大大說: 看看assambly,會不會是被optimize掉了

發現一個怪情況,先記下來
kernel跟我越來越不熟了......
就這麼簡單的code....怎麼會產生這樣的輸出????


for(x=0;x<=96;x+=4) printk("0x12345678>>%d=%.8x\n",x,0x12345678>>x);
[ 1321.300269] 0x12345678>>0=12345678
[ 1321.300271] 0x12345678>>4=01234567
[ 1321.300272] 0x12345678>>8=00123456
[ 1321.300274] 0x12345678>>12=00012345
[ 1321.300278] 0x12345678>>16=00001234
[ 1321.300280] 0x12345678>>20=00000123
[ 1321.300281] 0x12345678>>24=00000012
[ 1321.300283] 0x12345678>>28=00000001
[ 1321.300285] 0x12345678>>32=12345678
[ 1321.300289] 0x12345678>>36=01234567
[ 1321.300291] 0x12345678>>40=00123456
[ 1321.300292] 0x12345678>>44=00012345
[ 1321.300294] 0x12345678>>48=00001234
[ 1321.300295] 0x12345678>>52=00000123
[ 1321.300297] 0x12345678>>56=00000012
[ 1321.300299] 0x12345678>>60=00000001
[ 1321.300301] 0x12345678>>64=12345678
[ 1321.300302] 0x12345678>>68=01234567
[ 1321.300303] 0x12345678>>72=00123456
[ 1321.300306] 0x12345678>>76=00012345
[ 1321.300307] 0x12345678>>80=00001234
[ 1321.300309] 0x12345678>>84=00000123
[ 1321.300310] 0x12345678>>88=00000012
[ 1321.300312] 0x12345678>>92=00000001
[ 1321.300314] 0x12345678>>96=12345678


還沒完....
for(x=0;x<=96;x+=4) printk("0x12345678>>%d=%.8x\n",x,0x12345678ULL>>x);
[ 1952.643777] 0x12345678>>0=12345678
[ 1952.643778] 0x12345678>>4=01234567
[ 1952.643779] 0x12345678>>8=00123456
[ 1952.643780] 0x12345678>>12=00012345
[ 1952.643781] 0x12345678>>16=00001234
[ 1952.643783] 0x12345678>>20=00000123
[ 1952.643784] 0x12345678>>24=00000012
[ 1952.643785] 0x12345678>>28=00000001
[ 1952.643786] 0x12345678>>32=00000000
[ 1952.643787] 0x12345678>>36=00000000
[ 1952.643788] 0x12345678>>40=00000000
[ 1952.643792] 0x12345678>>44=00000000
[ 1952.643793] 0x12345678>>48=00000000
[ 1952.643794] 0x12345678>>52=00000000
[ 1952.643795] 0x12345678>>56=00000000
[ 1952.643796] 0x12345678>>60=00000000
[ 1952.643798] 0x12345678>>64=12345678
[ 1952.643802] 0x12345678>>68=01234567
[ 1952.643803] 0x12345678>>72=00123456
[ 1952.643804] 0x12345678>>76=00012345
[ 1952.643805] 0x12345678>>80=00001234
[ 1952.643806] 0x12345678>>84=00000123
[ 1952.643808] 0x12345678>>88=00000012
[ 1952.643811] 0x12345678>>92=00000001
[ 1952.643813] 0x12345678>>96=00000000

2008年12月25日 星期四

西洋棋

遊戲玩法
http://hk.geocities.com/goodchessclub/rules.html

棋步記錄
http://hk.geocities.com/goodchessclub/notation.html

討論教學
http://hk.geocities.com/goodchessclub/lecture.html

西洋棋介紹
http://140.112.12.122/chess/p2.htm

Linux u64

使用u64的變數時需要特別小心,尤其是call-by-value, u64佔8byte, 要是被當成32-bit處理, 參數可就亂了, 到時候怎麼死的都不知道

include/asm-x86/types.h

#ifndef __ASSEMBLY__

typedef u64 dma64_addr_t;
#if defined(CONFIG_X86_64) || defined(CONFIG_HIGHMEM64G)
/* DMA addresses come in 32-bit and 64-bit flavours. */
typedef u64 dma_addr_t;
#else
typedef u32 dma_addr_t;
#endif

#endif /* __ASSEMBLY__ */


怎么给u64赋值?
http://linux.chinaunix.net/bbs/viewthread.php?tid=1035858
0x100000000ULL


Re: __udivdi3 and linux kernel u64 division question [x86]
http://search.luky.org/linux-kernel.2005/msg38382.html

如何处理两个u32相加溢出的问题? 定义了个u64似乎没用
http://www.unixresources.net/linux/clf/program/archive/00/00/60/56/605612.html
http://www.lslnet.com/linux/f/docs1/i38/big5279591.htm
printf("a = %08x %08x\n", a & 0xFFFFFFFF, a >> 32);
參數壓棧有關係的.
若不轉換, %08x %08x 需要 8字節 , a & 0xFFFFFFFF 也是8字節, 印出來的就是 a 的所有 8位.
printf("a = %08x %08x\n", a & 0xFFFFFFFF, 1234567); 的結果 也是 a = e0000001 00000000.
printf("a = %08x %08x\n", (u32)(a & 0xFFFFFFFF), (u32)(a >> 32) ); 才正確.



小问题:用printk如何直接打印出u64类型的大数??
http://topic.csdn.net/t/20041216/11/3650509.html
d,lx,ld,,lu,这几个都是输出32位的
hd,hx,hu,这几个都是输出16位数据的,
hhd,hhx,hhu,这几个都是输出8位的,
lld,ll,llu,llx,这几个都是输出64位的


[wiki] printf
http://en.wikipedia.org/wiki/Printf#printf_format_placeholders

2008年12月24日 星期三

Learning GIT


以一個初學者的角度
之所謂分散式,就是 做事在本地端做,但也能互相連結做更新


Add the following line to ~/.bashrc to select vi as the default editor:
export EDITOR=vi


Initial setting
git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

git config --global color.diff auto;
git config --global color.status auto;
git config --global color.branch auto;

git config --global alias.r rebase;
git config --global alias.rc "rebase --continue";
git config --global alias.ra "rebase --abort";
git config --global alias.rk "rebase --skip";
git config --global alias.st status;
git config --global alias.bi bisect;
git config --global alias.br branch;
git config --global alias.ci commit;
git config --global alias.cia "commit --amend";
git config --global alias.co checkout;
git config --global alias.f fetch;
git config --global alias.cp cherry-pick;
git config --global alias.ap "add -p";

git config --global branch.autosetuprebase always;
git config --global core.autocrlf false

or Edit the file $HOME/.gitconfig
[user]
name = Your Name Comes Here
email = you@yourdomain.example.com

[color]
diff = auto
status = auto
branch = auto

[alias]
rb = rebase
st = status
bi = bisect
br = branch
ci = commit
co = checkout
ap = add -p

srb = svn rebase
sci = svn dcommit
pu = pull
pullr = pull --rebase
pur = pull --rebase
ps = push
[branch]autosetuprebase = always
Only You Can Prevent git Merge Commits
http://www.viget.com/extend/only-you-can-prevent-git-merge-commits/


git ignore
$GIT_DIR/info/exclude: 整個project的ignore設定
.gitignore: 每個目錄(及以下子目錄)的ignore設定


Remote Operation
git clone <remote_src>
git init

git remote add <remote_name> xxx@xxx:/xxx :新增一個remote設定
git push <remote_name> 將local改變"推"到遠端
git push <remote_name> --all :"推"在.git/refs/heads/下所有的東西
git push <remote_name> --mirror : 推"在.git/refs/下所有的東西 which means .git/ref/heads, .git/ref/remotes and .git/refs/tags/

git pull :"拉"(fetch+merge)

git pull -t :只有"拉"tag
git fetch --tags

Local Operation
git add/rm :告訴git哪些檔案要commit,這些檔案會先進入index。這個過程也叫作Staging
git commit -m "xxx" :只commit有add進index的東西

git commit -a -m "xxx" :commit所有曾經commit的檔案中有 被改變被刪除 的檔案 (add+commit)

git log
git log --all

git checkout <SHA1_code> :切換到某次的commit,you are on "no branch" after checkout
git checkout <tag_name> :切換到某個tag,you are on "no branch" after checkout
git checkout <branch_name> :切換到某個branch
git checkout -b <branch_name> :新增某個branch並切換到它上面

git diff
git merge

git reset
git reset --mixed
(--mixed is the default action)
git reset HEAD :把某個檔案移出index(staging)

git reset --hard :把working tree和index全恢復,即回到 原始狀態
git reset --soft :什麼都不動,但"requires them to be in a good order".....到底是要幹嘛用的阿...



Fixing mistakes
http://kernel.org/pub/software/scm/git/docs/user-manual.html#fixing-mistakes
Fixing a mistake with a new commit
git revert HEAD
Fixing a mistake by rewriting history
git commit --amend


(謎之聲: git是 大大 等級玩的東西,大大的想法不是凡人可以看透的,像這種地雷只有你這種凡人才踩的到啊)
(謎之聲: 你快點回去火星吧,地球是很危險滴!!!)

怎麼找出git中有沒有dangling commit?
現在似乎除了看reflog外沒有其他辦法,新版的git會有warning on dangling commit...

<mkl> Is there anyway to check if there is dangling commit in current database?
<mkl> git log --all or gitk --all won't show dangling commit
<Ilari> mkl: You could extract recent such commits from reflogs, but I don't know easy and fast way to cross-reference them with current branches...
<mkl> yes, reflog seems the only way to find the dangling commit, but only if you aware that there is one, and you have to dig into a long log full with hex code.....
<Ilari> mkl: Also, commit followed by checkout moving from something non-symbolic is pretty good indication that something left dangling.
<mkl> yes, but only if you do aware of the situation....
<mkl> and also commit followed by checkout from tag

<charon> mkl: newer git says which branch you committed on, and indicates a dangling commit with [detached HEAD]
<charon> mkl: 72c69ebc035 which is in 1.6.1
<mkl> Thanks charon, Ilari, drizzd, milli, I finally got the problem clearified and fixed....

detached HEAD explained
http://sitaramc.github.com/concepts/detached-head.html

另一個問題..
首先我回到過去的某個commit: git checkout XXXXXXX

結束後我要回到目前最新的commit
可是突然發現....我不知道它的hash codeㄟ....
當然,在我git checkout XXXXXXX時會show原來的hash code...
但是要是不知道的話要怎麼回到最新的commit呢
git log也看不到...
看來是我自己不知道怎麼搞的搞出了奇怪的狀況
最可能的是因為我用git checkout XXX在不同的commit間切換看code後
直接git checkout <SHA1 of newest commit>然後就改code/commit了
這樣的commit是上去了,但不是在branch上,變成所謂的dangling commit

dangling commit
those commits that is not pointed by any branch/HEAD/tag, and neither the ancestor of any commit pointed by any branch/HEAD/tag

而且dangling commit不會被push/fetch/pull to/from remote端。一個不小心,dangling commit就會消失了...

* 可以用git branch顯示目前所在的branch,改code前一定要切到某個branch下才能改;checkout 某個commit或tag 後,git branch會變成(no branch),這時候不要commit
# git branch
* (no branch)
  test


git branch :list所有的branch與目前HEAD所在的branch

git log --all
list 出所有的commit(但是似乎dangling commit不會被list出來)

git reflog
Reflog is a mechanism to record when the tip of branches are updated. This command is to manage the information recorded in it. 它會log所有的 commit和checkout

git branch -D <branch_name>: 刪除branch
git branch -m <branch_name1> <branch_name2>: 改branch name(branch_name1 -> branch_name2)

.git/HEAD: 目前的指向的位置
.git/refs/heads/<branch_name>: branch "branch_name"指向的位置
.git/refs/tags/<tag_name>: tag "tag_name"指向的位置

git cherry-pick <SHA1_code> :apply某個commit
git merge <branch_name> :與某個branch merge,或者說,apply某個branch的改變

gitk
gitk --all :顯示所有的branch(也不會顯示dangling commit)



一小時內搞懂 Git
http://people.debian.org.tw/~chihchun/2009/01/05/understand-git-in-one-hour/

git-talk
http://media.gitcasts.com/git-talk.flv


Slides
http://www.slideshare.net/chacon/getting-git

The Git Community Book
http://book.git-scm.com/
http://book.git-scm.com/book.pdf

git gc :garbage collection

不小心刪掉了某個檔案
在svn可以很簡單的svn up就抓回來了...
git該怎麼辦呢?

我想到的辦法是用git diff產生patch再 patch -R....但是我覺得這樣應該是很蠢的
git該有辦法回復吧?
  • git reset --hard
    把所有改變(data/index)回復,不過不能就單個檔案回復
  • git checkout [FILE]
    回復單一檔案data,像svn revert那樣
    但如果檔案的index已經改變則要先恢復index才能用

    但只是git checkout沒給任何檔案不會回復任何檔案
  • http://www.kernel.org/pub/software/scm/git/docs/git-stash.html
    git stash
    git stash list
    git stash apply
    git stash apply stash@{1}
    git stash clear

又..該檔案又被我git rm掉了
雖然還沒有commit...
但是我該怎麼回到原來的狀態呢.....
(任何index的改變)
git reset
git reset -- [filename]
可以回復index的改變,但僅止於index,實際檔案資料則不行


git-reset(1) Manual Page
http://www.kernel.org/pub/software/scm/git/docs/git-reset.html

Git - SVN Crash Course
http://git.or.cz/course/svn.html

gittutorial(7) Manual Page
http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html

GitWiki - QuickStart
http://git.or.cz/gitwiki/QuickStart

Rex's blah blah blah - Learning git
http://people.debian.org.tw/~chihchun/2008/08/20/learning-git/

Everyday GIT With 20 Commands Or So
http://www.kernel.org/pub/software/scm/git/docs/everyday.html

Git User's Manual (for version 1.5.3 or newer)
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html

git-svn
http://asleepfromday.wordpress.com/2008/03/24/git-svn/

[Linux][軟體] Git-svn 使用簡單介紹
http://antontw.blogspot.com/2008/05/linux-git-svn.html

git-svn(1) Manual Page
http://www.kernel.org/pub/software/scm/git/docs/git-svn.html

2008年12月22日 星期一

iPhone vs and Freerunner 疊疊樂

同事新購入的iPhone...
3.5吋LCD看起來真是無限寬廣...
套一句新學的idiom, Comparing iPhone to Freerunner is comparing apples to oranges.
拿 時尚型男 跟 工程師宅宅 比....能比嗎...

哼...我能接console..你能嗎? (同事: ......... )

http://wiki.openmoko.org/wiki/Jokes

Q: What's the difference between an iphone and a freerunner?
A: One works but takes away your freedom, the other is free but needs your work



而且實在有夠給他薄的...


設計對白: 上面那位,您好像有點重ㄋㄟ....

小天天 取名字

姸秀、員如、雨潤、盈伸

真不知道這名字是怎麼算的....
要是真的取名叫 林盈伸 ....
我會被我女兒怨念到死喔.....
可能還會被po上ptt笑一輩子吧

http://140.111.1.40/yitia/fra/fra00894.htm


字號 A00894

正字 【妍】女-04-07

音讀 |ㄢˊ

釋義
訩豔麗、美好。如:「不辨蚩妍」、「百花爭妍」。文選.
 陸機.挽歌詩三首之二:「豐肌饗螻蟻,妍姿永夷泯。」
 文選.鮑照.蕪城賦:「才力雄富,士馬精妍。」




http://140.111.1.40/yitia/fra/fra02913.htm
字號
A02913

正字
【秀】禾-02-07

音讀
ㄒ|ㄡˋ

釋義
訜稻麥等穀類吐穗開花。詩經.大雅.生民:「實發實秀
  ,實堅實好。」唐.聶夷中.田家詩:「六月禾未秀,
  官家已修倉。」
 瞹泛指草木開花。唐.杜甫.九日寄岑參詩:「是節東籬
  菊,紛披為誰秀?」
 攰生長、成長。晉.顧愷之.神情詩:「冬嶺秀寒松。」
 涖表現、表演。為英語show的音譯。如:「秀一下」。

覑草木的花。漢.武帝.秋風辭:「蘭有秀兮菊有芳。」
  文選.張協.七命:「方疏含秀,圓井吐葩。」
 瞹才智傑出的人。如:「後起之秀」。晉書.卷六十五.
  王導傳:「顧榮、賀循、紀贍、周俰,皆南土之秀。」
 攰演出、表演。如:「做秀」、「一場秀」。
 涖姓。如春秋時宋有秀老。

訩草木繁茂。宋史.卷六十五.五行志.木志:「漢陽軍
  有插榴枝於石罅,秀茂成陰。」宋.歐陽修.醉翁亭記
  :「佳木秀而繁陰。」
 瞹清麗、俊美。如:「娟秀」、「清秀」、「山明水秀」
  。唐.韓愈.送李愿歸盤谷序:「清聲而便體,秀外而
  惠中。」
 攰優異、傑出。如:「優秀」、「一枝獨秀」。國語.齊
  語:「秀民之能為士者,必足賴也。」漢書.卷四十八
  .賈誼傳:「河南守吳公聞其秀材,召置門下,甚幸愛
  。」

2008年12月21日 星期日

2008年12月18日 星期四

WSG-1000 / G-Trender

靠...很給它心動ㄟ...


GPS,藍芽,氣壓高度計,電子羅盤
http://www.wintec.com.tw/b5/product_detail.php?pro_id=79%20style=


[分享] 媽祖婆加持過的WSG-1000
http://www.mobile01.com/topicdetail.php?f=130&t=590637&p=1
(有Wintec的人回答的討論)

[使用心得分享] 帶著 Wintec G-Trender / WSG-1000 記錄大甲媽遶逕
http://blog.xuite.net/uhoo/dc/16744510


G-Trender 可以記錄溫度與氣壓了
http://blog.xuite.net/uhoo/dc/17108440

定價大概在5k~6k
http://goods.ruten.com.tw/item/show?11080811265643
http://goods.ruten.com.tw/item/history?11080910454936
http://www.mml.com.tw/block/forum/index.php?action=forum_topicdetail&page=forum_topicdetail&f=429&t=117020&p=

vim related commands

VIM字串搜尋與取代
s(substitute)指令可搜尋某行列範圍。
g(global)指令則可搜尋整個編輯緩衝區的資料。
s 指令以第一個滿足該條件的字串為其取代的對象,若該行有數個滿足該條件的字串,也僅能取代第一個,若想取代所有的字串則需加上g參數。
c 詢問
:1,$s/old/new/g 將檔案中所有的『old』改成『new』。
:10,20s/^/ / 將第10行至第20行資料的最前面插入5個空白。
:%s/old/new/g 將編輯緩衝區中所有的『old』改成『new』。
:1,$s/$/ \\/c 在所有行後面加" \",每次都詢問
:1,$s/ /\r/c 把所有空白都變成換行,每次都詢問

:s/ *$//g刪掉以空白結尾的空白
:g/^$/d 將檔案中所有的空行刪掉
:10,20g/^$/d 將10-20行中空行刪掉

:g/XXXXXXX/ .,/YYYYYYYYYYY/d 刪掉XXXX到YYYY間多行
https://vi.stackexchange.com/questions/5265/how-to-delete-a-multi-line-match

gg (move to 1st line)
G (move to last line)

column select
^v (move arrow key to select area)

column delete
column select + d

column insert
column select + [shift]+i

delete word
dw

Line number
:set nu
:set nonu

Ignore Case (not case sensitive)
:set ic
:set noic

Disable indent
:set paste
:set nopaste

:e <files>

vsplit
split
^w<arrowkey>
:b<number>

shift+% 找對應的括號
shift+8 找現在cursor所在的word

tags
:set tags=tags
^]
^t
:ts or g]
:tag /search-string



Linux vi and vim editor: Tutorial and advanced features (include ctags)
http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
http://freehaha.blogspot.com/2007/06/vim-code.html
http://zcecil.net/?p=160
http://vim.sourceforge.net/tips/tip.php?tip_id=330
http://www.uic.edu/depts/accc/software/unixgeneral/vi101.html

Column Edit Mode in VI
http://pivotallabs.com/users/brian/blog/articles/350-column-edit-mode-in-vi

我的 VIM 之路
http://t.bsdx.org/2007/06/15/%E6%88%91%E7%9A%84-vim-%E4%B9%8B%E8%B7%AF/

2008年12月17日 星期三

Linux SATA AHCI

Per port priv structure

  • SG entry is limited to 168 entries
    • 65535 in spec
  • total 91392 (0x16500) bytes
  • alignment requirements
    • CLB (command header): 1-KB aligned
    • FB(rx fis buffer): 256-byte aligned
    • CTBA(command table): 128-byte aligned
    • DBA (data buffer): word(4-byte) aligned
  • Each PRD entry (of command table) could point to a buffer of maximum length of 4MB

2008年12月10日 星期三

Openmoko's software strategy for the next 6 months

http://lists.openmoko.org/pipermail/community/2008-December/037352.html

---1 current stable image
Our current stable image is called 'Om2008.9', available at http://downloads.openmoko.org/releases/Om2008.9/
We are sometimes cherry-picking fixes into it, but admittedly not as
many as we would like. If someone wants to step up to become stable
maintainer for this image and cherry-pick more fixes into it, please
let me know.
Alternatively, a number of other images are available, Debian, Qt
Extended, Android, FDOM, SHR, etc.
See http://wiki.openmoko.org/wiki/Distributions for a more
comprehensive list.

---2 Mickey's framework milestones
As many people know, the next big thing for Openmoko will be Mickey's
FSO framework around d-bus and Python, and the Paroli telephony UI.
See http://wiki.openmoko.org/wiki/OpenmokoFramework
A few weeks ago, Mickey released milestone 4, available at http://downloads.freesmartphone.org/fso-stable/milestone4.1/
In late January, he plans to come out with milestone 5, in late March
with milestone 6.
See here for a more detailed roadmap: http://trac.freesmartphone.org/roadmap

---3 next major release, Om2009
After the next 2 FSO milestones, Openmoko will fork off a stable
branch, and spend 2-3 months on testing and bug fixing. This will lead
to our next major release, Om2009.
The telephony UI will be Paroli, see http://code.google.com/p/paroli/
The way things are going right now, we will probably have this release
mid-next year.

2008年12月9日 星期二

FSO milestone4

http://wiki.openmoko.org/wiki/OpenmokoFramework/Status_Update_5
http://wiki.openmoko.org/wiki/FSO_UI_Tutorial
http://wiki.openmoko.org/wiki/FSO_ringtones
http://downloads.openmoko.org/daily/testing/


http://downloads.freesmartphone.org/fso-stable/milestone4.1/

http://lists.openmoko.org/pipermail/community/2008-November/035922.html
1. fso-console-image: minimal system with frameworkd, no user interface manager.
2. fso-illume-image: everything in console-image plus X-Window, plus
Enlightenment plus Illume window manager.
3. fso-image: everything in illume-image plus Zhone. Can be used for phone
calls. Like previous milestones. But Zhone is going to be faded out.


illume
http://downloads.freesmartphone.org/fso-stable/milestone4.1/openmoko-fso-illume-image-glibc-ipk--20081120-om-gta02.rootfs.tar.bz2
Zhone
http://downloads.freesmartphone.org/fso-stable/milestone4.1/openmoko-fso-image-glibc-ipk--20081120-om-gta02.rootfs.tar.bz2

http://downloads.freesmartphone.org/fso-stable/milestone4.1/uImage-2.6.24+r10+gitr6e2a723ef54ee2e739c34786981b2c508db803c1-r10-om-gta02.bin


ringtone profiles
YAML configuration file
/etc/freesmartphone/opreferences/conf/phone
/etc/freesmartphone/opreferences/conf/profiles/default.yaml

To change this default ringtone :

1. copy the sound file into /usr/share/sounds/
2. edit the "ring-tone" field to match your sound filename.

2008年12月8日 星期一

中文化 on OM & Qt

http://www.openmobilefree.net/index.php?entry=entry081205-171449

Qt的中文其實跟我之前的結果差不多
簡訊的中文就可以看到了,但是電話簿的卻看不到(亂碼)
mplayer在play list時看的到,但是在播放中的仍是亂碼
我想可能是程式有特別指定導致的,可能得改程式才有解(?)

  1. Copy font file to /opt/Trolltech/Qtopia/lib/fonts
  2. echo "simsun simsun.ttf FT n 50 0 su" >> /opt/Trolltech/Qtopia/lib/fonts
    (注意寫入的內容與使用的字型相關)
    (我之前是沒有做這一步啦,不過結果似乎一樣)


OM的部份則很成功,簡訊和電話簿中都可以看到中文了
  1. Copy font file to /usr/share/fonts/truetype/
  2. set Openmoko LANG
    echo "export LANG=zh_CN.UTF-8" >> /usr/bin/x-window-manager
  3. Edit /usr/share/applications/*.desktop
    [Desktop Entry]
    Name=Application Manager
    Name[zh_CN]=程序管理
    Comment=Update, install and remove applications
    Encoding=UTF-8

(以上zh_CN應改為zh_TW)



http://wiki.debian.org.hk/w/Make_Debian_support_Chinese
http://www.linuxsir.org/bbs/lastpostinthread315838.html
zh_CN
zh_TW
zh_HK
这些不关编码的事
编码需要在后面指定
比如zh_CN.GB2312 zh_CN.UTF-8 zh_HK.UTF-8

Bleeding edge

[Wiki] Bleeding edge
http://en.wikipedia.org/wiki/Bleeding_edge

什麼是bleeding edge呢?
http://tw.knowledge.yahoo.com/question/question?qid=1306031309229

bleeding edge 是一個新名詞,是從 leading edge / cutting edge (最尖端) 這個詞變化過來的,至於為什麼會用 "bleeding" (流血/犧牲)呢?

用bleeding表達了這產品實在是太新了,所以擁有它是要付出(犧牲)代價的,哪些代價呢? 可能是產品穩定性還不夠(所以你成了新科技的白老鼠??),也可能是產品賣的是天價(所以你成了凱子??),所以說,這真的是 "bleeding edge"啊。

Installing Ubuntu to new PC with RAM > 4GB and nVidia graphics card

Intel Core2Quad Q9550 @ 2.83GHz
Asus P5Q
8G DDR2 800
EN9500GT OC/DE/512M
SATA ExcelStor Technology J8160S 160GB
SATA Optiarc DVD RW AD-7200S


Ubuntu 7.04 have problem while starting X

Ubuntu 8.04 lte, Ubuntu 8.10
no matter AHCI or not,installing to a SATA disk, or USB to IDE (WD1600JB WD Caviar SE, IDE 160GB)
Stop while installing system around 50% with following reported:
The installer encountered an error copying files to the hard disk:

[Errno 5] Input/output error

This is often due to a faulty CD/DVD disk or drive, or a faulty hard disk. It may help to clean the CD/DVD, to burn the CD/DVD at a lower speed, to clean the CD/DVD drive lens (cleaning kits are often available from electronics suppliers), to check whether the hard disk is old and in need of replacement, or to move the system to a cooler environment.
nVidia+8GB RAM issue, all ok after remove RAM to size


Debian 4.0r3
No common CD-ROM driver was detected
........
This seems that AHCI CD-ROM not supported yet


Fedora 9
Finished installation, rebooting, then there comes the Welcome menu, system hang after finish [Hardware Profile].
nVidia+8GB RAM issue, all ok after remove RAM to size


NVidia GeForce Video Adapters Not Supported on Computers That Use PAE
http://support.microsoft.com/kb/283296
NVidia GeForce 使用 PAE 的電腦上不支援視訊介面卡
http://support.microsoft.com/kb/283296/zh-tw
[Wiki] Physical Address Extension(PAE)
http://en.wikipedia.org/wiki/Physical_Address_Extension
Physical Address Extension - PAE Memory and Windows
http://www.microsoft.com/whdc/system/platform/server/PAE/PAEdrv.mspx
PAE in 8.10 desktop?
http://ubuntuforums.org/showthread.php?t=957430
The server kernel has been compiled with PAE (which solves the problem) and with Xen related things. The latter prevents the installation and use of the NVidia proprietary drivers. Depending on your configuration, this may create another problem, which can be solved by compiling your own kernel, with PAE but without Xen support.

32 bit Ubuntu with 4GB+ of memory
http://ubuntuforums.org/showthread.php?t=855511

RAM >=4G requires to enable PAE
nVidia driver cannot work with Xen enabled

Ubuntu desktop have PAE and Xen disabled
Ubuntu server have both PAE and Xen enabled

but why Ubuntu desktop installation would failed? (unknown)

Solutions
  1. Remove RAM to size < 3GB, install ubuntu desktop, rebuild kernel to enable PAE, re-insert RAM
    (Ubuntu could reboot with 8GB RAM installed and w/o PAE enabled, but there is only 3292MB RAM available, shown on htop, while w/ PAE,8106MB.

    Besides, enabling nVidia accelerated graphics driver w/o PAE enabled w/ 8GB RAM installed, error like the following might be seen while restarting:
    Ubuntu is running in low-graphics mode
    The following error was encountered. You may need to update your configuration to solve this.
    (EE) NVIDIA(0): Failed to load the NVIDIA kernel module!
    (EE) NVIDIA(0): *** Aborting ***
    (EE) Screen(s) found, but none have a usable configuration.

  2. Install ubuntu server, rebuild kernel to disable Xen.
    (not tried yet)

To Enable PAE
-> Processor type and features
-> High Memory Support
-> 64GB

Installation of ATI and nVidia Graphics drivers
http://ubuntuguide.org/wiki/Ubuntu:Intrepid#Installation_of_ATI_and_nVidia_Graphics_drivers
http://www.nvidia.com/object/linux_display_ia32_177.82.html

  1. [System] -> [Administration] -> [Hardware Drivers] -> (Choose a nVidia accelerated graphics driver) -> [Activate]
    (the chosen driver has "restart" sign before it)
  2. restart X or reboot

glxgear result
w/ nVidia driver: 4400-4600 FPS
w/o nVidia driver: 390-420 FPS


ubuntu server kernel misidentified as xen?
http://www.nvnews.net/vbulletin/showthread.php?t=112102
I'm trying to install the 169.12 driver (from nvidia's .run file). The kernel I am using is from Ubuntu 8.04, the "2.6.24-16-server" kernel. The installer refuses to install into this kernel: it reports
Code:
The kernel you are installing for is a xen kernel.

Linux文字模式下燒錄ISO光碟 - cdrecod

[燒錄]Linux文字模式下燒錄光碟(ISO)
http://ku777.blogspot.com/2008/04/linuxiso.html
http://csc.ocean-pioneer.com/docum/linux_burn.html



cdrecord --scanbus
scsibus3:
3,0,0 300) 'Optiarc ' 'DVD RW AD-7530B ' 'NX09' Removable CD-ROM
3,1,0 301) *
3,2,0 302) *
3,3,0 303) *
3,4,0 304) *
3,5,0 305) *
3,6,0 306) *
3,7,0 307) *


dd if=/dev/scd0 of=/tmp/fed9_1.iso
cdrecord dev=/dev/scd0 speed=2 fs=8m -v -eject -dummy /tmp/fed9_1.iso
cdrecord -v dev=/dev/scd0 speed=4 -isosize /dev/hdc

ps: 我在Ubuntu8.04上無法使用dev=3,0,0,用dev=/dev/scd0則ok

Begining Python: From Novice to Professional - 2

#Collecting parameters
def print_parm(*arg,**named_arg):
print(arg,"---",named_arg)

print_parm(1)
print_parm(1,2)
print_parm([1,2,3,4])
print_parm(*[1,2,3,4])
print_parm((1,2,3,4))
print_parm(*(1,2,3,4))
print_parm({"a":1,"b":2,"c":3})
print_parm(**{"a":1,"b":2,"c":3})
print_parm(1,2,3,{"a":1,"b":2,"c":3})
print_parm(1,2,3,a=1,b=2,c=3)


#class
class sample:
def __double_underscore_would_be_renamed_should_not_access(self):
print ("should not be access directly")
def access(self):
print("access first")
self.__double_underscore_would_be_renamed_should_not_access()
def _single_underscore_method_would_not_be_imported(self):
print("I will not be imported")


x=sample()
x.access()
#you can't call x.__double_underscore_would_be_renamed_should_not_access() directly
#but you can...
x._sample__double_underscore_would_be_renamed_should_not_access()

Python on Freerunner

http://wiki.openmoko.org/wiki/Python
GTK

#!/usr/bin/python
import gtk

#create a (nonvisible) window
w = gtk.Window()

#create a button (not yet on any window)
b = gtk.Button('Hello')

#put the button on the window
w.add(b)

#create a silly callback function
def hello(target):
print 'Hello world'
exit()

#make the button call the callback when pressed
b.connect('clicked', hello)

#make the window display
w.show_all()

#start processing screen events
gtk.main()

http://www.pygtk.org/reference.html
http://www.pygtk.org/docs/pygtk/

http://wiki.openmoko.org/wiki/EFL_Documentation
etk examples
http://svn.enlightenment.org/svn/e/trunk/BINDINGS/python/python-etk/examples/
ETK
import etk

#create a button (not yet on any window)
b = etk.Button(label="Hello")

#create a (nonvisible) window and put the button on the window
w = etk.Window(title="Hello", child=b)

#create a silly callback function
def hello(target):
print 'Hello World'
etk.main_quit()

#make the button call the callback when pressed
b.on_clicked(hello)

#make the window display
w.show_all()

#start processing screen events
etk.main()

2008年12月7日 星期日

SATA AHCI onboard (PC)

http://www.intel.com/support/chipsets/imst/sb/CS-012304.htm

* Intel® ICH10R/DO SATA RAID/AHCI controller hub
* Intel® ICH10D SATA AHCI controller hub
* Intel® ICH9M-E SATA RAID/AHCI controller hub
* Intel® ICH9M AHCI controller hub
* Intel® 82801IR/IO Controller Hub (ICH9R/DO) - RAID and AHCI
* Intel® 82801HEM I/O Controller Hub (ICH8M-E) - RAID and AHCI
* Intel® 82801HBM I/O Controller Hub (ICH8M) - AHCI only
* Intel® 82801HR/HH/HO I/O Controller Hub (ICH8R/DH/DO) - RAID and AHCI
* Intel® 631xESB/632xESB I/O Controller Hub - RAID and AHCI
* Intel® 82801GHM I/O Controller Hub (ICH7MDH) - RAID only
* Intel® 82801GBM I/O Controller Hub (ICH7M) - AHCI only
* Intel® 82801GR/GH I/O Controller Hub (ICH7R/DH) - RAID and AHCI
* Intel® 82801FR I/O Controller Hub (ICH6R) - RAID and AHCI
* Intel® 82801FBM I/O Controller Hub (ICH6M) - AHCI only


五大家族57款 整合主板芯片组编年史回顾 (10) Intel G43, G45
http://tech.sina.com.cn/h/2008-12-08/10322633138.shtml

Intel chipset IDE -> AHCI (Windows)
http://jsli.blogspot.com/2008/08/intel-chipset-ide-ahci.html

主板开启AHCI接口,SATA硬盘的XP系统安装 全攻略
http://itbbs.pconline.com.cn/diy/8973801.html

2008年12月4日 星期四

張懸 寶貝

http://tw.youtube.com/watch?v=gt7ZO5YAMuM
我的寶貝 張懸

寶貝 張懸演唱

我的寶貝 寶貝
給你一點甜甜,讓你今夜都好眠
我的小鬼 小鬼
逗逗你的眉眼,讓你喜歡這世界

嘩啦啦啦啦啦我的寶貝,倦的時候有個人陪
唉呀呀呀呀呀我的寶貝,要你知道你最美

我的寶貝 寶貝
給你一點甜甜,讓你今夜很好眠
我的小鬼 小鬼
捏捏你的小臉,讓你喜歡整個明天
嘩啦啦啦啦啦 我的寶貝
倦的時候有個人陪
唉呀呀呀呀呀 我的寶貝
要你知道你最美
嘩啦啦啦啦啦 我的寶貝
孤單時有人把你想念
唉呀呀呀呀呀 我的寶貝
要你知道你最美

Begining Python: From Novice to Professional

Install
http://www.python.org/download/
http://www.python.org/download/windows/
http://www.python.org/ftp/python/3.0/python-3.0.msi

Types
int,long,float

+,-,*,%,
/
before python3.0,
int use floor round, or use
from __future__ import division
to get float result from int division


// int division
** exponentiation


Hexadecimals: 0xXXXX

Octals:0XXXX(python3.0不會動...)

Container: sequence, mapping

Sequences: list, tuple, string, unicode string, buffer object, xrange object

List
index from 0

Sequence addition
>>> [1,2,3]+[4,5,6]
[1, 2, 3, 4, 5, 6]

Sequence multiplication
>>> [42]*5
[42, 42, 42, 42, 42]

Slicing
>>> xxx=[1,2,3,4,5,6,7,8,9,0]
>>> xxx[4:6]
[5, 6]

>>> xxx[-3:]
[8, 9, 0]
>>> xxx[:]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
>>> xxx[5:-3]
[6, 7]
>>> xxx[:2]
[1, 2]

Step
>>> xxx[::2]
[1, 3, 5, 7, 9]
>>> xxx[1::2]
[2, 4, 6, 8, 0]

keywork None
>>> xxx=[None]
>>> xxx
[None]

>>> len(x)
0
>>> len(xxx)
10
>>> max(xxx)
9
>>> min(xxx)
0

Sequence deletion
>>> del(xx[3])
>>> xx
['h', 'e', 'l', 'o']

Item Assignment
>>> xx
['h', 'e', 'l', 'l', 'o']
>>> xx[2]="a"
>>> xx
['h', 'e', 'a', 'l', 'o']

Slice Assignment
>>> xx[2:]=list("llo")
>>> xx
['h', 'e', 'l', 'l', 'o']

Convert to list
>>> list("hello")
['h', 'e', 'l', 'l', 'o']

string is not changable, like tuple.
>>> x="hello"
>>> x[3]="a"
Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
x[3]="a"
TypeError: 'str' object does not support item assignment
>>> xx=list(x)
>>> xx[3]="a"
>>> xx
['h', 'e', 'l', 'a', 'o']

Membership check -- in
>>> xxx=[1,2,3,4,5,6,7,8,9,0]
>>> 3 in xxx
True
>>> 10 in xxx
False

List methods - object.method(argument)
append(value)
count(value) - count the occurances of the given value
extend(list_object)
index(value) - find the index of the given value
insert(pos,value)
pop(pos) - remove the element of the given position, the last one if pos not given
remove(value)
reverse()
sort()
sort(cmp)
sort(key=len)
sort(reverse=True|False)


Tuple
>>> 1
1
>>> 1,
(1,)
>>> (1,)
(1,)
>>> (1)
1

Convert list to tuple
>>> tuple([1,2,3])
(1, 2, 3)
>>>


Strings
single quote '
double quote "
escape \

String Concatenation +
String representations
str(x)
repr(x) or backticks `x`

Long string """ or '''
Raw string r"xxx"
Unicode string u"xxx"


Dictionary
>>> xx={'x':1,'y':2,'z':3}
>>> xx['y']
2
>>> dict([('name','alice'),('age',22)])
{'age': 22, 'name': 'alice'}
>>> dict(name='ann',age=27)
{'age': 27, 'name': 'ann'}


>>> xx=dict(name='ann',age=27)
>>> 'name' in xx
True
>>> 'ann' in xx
False



Functions
float(object)
int(object)
long(object)
str(object)
repr(object)
list(object)
tuple(object)

print(string)
input(string)
raw_input(string)
pow(x,y[,z]) (x**y)%z
abs(number)
cmath.sqrt(number)

round(number[,ndigits])

sorted(seq)
reversed(seq)
math.ceil(number)
math.floor(number)
math.sqrt(number)
floor
ceil

Module
math
cmath

import <module>
from <module> import <function>

2008年12月3日 星期三

a solution to the echo issue

just a note, haven't tried it, been a little lazy recently....


http://lists.openmoko.org/nabble.html#nabble-td1486414|a1518726
In file /usr/lib/python2.5/site-packages/framework/subsystems/ogsmd/modems/ti_calypso/unsolicited.py, function percentCPI, line 210 aprox

Where it says:
info = {}


I have:
devchannel = self._object.modem.communicationChannel("DeviceMediator")
devchannel.enqueue( "%N0187" )
info = {}

李宗盛 希望

希望
作詞:李宗盛 作曲:李宗盛

養幾個孩子是我人生的願望 我喜歡他們圍繞在我身旁
如果這紛亂的世界讓我沮喪 我就去看看他們眼中的光芒

總有一天我會越來越忙 還好孩子總是給我希望
看著他們一天一天成長 我真的忍不住要把夢想對他講

總在他們的身上 看到自己過去的模樣
對自己、對人生、對未來的渴望

他們是我的希望 讓我有繼續的力量
他們是未來的希望 所有的孩子都一樣
他們是未來的希望 但願我能給他一個最像天堂的地方

依稀記得他們出生時的模樣 我和太太眼裡泛著淚光
雖然他長得和我不是很像 但是朋友都說他比我漂亮

毫無意外我真的越來越忙 還好孩子總是給我希望
如果能夠陪著他們一起成長 生命裡就算失去一些別的又怎麼樣

總在他們的身上 看到自己過去的模樣
對自己、對人生、對未來的渴望

他們是我的希望 讓我有繼續的力量
他們是未來的希望 所有的孩子都一樣
他們是未來的希望 但願我能給他一個最像天堂的地方

雖然我難免還是會想 這樣的歌很少人會欣賞
這一首歌無關兒女情長 只獻給我家那三個可愛的姑娘
他們在我心裡最柔軟的地方 雖然我總是身在遠方
我生命裡美好的一切願與他們分享