Kanru’s 探險日誌

當發現美好的事物時,所要做的第一件事,就是把它分享給所有人

Archive for the ‘小工具’ Category

Current state of Debian Chinese translations

with one comment

整理一下目前 Debian 各部份的中文翻譯狀況:

transgraph

收錄於 Debian 中的軟體的翻譯

這裡大部分是各種有收錄在 Debian 中的軟體的 PO 檔的翻譯,不是 Debian 特有的,主要協調者是 Zh-l10n。

參考:

Debian 套件設定樣板的翻譯

也就是 po-debconf 的翻譯,這些翻譯會出現在安裝套件後的設定畫面。目前有翻譯的還不多,想要進行翻譯的可以參考 popcon 分數決定要先從哪個套件開始。

可以使用這隻 script 來幫助翻譯:

  • 取得 po 檔
    • transhelp get abook
  • 編輯
    • edit abook/zh_TW.po
  • 檢查翻譯結果
    • transhelp check abook
  • 模擬顯示結果
    • transhelp display abook
  • 提交
    • transhelp send abook

transhelp 只是簡化翻譯的流程,真正要翻譯前請先參考 README-trans

Debian 套件描述的翻譯

套件描述的翻譯,這些翻譯會出現在套件管理軟體中 (如 aptitude) 或是 packages.debian.org 網站上。

無論你是要翻譯或是要 review,都可以透過網頁介面進行。

參考摩托學園:DDTSS翻譯 Debian 套件訊息

Debian 網站的翻譯

目前最重要的頁面都已經是最新了,其他常用頁面以及一些曾經翻譯過的頁面也在陸續整理中。我用 graphviz 畫了一張目前翻譯狀況的圖示,紅色代表目錄中有未翻譯網頁,綠色代表網頁已經跟原文同步。

想要參與翻譯的可以參考這裡這裡

Debian Installer 的翻譯

這裡整理了 Debian Installer 會用到的套件的翻譯,目前只剩下少數還未更新。

Lenny Release Note 的翻譯

很早就開始進行了,就我所知 Tetralet 已經翻譯了一部分。想要幫忙的可以聯絡他。

Lenny Install Manual 的翻譯

之前是 dreamcryer 翻譯的,現在聯絡不到人。簡體中文版已經翻譯的差不多了,想幫忙的人可以由此下手。

Debian Wiki 的翻譯:

不知道,Wiki 變化太快也許不適合進行翻譯。

其他

歡迎提供其他相關訊息 m(_ _)m

TODO: 整理到 Wiki 上

參考網站:http://www.debian.org/international/l10n/

Written by Kanru Chen

December 18th, 2008 at 1:33 am

Posted in Debian, 小工具, 爬網探險

Tagged with ,

Git branch in bash prompt

leave comments »

之前提過 zsh 有支援在 prompt 上顯示多種 VCS 資訊的功能,不知道 bash 上是否有人寫好同樣支援這麼多種 VCS 的 library,不過目前 git 附帶的 bash completion script 中有提供自訂 PS1 的函式。

只要呼叫 __git_ps1 即可得到目前的 git branch 的格式化輸出,可以自訂 prompt 如下


GITPS1='$(__git_ps1 ":%s ")'
export PS1="\w ${GITPS1}\$ "

就會顯示如


/usr/src/awesome :next $

這樣的 prompt

Written by Kanru Chen

December 13th, 2008 at 8:47 pm

Posted in 小工具, 爬網探險

Tagged with , , ,

Pdnsd - cache your DNS query

leave comments »

pdnsd 是一個小型的 proxy DNS server,主要功能就是 proxy 與 cache,而不是像 bind9 那樣的完整 DNS server。

雖然 DNS 通常不是網路延遲的主因,但有時候就是很慢,使用 pdnsd 前後可以差非常多。


% time host blog.kanru.info 168.95.1.1
0.00s user 0.01s system 0% cpu 0.963 total
% time host blog.kanru.info 127.0.0.1
0.00s user 0.00s system 65% cpu 0.011 total

在 Debian 系統上,如果你原本就有使用 resolvconf 的話,那麼只要在 configure 時選擇使用 resolvconf 就會動態的把 resolv.conf 內的 DNS server 包含,而 resolv.conf 只會剩下 127.0.0.1,如:


% /usr/sbin/pdnsd-ctl status
...
label: resolvconf
ip: 168.95.1.1
server assumed available: yes
ip: 192.168.1.1
server assumed available: yes
port: 53
...
% cat /etc/resolv.conf
nameserver 127.0.0.1

apt-get install pdnsd 完全零設定 ;-)

Written by Kanru Chen

December 8th, 2008 at 3:13 pm

Posted in Debian, 小工具, 爬網探險

