2009年3月30日星期一

python 参考

pthon 学习参考

中文:
下面两篇都有 pdf 下载,不过还是第一篇结构合理些。
程序员指南.pdf
核心编程 第二版.pdf

英文:
直接看 /usr/share/doc 中的文档吧,没有就自己安装,文档例子很多,很容易读。

2009年3月28日星期六

mplayer中的声道问题

mplayer中的声道问题
左声道
mplayer -af channels=1:1:1 filename.rmvb

右声道
mplayer -af channels=1:1 filename.rmvb

2009年3月27日星期五

启动管理器

gnu grub

stage1(mbr), stage1.5, stage2, menu.lst
manual: http://www.gnu.org/software/grub/manual/html_node/

grub4dos

mbr, grldr, menu.lst
wiki: http://grub4dos.sourceforge.net/wiki/

lilo

mbr, map, boot.b, lilo.conf
manpage: http://swoolley.org/man.cgi/lilo

syslinux

mbr, ldlinux.sys, syslinux.cfg
http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project

isolinux

mbr, isolinux.bin, isolinux.cfg
http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project

2009年3月26日星期四

bash shortcuts

http://blog.neu.edu.cn/sonic3021/archives/46

Bash快捷键
一般組合鍵

* Ctrl-U: 清除一行中游標之前的所有文字。
* Ctrl-H: 移除游標前的一個字元。
* Ctrl-D: 結束輸入。(如果您在 shell 下,就會跳出該 shell)
* Ctrl-C: 終止正在執行的程式。
* Ctrl-Z: 暫時停止程式。 (將該工作放到背景)
* Ctrl-S: 停止輸出到畫面上。(類似 Scroll Lock)
* Ctrl-Q: 回復輸出到畫面上。
* 上/下箭頭: 開始搜尋過去的命令。
* Ctrl-R: 開始漸進收尋過去的命令。
* TAB: 擴展要輸入的檔案到命令列上。
* Ctrl-V TAB: 輸入 TAB,而不是命令列擴展

Emacs 模式下的組合鍵

Bash組合鍵運行預設是emacs模式,但也可以改環境變數EDITOR 成Vi 模式。但是GNU/Linux 下大部分的文字應用程式預設都是emacs模式,建議學emacs模式比較方便。

* Ctrl-A 游標跳至行首,也可用 Home
* Ctrl-E 游標跳至行末,也可用 End
* Meta-B 游標倒退跳一個字
* Meta-F 游標向前跳一個字
* Ctrl-U 從游標倒退刪回至行首
* Ctrl-W 從游標倒退刪最後一個參數, 看起來跟 meta-backspace 一樣
* meta-d Kill from the cursor to the end of the current word, or, if between words, to the end of the next word.
* Ctrl-K 從游標向前刪至行尾
* Ctrl-Y 貼上bash刪除緩衝區裡的內容 或 Insert鍵
* Meta-Y Rotate the kill-ring, and yank the new top
* Ctrl-_ 回手(undo)

巨集

* Ctrl-x ( 開始紀錄巨集
* Ctrl-x ) 結束紀錄巨集
* Ctrl-x e 執行巨集

命令回溯運行

* !xyz回溯運行最後一個以xyz開頭的命令
* !?xyz回溯運行最後一個包含xyz 的命令
* !!回溯運行前一命令
* !號碼n回溯運行第n號命令
* !-號碼n(倒數第n號命令)
* !* 前一命令的所有參數(意即 前一命令去掉第一個字)
* !^ 前一命令的第一個參數
* !$ 前一命令的最後一個參數(這裡字是指以空白分開的 "詞" 而非 字元) 相當於 Meta-. 或 meta-_ 鍵

修改回溯命令內容

* ^被取代字元^取代字元
* :號碼 第幾參數 (第一參數是:0)。例:若前一命令共有三個參數 (共四個字),要去掉最後一個參數可用 !!:-2
* :p 光顯示命令而不執行
* :h Remove a trailing file name component, leaving only the head.
* :t Remove all leading file name components, leaving the tail.
* :r Remove a trailing suffix of the form .xxx, leaving the basename.
* :e Remove all but the trailing suffix.

在 bash 下也可以用 Ctrl-x Ctrl-e 來開啟編輯器來編輯命令。
Gnome-Terminal 鍵盤指定的問題

Gnome Terminal中 Alt鍵 被Menu bar 搶掉了,得用Esc鍵或其他鍵當Meta鍵

一般我們用

* back-space 產生 ASCII DEL
* delete 產生 跳出字元序列

這樣

* delete會取代傳統的 Ctrl-d : 往前刪
* back-space會取代傳統的 delete: 倒退刪

這樣 後退鍵 會倒退刪;刪除鍵 會往前刪。但 ESC-delete 就沒法工作 要用ESC-d

vim 相关

vim 文本宽度

:set tw=80 #textwidth
:set fo+=mM # formatoptions
gq{motion}
gqq
{visual}gq
or
gw

vim 复制与剪切

internal:
y p
:[range]co[py] {address}
:[range]m[ove] {address}
externel:
"+y "+x "+gp

移动

hjkl
wb ege
0^$
()
{}
shift hml
ctrl ud
ctrl fb
gg G
:n
%n

没事可以看看它的 doc.

2009年3月25日星期三

Virtualbox 问题

发现 Virtualbox 不能同时开一个 amd64 或 x86_64 的系统和其它的一个 i386 的其它的系统,这里的 amd64 用的是 Debian,x86_64 用的是 fedora 11, i386 用的是 windows xp 和 slax 6.0.9。但是,能同时开 amd64 和 x86_64 的系统(它们两个都要启用 amd_v 支持),也能同时开两个 i386 的系统。不知道是怎么回事?

