2010年7月11日 星期日

Integrate vim and lxr

LXR is the Linux cross reference which a "a software toolset for indexing and presenting source code repositories" (from lxr web site). It's very useful when you develop large software system with big team. There always are apis you never know and don't know how to use it or data object you need to check what's it exactly provided. But it provide web base interface and I want use it in my vim.

There is another advantage for me to integrate lxr and vim. Our team rebuild the lxr database to refresh member's update automatically and I don't have to update index database like cscope by myself which I did it past two years.

The way I integrate vim and LXR is quite simple. I think maybe it's just too simple and I can't find any related information from internet. Anyway, I made it myself and it does help to me.

I integrate the vim and LXR by provide a utility which send http request to LXR web server, parser the http response, and translate to cscope's line-oriented output. Then, the vim can interactive with cscope by line-oriented mode. It's so simple that you can even use shell script to make it and I made it with python. Actually it's a cscope line-oriented mode enumerator for LXR. :-) The other benefit is emacs can use it too.

The MOST IMPORTANT THING is that prompt of cscope is ">> ". Note the last space character. It's part of prompt. The space take me one day to debug. I even read the vim and global source code. You can avoid the stupid bug if you read my blog. It's OK to skip all other part of this article when you note this. :-)

Then, not all cscope functions can map to LXR. For example, cscope can only search who call a function or everyone called by a function. But the LXR provide all reference only. My team use older version's LXR and it provide less information then latest.

The last thing is LXR can tell you a line of a source file reference to the keyword you search but no code segment. You have to check each result You can either send another http request to LXR web server to get code segment or grep source file according to the file path provided by search result. The code segment is very very helpful when you get large search result.

2010年6月7日 星期一

Add font without root in linux

My job is software development in Linux. Our company provide many servers for development. Of curse, I don't have root permission. But I want some great font for coding and that really help a lot. So I try to use font in my terminal without root permission.

Step:
1.put font file into .fonts in your home directory
2.run "fc-chace" update font cache. And you can check the font list with "fc-list"
3.set your application such gvim or terminal to the font you add.
That's all.

Linux Tutorial: Linux Fonts have detail information about fonts in linux.

2010年6月5日 星期六

Manul build Atheros AR8151 for ArchLinux

Well... This also take me couple hours. It shouldn't' be. So I need to note it for myself.

First, there is not build-in support for atheros AR8151 ethernet chip in archlinux. You need to build it by yourself.