Tagged with , , ,

為什麼 Git 比 X 好?

with one comment

當初一看到這個標題心裡想的是 Git 怎麼拿來跟 X 比?原來這個 X 是指其他 SCM…

http://whygitisbetterthanx.com/

很多人都注意到了,但是現在有

http://zh-tw.whygitisbetterthanx.com/

囉,小小替 Git 宣傳一下 :p

Written by Kanru Chen

December 6th, 2008 at 8:40 am

Posted in Programming, 小工具, 爬網探險

Tagged with ,

Vim - 以游標位置為基礎捲動螢幕

with 2 comments

不是人人都有大螢幕可以一次容納幾百行程式碼,且看文件時我們常會希望可以從頭看到尾,或者是寫文章時我們會希望可以從螢幕的最上頭開新段落然後一次寫一整個螢幕。

如果不熟悉以下命令,你可能常常要用 hjkl 或方向鍵去移動游標,調整顯示的範圍。但是,其實不用這麼辛苦。

zt 把游標下這行放到螢幕最上方

zz 放到中間

zb 放到最後

比如說,要開始寫新段落我只要 L 移動游標到最後,然後 zt ,我就會有一整頁空白的空間可以開始揮灑 :)

Written by Kanru Chen

December 1st, 2008 at 11:40 pm

Posted in Programming, 小工具, 爬網探險

Tagged with

Vim - 檔名太長怎麼辦

leave comments »

這是 vim 的一個小技巧,考慮以下情境:

  1. 我現在在 ~/ 目錄
  2. 因為某個原因我打開 vim 編輯 /usr/src/foodir/src/bardoor.c
  3. 看了看,發現需要參考同目錄下的 bardoor.h,於是打入命令 :tabe
  4. 接下來怎麼辦?因為目前工作目錄是 ~/,如果要用 vim 的 tab 補完的話還是需要把路徑再打一次
  5. 想一想再看答案 :)

    Read the rest of this entry »

Written by Kanru Chen

November 30th, 2008 at 7:25 pm

Posted in Programming, 小工具, 爬網探險

Tagged with

Abook Tags Support

leave comments »

Abook 是一個文字模式的通訊錄軟體,可以跟 mutt 搭配使用。

功能很齊全,就是沒有群組的功能…這個 patch 新增一個 tags 欄位,讓 abook 在搜尋的時候會搜尋 NAME, NICK, EMAIL, TAGS 四個項目,模擬群組的功能。

不知道若原作者看到這種 patch 會做何感想 XD

Written by Kanru Chen

November 23rd, 2008 at 9:49 pm

Posted in Programming, 小工具, 爬網探險

Tagged with , ,

使用 git-svn 整合 git 與 svn

leave comments »

git 是目前最紅的分散式 VCS 之一,我很喜歡用 git 因為他預設就有許多方便的特性如:

  • git log/diff/help 都有彩色的 pager 可用,不用再自己 pipe 到 less
  • git log 的格式一目了然,清晰易懂
  • git bisect/format-patch/shortlog/stash… 等趁手工具一堆
  • 速度快

而 git 不僅僅是 git,他分成高階的命令如 pull/commit 等,還有低階的命令可以直接操作 ref/object,因此有一些 VCS 就是建立在 git 的檔案系統上,運作起來跟 git 截然不同。

git-svn 是一個可以把 svn 當 git 用的工具,就算專案還在用 svn 也可以享受到 git 的便利。以下簡介一下 git-svn 的使用流程。

首先創造一個實驗用的 svn repository:


bob % cd /tmp/test
bob % svnadmin create hello
bob % svn co file:///tmp/test/hello hello-svn
bob % cd hello-svn
bob % svn mkdir branches tags trunk
bob % svn ci -m'Initial dir setup'

現在我們有一個傳統的 svn repository 了,加點東西進去吧:


bob % cd trunk
bob % echo "printf("hello\n");" > hello.c
bob % svn add hello.c
bob % svn ci -m'My first program :D'
bob % cd ..
bob % svn cp trunk tags/v0.1
bob % svn ci -m'tag v0.1'

這時候 Bob 已經建好他的程式 v0.1 版,Alice 知道了他的計劃也想加入,於是她用 git-svn 來取出 repository


alice % git svn clone --stdlayout file:///tmp/test/hello hello-git
Initialized empty Git repository in /tmp/test/hello-git/.git/
r1 = 80a0fc18653e8bc7d3784567b1b7024b20fd8c11 (trunk)
    A   hello.c
r2 = 4a80acebb6a41c208f3427498225f829950ee39e (trunk)
Found possible branch point: file:///tmp/test/hello/trunk => file:///tmp/test/hello/tags/v0.1, 1
Found branch parent: (tags/v0.1) 80a0fc18653e8bc7d3784567b1b7024b20fd8c11
Following parent with do_switch
    A   hello.c