源列表

Ubuntu源列表

deb http://mirrors.163.com/ubuntu/ hardy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ hardy-backports main restricted universe multivers

Debian 源列表

deb http://mirrors.163.com/debian lenny main non-free contrib
deb http://mirrors.163.com/debian lenny-proposed-updates main contrib non-free
deb http://mirrors.163.com/debian-security lenny/updates main contrib non-free
deb-src http://mirrors.163.com/debian lenny main non-free contrib
deb-src http://mirrors.163.com/debian lenny-proposed-updates main contrib non-free
deb-src http://mirrors.163.com/debian-security lenny/updates main contrib non-free

Archlinux 源
Server = http://mirrors.163.com/archlinux/$repo/os//i686
Server = http://mirror.lzjtu.edu.cn/archlinux/$repo/os/i686

天津大学 ubuntu

http://202.113.13.45:9527/ubuntu-dist

南开大学 debian(更新很慢)

ftp://202.113.29.4/Debian/debian/
http://202.113.29.3/debian/debian/

x configure

Section "Module"
EndSection

Section "Files"
EndSection

Section "ServerFlags"
EndSection

Section "InputDevice"
Identifier "keyboard1"
Driver "dbd"
EndSection

Section "InputDevice"
Indentifier "mouse1"
Driver "mouse"
EndSection

Section "Monitor"
Identifier "my monitor"
HorizSync 31.5-150.0
VertReflesh 75-85
EndSection

Section "Device"
Identifier "VESA framebuffer"
Driver "vesa"
EndSection

Section "screen"
Identifier "screen1"
Device "VESA framebuffer"
Monitor "my monitor"
DefaultDepth 8
SubSection "Display"
Depth 8
Modes "1024*768" "800*600" "640*480"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "simple layout"
Screen "screen1"
InputDevice "mouse1" "CorePointer"
InputDevice "keyboard1" "CoreKeyboard"
EndSection

2009年3月24日星期二

魔方

APPLET来源:http://www.randelshofer.ch/





没事可以玩玩,呵呵。我已经会玩初级玩法了,还要学学高级玩法。

注:运行上面的小游戏要有 JRE 环境。

2009年3月21日星期六

debian 下打包

debian 下打包

1,环境

build-essential(gcc, g++, libc6-dev,make, dpkg-dev), python, perl, gfortran
autoconf, automake, patch, xutils
dh-make,debhelper, devscripts, pbuilder
file, gnupg,fakeroot

2, 简单打包
mkdir pack
mv ./pack ./package.tar.gz
cd ./pack
tar zxvf ./package.tar.gz
cd ./package
dh_make -e account@domain.com -f ../package.tar.gz
... Answer prompts.
... Fix source tree
... If it is a script package, set debian/control to "Architecture: all"
... Do not erase ../package.orig.tar.gz
debuild or dpkg-buildpackage -rfakeroot -uc -b
... Make sure no warning happens.



注:我用这种办法成功把 pidgin_2.5.5 打成 deb 包。正如前篇文章说的,我已经成功在机器上将源码编译通过了,但是在 dpkg-buildpackage 时总出错,有如下提示:
*** Warning: Linking the shared library perl.la against the
*** static library /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a is not portable!
...
关键是先前编译的依赖我都解决了,怎么现在会不能通过呢,后来,小改了下 debian/rules 文件就可以正常通过了。原来是 dh_make 生成的 rules 文件还是有些小问题。先前让我不理解的 deb 包的依赖问题其实不是问题,build 过程会在 control 中自动添加依赖。
总结经验,打包前要对软件包进行编译试用,再将其打包,整个过程很简单。下面的方法太长,暂没有试。

3, 用dpatch和pbuilder打包
mkdir pack
mv ./pack ./package.tar.gz
cd ./pack
tar zxvf ./package.tar.gz
cp ./package ./package.org
cd ./package
dh_make -e account@domain.com -f ../package.tar.gz
... Answer prompts.
... Fix source tree by editor
... Try building packages with "dpkg-buildpackage -rfakeroot -us -uc"
... Edit source to make source buildable.
... Do not erase ../package.orig.tar.gz
cd ..
cp ./package ./package.bak
mv ./package/debian ./debian
diff -Nru package-orig package > patch-file
... You may overwrite package directory while doing this.
... Make sure to keep package.bak for your safety
mkdir -p debian/patches
dpatch patch-template patch-file \
-p "01_patchname" "patch-file description" \
< patch-file > debian/patches/01_patchname.dpatch
cd debian/patches
echo 01_patchname.dpatch >00list
cd ../..
rm -rf package
gvim debian/rules

现在文件debian/rules的内容是:

config.status: configure
./configure --prefix=/usr --mandir=/usr/share
build: config.status
${MAKE}
clean:
$(testdir)
$(testroot)
${MAKE} distclean
rm -rf debian/imaginary-package debian/files debian/substvars

可以用编辑器修改debian/rules文件为以下内容使其使用dpatch:

config.status: patch configure
./configure --prefix=/usr --mandir=/usr/share
build: config.status
${MAKE}
clean: clean-patched unpatch
clean-patched:
$(testdir)
$(testroot)
${MAKE} distclean
rm -rf debian/imaginary-package debian/files debian/substvars
patch: patch-stamp
patch-stamp:
dpatch apply-all
dpatch call-all -a=pkg-info >patch-stamp

unpatch:
dpatch deapply-all
rm -rf patch-stamp debian/patched

现在可以用dpatch系统重新打包了

tar zxvf package.orig.tar.gz
cp -a debian/ package/debian
cd package
sudo pbuilder update
pdebuild

主要参考:http://wiki.ubuntu.org.cn/Debian-maint-guide/A