2.extract tar ball to somewhere.
3.make sure you have related package like gcc, make, kernel header.
4.The driver from atheros default take /lib/modules/$(BUILD_KERNEL)/build for kernel header and I change to /usr/src/linux-$(BUILD_KERNEL) by change the order of KSP variable in src/Makefile
5.Refer to readme file in tar ball, I found I don't have version.h in header path and do "make include/linux/version.h" in linux source tree.
6.I use kernel 2.6.33 and it seems have a change which not use utsrelease.h file. But the driver makefile need it. I manually add a utsrelease.h in /usr/src/$(KERNEL_VERSION)/include/linux with content "#define UTS_RELEASE 2.6.33-ARCH"
7.build driver with "make" and "make install" to install it (don't forget install as root)
8.You should get a driver as kernel module in /lib/modules//kernel/drivers/net/atl1e/atl1e.ko. The readme file of tar ball show it as arl1e.ko but I get alt1e.ko. I don't know why but it don't matter. It's the driver for AS8151.
9.load the driver by "modprobe atl1e" and check it with "lsmod | grep atl1e"
10.Finish to build driver. You can test it by "ifconfig ethx

Then the AR5181 ethernet chip works. And don't forget to add it to MODULE of /etc/rc.conf or config modprobe for next boot.

archlinux and kdemod

I try to change to use ArchLinux. Documents of ArchLinx web are very helpful. I just follow the instruction and install it in my new laptop. Well...Almost. Actually I have problem in start kdemode. It told "kstartupconfig4 miss or fail......" and the result I google for it is that's related to gcc version. But I had installed newest gcc and it still have problem. If you are looking for step by step instruction, go to ArchLiux's website.

I give up to install kdemod and remove it in the end. But I found the pacman package system is very impressive. I note that the disk size usage before install and after remove are almost the same. That means pacman did remove kdemod and its dependency package clearly. Again, It's very impressive.

But the ArchLinux default deriver for my atheros AR928x seems have same problem with unbuntu 10.04. The network speed is terrible and I have no such problem in windows 7. It take almost two hours to download kdemod and I don't want do it again. I don't know how to fix it yet. But I was tired with it.

So I use awesome now and it just works fine. I will install kde (kdemod? No. Thanks.) after I fix network issue. Now... Time to bed.

[update 2010/06/07]
I don't know why the network interface doesn't slow after I install kde although I know it's not related to kde. Anyway, ArchLinux is very impressive and I like it. GoodBye~ Ubuntu.

2010年4月21日 星期三

個人使用的Tiddlywiki server版設定

因為現在改用Chrome不用firefox,所以在tiddlywiki存檔需要另外設定。基本上最方便的方式就是安裝jre,再配合一個存檔的jar就可以了。但是公司的電腦沒有開admin的權限,我也不想再請IT只為了這個裝jre,所以改試試看Tiddlywiki有什麼其他的方法。

目標是能從server上開啟Tiddlywiki再回存,因為是個人使用所以,權限比較不重要,利用firewall或server設定成只能local access就可以。也因為只是個人使用,所以希望是lightweight server。

Tiddily有一些server版,但是都需要mysql。加了mysql怎樣都lightweight不起來。所以後來使用了最方便的upload plugin。

所以結果是Tiddlywiki的upload plugin+store.php+php+mongoose web server。
Mongoose 是我所以找到能support php裡最lightweight的web server,只有56k的大小。也有ACL的功能,不需動firewall。
走cgi的php只需要php-cgi.exe+php5ts.dll+php.ini也很簡單,約5mb。

但是一開始還是有些不方便的地方。
第一個問題是會有個cmd的視窗,這可以從網路上找到利用com啟動可以達成,連vb的script也有,所以搞定。
第二個問題是upload plugin的upload需要密碼,每次都要重打,滿煩人的。這可以修改配合使用的store.php,或著是在Tiddlywiki裡設成預設參數Peristent Option。就不需要一直填密碼。

這樣就可以像在只用local file一樣,直接開,改完直接存。除了Tiddlywiki以外的檔案總共只要幾mb,不管是備份或是放到flash disk都很方便。這樣還有另外一個好處是自己的Tiddlywiki想用那個版本都沒問題,自行升級也沒問題,不受server限制,直接把Tiddlywiki拿來另外用也沒問題。

雖然不是最完美的solution,但是對我來說是最好的solution。

2010年3月23日 星期二

個人對Mercurial和Git的不同感想

在熟悉了Git後,又找了點時間學了Mercurial。之前準備要學習Git時,就找了很多資料。Mercurial和Git的各種比較當然更是不能少,所以對Mercurial也很有興趣。

Mercurial和Git實際儲存的方式很類似,所以熟悉了Git再看來Mercurial覺得很多觀念都很容易理解。不過有趣的是,因為Mercurial和Git使用了類似的資料儲存,我們可以說Mercurial和Git是用不同的觀點來操作同一份資料,因些產了大異其趣的兩種VCS(這裡說大異其趣也是有點誇大,因為對使用觀念還是很相近)。網路上Google這個Git和Mercurial分析(中文版)雖然有點舊,但還是很不錯。

就我的觀點來說,其實Mercurial其實比較算是VCS。Git連History可以改的功能讓我不太能接受,但是rebase又實在很實用。在我熟悉了Git之後,覺得Git其實比較像是Revision Exchange System,很多的功能都是為了讓contributer能夠很方便的把update送給maintainer,而maintainer也能最方便的把contributer的update merge進maintainer的source。也為了如此Git幾乎把把有的能力都開放給user,但也就是開放的太多太強大,也很容易讓user把repository搞壞。Pro Git裡也強調己經publish的commit最好不好再change或刪除,包含有些功能的本質就是rewrite commit。

其實單就功能性和理念上來說,我是比較喜歡Mercurial的一些特點,包括commit history不能改變,比較平緩的學習曲線,使用跨平台的Python,user容易寫自己的extension,還有對http的高度整合。

但是以我現在的使用環境,最需要的是local branch、history rewrite、rebase。所以我現在使用Git。還有另一個理由是我沒有root的權限,只要把Git build在家目錄裡就可以,相對來說較方便。

Git讓我覺得最不方便的就是在架設server的部分,Mercurial在server部分功能也相對比較方便。也剛我現在只是個人使用,沒使用到server的部分,但是在可預的未來還是需要的。

其實以Mercurial和Git底層的高度相似度,應該不太有因為架構上的差異而有一種能提供而另一種無法做到的功能。我想多半是因為理念的不同而不提供(或是認為不應該提供)。能互相參考,把好用的功能互相補強,當然是最好不過。最好是還可而互通,像對svn一樣的支援就最好不過了。不過我想這應該是我想太多了。:)

之前看到Git支援svn,本來以為可以靠git svn完整支援,把git當svn client,現在發現實際使用上除了有點地方要小心以外,好像dcommit也還有一點不穩定。這樣讓使用起Git,也無法發揮Git的強大。
Mercurial目前對svn的支援度我還不清楚,不過我想我可以以Python當標杆,Python在等hgsubversion的完成度也要轉換到Mercurial。當Python轉到Mercurial後就意味著hbsubversion就到達一定的可用度了。

PS:Mercurial的default package也包括了一些很重要但預設是不開啟的extension,像rebase及能達到local branch的bookmark。這讓我更喜歡這種extension的設計,讓你在嚴謹管理中,也能有一些做例外的能力。而Git也正在討論對http的支援。大家都朝正面的道路前進。

--update 2011/0905
Git在1.7之後就支援smart http讓使用http push或pull時更有效率

Git的local branch果然好用

前一陣子將Pro Git讀完了,開始使用Git來輔助在公司的工作。Git的local branch真是好用。在公司使用公司的VCS,要達到一定的完整性和正確性後才能check in,在還沒check in前自己做不同測試也很不方便,老是要把檔案搬來搬去備份來備去,還要自己做merge。當要同時處理不同功能時就更辛苦了。改用Git後,這些事都方便很多。只是Git實在是也不算好學。網路上有許多的文章,很多人簡介,但是我覺那些對初學者來說其實還是不太夠。雖然最重要的部分都不會少,但是對初學者來說反而更霧裡看花。我一開始看也是先看別人的介紹,但是總覺無法擋掌握Git。最後還是看完了Pro Git之後才覺得真正知道如何使用。

所以現在就變成從公司的VCS check out到自己的local後再使用Git,在不同的local branch做不同的測試,甚至是同時做不同的功能。最後再最後的結果check in進公司。有點像git svn的做法,但是是手動版本。而且公司也不是用svn,git svn幫不上忙就是了。

而且有了Git的rebase和輕鬆merge能力,同時開的local branch最後很也容易就能和公司的VCS的最新版本接軌。除了有時會忘記現在build出來的binary到底是那個branch以外都很方便,我想就大概是太方便的後果吧。