Successfully followed parent
r3 = 24ca9410e9ca78ffa3bffa1c9ef574068d128935 (tags/v0.1)
Checked out HEAD:
  file:///tmp/test/hello/tags/v0.1 r3
alice % git reset --hard remotes/trunk

因為是使用 stdlayout,所以 tag/branch 等會自動對應到 remote branch


alice % cd hello-git
alice % git branch -r
  tags/v0.1
  trunk

Alice 發現 Bob 原本的程式無法 compile,因此開始修改,改完之後用 git add -p 挑選要 commit 的部份,然後把剩下的部份 stash 起來,最後用 git svn dcommit 提交給 Bob 的 svn repository


alice % edit hello.c
alice % git add -p
alice % git commit -m'Fix everything'
alice % git stash
alice % git svn dcommit

隔了幾天,Alice 發現 Bob 有更新,因此開始做同步。同時,因為她有一個 local branch,所以在更新完 master 之後,還需要把 fancy branch 跟 master rebase。


alice % git svn fetch
    M   hello.c
r6 = c43134a98f43dc6507deaa7495bfcd2c906aaa30 (trunk)
alice % git svn rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/trunk.
alice % git checkout fancy
alice % git rebase master
First, rewinding head to replay your work on top of it...
Applying: Inital fancy output branch

以上就是使用 git-svn 時會用到的大部分指令,其餘的就跟操作一般 git 一樣。

各命令的詳細說明可以參考 git-svn(1)

Written by Kanru Chen

November 23rd, 2008 at 6:03 pm

Posted in 小工具, 爬網探險

Tagged with ,

在隨身碟上用 LVM

leave comments »

要移除隨身碟之前,除了要 umount 外,記得要先用 vgchange 把 VolumeGroup 關掉,不然會在 /dev 殘留不能用的 vg/map。


vgchange -a n extdrive

這是一篇筆記。

Written by Kanru Chen

November 19th, 2008 at 12:39 pm

Posted in Linux, 小工具, 爬網探險

Tagged with

devscripts 系列: mk-build-deps

leave comments »

devscripts 是給 Debian developer 用的一些好用工具的集合,今天要介紹的是 mk-build-deps

Debian distribution 中包含了許多預先編譯好的 deb 檔,通常我們只要 apt-get install 安裝即可,但是當我們需要修改編譯參數或是製作新版本的套件時,就會需要 apt-get source 取得 source package 自行編譯。要製作 deb 時會要求先安裝一些相依套件,通常是 libfoo-dev 等,此時可以用 apt-get build-dep 自動安裝相依套件。

麻煩的地方是,透過 apt-get build-dep 安裝的套件並不是因為跟任何套件有相依性才被安裝的,相等於直接 apt-get install,因此不會在你編譯完不需要的時候自動移除。如果時常要編一些東西的話,常常系統上會裝滿了許多 libxxx-dev 難以整理。有一個技巧就是利用 equivs 製作 metapackage ,把編譯需要的套件都包含進去,以後不需要了只要移除這個 metapackage 就可以把所有相依套件移除乾淨。

mk-build-deps 就是把這個技巧自動化的工具,使用範例如下:


% mk-build-deps network-manager-gnome
dh_testdir
dh_testroot
dh_clean -k
dh_testdir
dh_testroot
dh_install
dh_installdocs
dh_installchangelogs
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dpkg-deb: building package <code>network-manager-applet-build-deps' in</code>../network-manager-applet-build-deps_0.6.6-2_all.deb'.</p>

<p>The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!</p>

<p>% dpkg -f network-manager-applet-build-deps_0.6.6-2_all.deb depends
autotools-dev, cdbs, debhelper (>= 5.0.0), docbook-to-man, intltool,
libdbus-glib-1-dev (>= 0.60), libgconf2-dev, libglade2-dev, libglib2.0-dev
(>= 2.10), libgnome-keyring-dev, libgnome2-dev, libgnomeui-dev,
libgtk2.0-dev, libiw-dev (>= 27+28pre9), libnm-util-dev (>= 0.6.6),
libnotify-dev (>= 0.3.0), network-manager-dev (>= 0.6.6), pkg-config

而 Frank Lichtenheld 更整理了一個 apt repository 可以直接安裝已經製作好的 build-dep 套件!只要加入以下到 sources.list 即可:


deb http://sourcedeps.debian.net/ sid main contrib non-free

Written by Kanru Chen

October 4th, 2008 at 11:26 pm

Posted in Debian, Linux, 小工具, 爬網探險

Tagged with ,