2010-12-31

ubuntu 10.10 折腾控制台 | struggling with console in ubuntu 10.10

新买了电脑,装ubuntu 10.10, 安装的时候控制台很完美,漂亮的1366x768,启动时还有漂亮的splash
刚装之后似乎是好的,最近却又不行了,控制台要么进不去,要么是恶心的1024x768。
想了想,自己的改动主要是配了grub2,还有就是装了fglrx。
grub配了几次无果,于是继续回到安装时的live cd,进去以后研究了一下,并没有用vesafb,另外就是发现用的是开源驱动radeon。
用hwinfo --framebuffer看,我的显卡vbe并不支持1366x768,但是live cd确实搞出来了,我猜是radeon和kms的原因,具体不懂了。
于是卸掉了fglrx,重启。
于是又看到了漂亮的splash,漂亮的1366x768控制台。

另外gnome的俄罗斯方块也能正常玩了,用fglrx的时候反而不正常。
期待radeon好好发展。fglrx太差了。。。



I've installed ubuntu 10.10 in my newly bought notebook, the console was perfect during installation, that was the wonderful 1366x768, as well as the beautiful splash.
I think everything was still ok just after installation, until now, I see just a blank screen, or some ugly 1024x768.
What I've done, that maybe relative, are just some tweak on grub2, and installing fglrx.
After failure in adjustment of grub2 for several times, I reboot with the live cd, and I found that vesafb is not used, and radeon is activated as the video driver.
`hwinfo --framebuffer` indicates that the vbe of my graphic card does not support 1366x768, however I did see that with live cd. I guess all of this should thanks to radeon and kms, while I've no idea about details.
So I just removed fglrx and rebooted.
Then come back my lovely splash and 1366x768 console.

By the way, the gnome tetris works quite well with radeon, but not fglrx.
Wish a better radeon driver soon. fglrx is just too bad.

2010-12-30

gnome panel 妙用一则 | A nice trick of gnome panel



链接: http://www.webupd8.org/2010/12/use-gnome-panel-as-wingpanel-quick-tip.html

结果如图,当panel上东西比较少的时候很实用。
操作步骤是在panel属性里取消expand,然后选中autohide,然后拖到右上角,通过gconf修改/apps/panel/toplevels/<panel name>/hide_delay为2147483647




Link: http://www.webupd8.org/2010/12/use-gnome-panel-as-wingpanel-quick-tip.html

Result as the picture above, quite useful when not too much things on the panel.
To make it like this, in the "properties“ dialog of the panel, cancel "expand" and select "autohide". Then drag the panel to the top-right of the screen. At last change the gconf value "/apps/panel/toplevels/<panel name>/hide_delay" to 2147483647

2010-12-17

无flash收听sky.fm | Listen to sky.fm without a flash player

sky.fm是我的最爱,原来ios有个sky.fm app,但是现在连不上了。

sky.fm现在也提供非flash的播放link,但是要进入那个flash页面,然而在ipad的safari上就会蹦到安装flash player的页面,很恶心。

当然如果有别的电脑可以去把link拷过来,但是没有。

于是搜了半天,发现了sky.fm/mobile。很好用,safari会自动调用quicktime,放后台也ok。



Sky.fm is my favorite online radio, there's been a sky.fm app on ios, but has been not working these days.

Non-flash links are also provided by sky.fm, however you'll need to visit the flash player page first, then get the links. While doing this with safari on ipad, you'll be redirect to a page which asks you to install flash player.

Of course, I can get the links from another computer, but there is not such another computer.

So I googled for a while, until I found sky.fm/mobile. Quite useful, since safari would call quicktime to play the list, so I can even listen to it putting it into background.

2010-12-09

利用Firefox订阅私人RSS feed | Subscribing private RSS feeds using Firefox

最近想订阅一个RSS feed,然而由于权限设置,需要登录才能拿到内容,未登录的情况下feed url会报错。

这种情况下Google Reader就不好使了,即便可以,总不能把我的用户名密码给它吧。

Google许久无果,最后想到了用Firefox自己订这个feed,因为Firefox里有我的Coookie。

于是成功了。




Now I'd like to subscribe a private RSS feed, where login is necessary, you won't see anything from the feed url without login.

In such a situation Google Reader won't work, even if possible, I don't want to reveal my username/password to it.

After wasting several minutes in Googling, I came up with an idea, that to subscribe the feed using Firefox, as it's holding my Cookies.

Then of course I succeeded.

Firefox 强制显示书签工具栏内容 | Force displaying bookmark item in Firefox toolbars

最近用Firefox订了一个feed,想把它显示出来,然而又不想为此浪费一行显示书签工具栏,于是把bookmark toolbar item拖到了地址栏尾部。

然而这个item是会自动收缩的,于是浪费了一段空白,而且我的feed需要展开才能看。

解决方法,利用stylish

#bookmarksBarContent .bookmark-item {
visibility: visible !important;
}

即可。




Recently I've subscribed a live feed using Firefox, I want it being displayed in my browser all the time, but I don't like the bookmark toolbar which wastes the entire line space. Therefore I drag the bookmark toolbar item to the end of the location bar.

However, that item will automatically collapse, resulting in that there's just a blank area, with an expand button, I have to view the item after expand the item, so stupid.

The solution is, by stylish:

#bookmarksBarContent .bookmark-item {
visibility: visible !important;
}

works like a charm.

2010-09-28

调整gnome音量调节的幅度 | Adjust the value of volume step in gnome

我的笔记本的音量调节是滚轮式的,拨一下会产生很多按键事件,因此音量增大或者减小很多,非常不爽。今天网上搜了一下,只需要改一个gconf键值:

/apps/gnome_settings_daemon/volume_step

原来是6,改成2比较适合我。



There's a volume wheel on my notebook, one touch would make a number of keypress event, therefore the volume will be enlarged or reduced too much, which is very annoying. After spending some time on searching, I found the corresponding gconf key:

/apps/gnome_settings_daemon/volume_step

The default value was 6, changing it to 2 is good for me.

2010-09-18

让 pstree 的 圆圈节点 Tcircle 保持一样大小 | Make all Tcircle nodes in pstree a fixed size

最近要用latex画树,决定学习pstricks,pstree还是蛮好用的,但是用Tcircle画节点时发现一个问题,每个圆圈的大小是与内容有关的,比如字母a和f的圆圈就不一样大,很难看。

在pstrick的文档里看了半天也没弄出个所以然,然后又搜了半天,才发现可以用makebox,原来这么简单,但是我对latex还是不熟练。

解法为:

\Tcircle{\makebox[\somefixedsize][c]{content}}



I need to draw some trees in latex, so I learned some pstricks, I found pstree is rather easy to use, but there's somethings with the Tcircle, the size of the circles is related to its content, for example for circles for 'a' and 'f' are not of the same size, which makes the tree very ugly.

I didn't found anything useful in the pstrick's document, after rather some time searching on the web, I realized that I can take advantage of makebox, that's a easy but great idea, however I was still not familiar enough with latex...

The solution is:

\Tcircle{\makebox[\somefixedsize][c]{content}}

2010-08-30

不能启用触摸板的临时办法 | A workaround of enabling touchpad

症状是 touchpad 可以识别,按笔记本上的启用/禁止触摸板键,屏幕上也有正确提示,但是触摸板就是不能工作。
一个可能的原因就是在windows里面禁用了,重启进ubuntu以后就出这个问题。
另外发现在禁用的情况下,按住笔记本上那个键(我这里是Fn+F7)就可以用,松开就不行。

在网上搜到的gconf的键值,观察了一下,只有按住的时候是enabled,否则是disabled了。

临时解决方案是:

gconftool-2 -t bool -s /desktop/gnome/peripherals/touchpad/touchpad_enabled "True"

运行以后笔记本上的启用/禁止键也能正常工作了。

这个估计是Xorg或者GNOME的bug。




The symptom is that although my touchpad is recognized, and when I press the enable/disable key on my keyboard, there's right notification on the screen, but my touchpad just is not working.

One possible reason is that I've disabled it in Windows, then I restarted my machine and entered Ubuntu.

Another thing I found is that only when holding the enable/disable key can I use the touchpad.

I found the corresponding key in gconf, and indeed I observed that the key is enabled only when the enable/disable key is being held.

A workaround is to run the following command.

gconftool-2 -t bool -s /desktop/gnome/peripherals/touchpad/touchpad_enabled "True"

After that the enable/disable key works well.

This must be a bug in Xorg or GNOME.

2010-07-24

Windows Server 2008 R2中配置游戏手柄 | Configuring gamepads in Windows Server 2008 R2

Windows Server 2008 R2 中似乎并没有游戏控制器的相关配置,以至我新买的手柄一直不能正确配置。


http://www.win2008r2workstation.com/win2008r2/game-controllers
中提供了一个游戏控制器的控制面板文件,包含了32位和64位的版本。按提示安装后就可以在控制面板里找到了,与之前Windows游戏控制器的配置无异。




Seems that the configuration dialog of gamepads is missing in Windows Server 2008 R2, which made my new gamepad not working all the time.

Several necessary files for gamepad configurations are provided in
http://www.win2008r2workstation.com/win2008r2/game-controllers
including 32bit and 64bit versions.

Just follow the instructions to install it, and then it can be found in the Control Panel, which is exactly the same as the gamepad configuration in previous versions of Windows.

在Google Reader中显示标记Like的条目 | Display liked items in Google Reader

转自:http://lifehacker.com/5317004/display-just-the-items-you-liked-in-google-reader

访问如下链接即可:
http://www.google.com/reader/view/user/-/state/com.google/like




From: http://lifehacker.com/5317004/display-just-the-items-you-liked-in-google-reader

Just visit the following URL:
http://www.google.com/reader/view/user/-/state/com.google/like

2010-06-01

指定excel输出csv文件的分隔符 | Specify the separator in csv file outputted by Excel

Excel 导入csv文件时候可以指定分隔符,但是输出是没有明显的选项,只是txt用空格,csv用逗号。

查了一下,这个需要去控制面板,区域语言选项,“格式”标签选高级,在数字里面就可以调整分隔符了。

这个还真是不直观,太隐蔽了。。。




In Excel the separator can be specified when import a csv file using the wizard, but there's no such an option when exporting, the only choices are txt and csv, where the space and comma are used as separator respectively.

And I found on the Internet that, to change the symbol, go to the control panel, then "regional and language options". In the advanced options under the "format" tab, there's a "number" tab, where you can change the "list separator".

This option is hidden so well...

2010-05-16

ptrace 在 linux 和 freebsd 下的若干区别 | Several differences of ptrace between Linux and FreeBSD

最近要把一个程序移植到Debian-kfreebsd上,并不如想象中的顺利。
主要是ptrace在两个平台上不太一样。

首先是宏定义,linux底下都叫PTRACE_*,freebsd上都是PT_*。这个也许不算什么

然后是ptrace函数的参数,主要是value这个,linux下面是long很好用,但是freebsd下是int,这样64位的时候就有些问题。

但是freebsd的ptrace有个更好用的操作PT_IO,可以自定义读写长度,而linux底下没有,要自己搞。

最后一个,花了我很长时间才解决的,是CONTINUE这个操作,linux下面addr这个参数是被忽略的,直接从中断的地方继续;但是freebsd下面则可以利用这个参数指定从哪里继续,如果希望从中断的地方继续,则指定为1即可。

目前只遇到这些,从这些方面来看,还是freebsd的接口更好用一些。



Recently I've been porting a software from Linux to Debian-kfreebsd, but it's not as easy as I had expected. The problem is the interface of ptrace is not exactly the same between linux and kfreebsd.

The first is the names of the macros, which are PTRACE_* under linux and PT_* under freebsd.

Secondly the function `ptrace' is not the same, the parameter `value' is `long' under Linux, but `int' under freebsd, so it seems that there'll be a problem on 64 bit freebsd.

However, there's another operation called PT_IO under freebsd, using which we can specify the number of bytes we want to read or write.

The last and the most annoying one I've met, is the parameter `addr' for the CONTINUE operations. Under linux this parameter is ignored, and the child process will continue at where it had been interrupted; but under freebsd, we can specify this location by setting this parameter, and we can also let it continue at where it had been interrupted but setting the value to 1.

Now that's all for my program, and it seems that the interface under freebsd is better than that under linux.

2010-05-03

并行运行多进程的Bash脚本 | A srcipt for running processes in parallel in Bash

原文:http://pebblesinthesand.wordpress.com/2008/05/22/a-srcipt-for-running-processes-in-parallel-in-bash/

技巧是控制了最大并发数目,当前并发数过大时,等待有进程退出才开始下一个。

我现在正在写的脚本里正需要这个,借鉴过来


#!/bin/bash
NUM=0
QUEUE=""
MAX_NPROC=2 # default
REPLACE_CMD=0 # no replacement by default
USAGE="A simple wrapper for running processes in parallel.
Usage: `basename $0` [-h] [-r] [-j nb_jobs] command arg_list
-h Shows this help
-r Replace asterix * in the command string with argument
-j nb_jobs Set number of simultanious jobs [2]
Examples:
`basename $0` somecommand arg1 arg2 arg3
`basename $0` -j 3 \"somecommand -r -p\" arg1 arg2 arg3
`basename $0` -j 6 -r \"convert -scale 50% * small/small_*\" *.jpg"

function queue {
QUEUE="$QUEUE $1"

NUM=$(($NUM+1))
}

function regeneratequeue {
OLDREQUEUE=$QUEUE
QUEUE=""
NUM=0
for PID in $OLDREQUEUE
do
if [ -d /proc/$PID ] ; then
QUEUE="$QUEUE $PID"
NUM=$(($NUM+1))
fi
done
}

function checkqueue {
OLDCHQUEUE=$QUEUE
for PID in $OLDCHQUEUE
do
if [ ! -d /proc/$PID ] ; then
regeneratequeue # at least one PID has finished
break
fi
done
}

# parse command line
if [ $# -eq 0 ]; then # must be at least one arg
echo "$USAGE" >&2
exit 1
fi

while getopts j:rh OPT; do # "j:" waits for an argument "h" doesnt
case $OPT in
h) echo "$USAGE"

exit 0 ;;
j) MAX_NPROC=$OPTARG ;;
r) REPLACE_CMD=1 ;;
\?) # getopts issues an error message
echo "$USAGE" >&2
exit 1 ;;
esac
done

# Main program
echo Using $MAX_NPROC parallel threads
shift `expr $OPTIND - 1` # shift input args, ignore processed args
COMMAND=$1
shift

for INS in $* # for the rest of the arguments
do
# DEFINE COMMAND
if [ $REPLACE_CMD -eq 1 ]; then
CMD=${COMMAND//"*"/$INS}
else
CMD="$COMMAND $INS" #append args
fi
echo "Running $CMD"

$CMD &
# DEFINE COMMAND END

PID=$!
queue $PID

while [ $NUM -ge $MAX_NPROC ]; do
checkqueue
sleep 0.4
done
done
wait # wait for all processes to finish before exit






Original posted at: http://pebblesinthesand.wordpress.com/2008/05/22/a-srcipt-for-running-processes-in-parallel-in-bash/

This script will run multiple process in background concurrently, while the maximum number of running processed is under control. When there are already too many running processes, a new one will wait until one process finished.

I just need this trick in my project, so I copied it here.

(See codes above)

2010-04-19

GameConqueror进入Debian Sid | GameConqueror is included in Debian Sid

如题,非常高兴。
继续盘算下一个版本需要实现的东西。
链接: http://code.google.com/p/scanmem/


As titled I'm quite happy with this.
Still considering possible features in next version.
Link: http://code.google.com/p/scanmem/

2010-04-11

Empathy 不能连 MSN 的问题 | Empathy cannot get MSN accounts online

症状是总报 Network Error, 重连也不行

根据http://aslakjohansen.wordpress.com/2009/07/27/empathy-gives-network-error/ 把telepathy-butterfly杀掉就可以了。


So it always report "Network error", reconnecting has no luck.

According to http://aslakjohansen.wordpress.com/2009/07/27/empathy-gives-network-error/ , just simply kill the "telepathy-butterfly" process, then it'll be fine.

Google Reader 总显示 "kept unread" 列表的问题 | Solution to the annoying "kept unread" list in Google Reader

不知道从什么时候开始我的Google Reader首页上总会显示一个kept unread列表,但是进去以后却是显示已读,此时点mark all as read或者挨个浏览这些item都没有任何效果。

今天在http://groups.google.com/group/google-reader-howdoi/browse_thread/thread/a68ae3f9a7761e26/11eb862ab44a67c3 找到了解法:

给每个kept unread的条目加星
去加星条目列表,挨个浏览每个条目(不要点mark all as read)
去掉这些条目的星

然后就正常了。 这个应该是Google Reader的bug吧。。。

There's been a "kept unread" list in my Google Reader home page for some time, and I didn't know why. In the list, each item seems be already ready, and clicking "mark all as read" or navigating each of them have no effect.

Today I found the solution on http://groups.google.com/group/google-reader-howdoi/browse_thread/thread/a68ae3f9a7761e26/11eb862ab44a67c3

Add start for each of them
In "starred items", navigate each of them (don't click "mark all as read")
Remove these temporary stars

Then that list would be gone. This must be a bug of Google Reader...

2010-04-10

gnome桌面便笺 | best sticky note application

最近需要搞个桌面上的todo list, 以前是用screenlets,现在不用了,而且为一个插件就开这个庞然大物太浪费了。

我在用gnote,但是这个不适合放在桌面上。gnome-panel的一个小插件也是sticky note,但是不能锁定在桌面上,一点就消失了。

另外搜到的xpad,但是我这里有bug,一个灰色的窗口,什么都么有。网上搜到了解决的patch,但是不想折腾了。

最后看到某人论坛留言: 在桌面建一个文本文件,然后把图标放大。。。顿时豁然开朗,一开始遇到这个特性时还觉得有些烦人,但是现在需要时反而想不起来了。。。

效果不错,缺点是不能弄太多文字。


Recently I found that I need a sticky note on my desktop. I used screenlets before, but not anymore now. It's a waste to enable it only for such a gadget.

Now I'm using gnote, which is rather a nice software, but it's not suitable for 'sticky' notes. There's also a stickynote applet for gnome-panel, but I don't know how to attach the notes to desktop -- every time I click somewhere, the notes disappear.

I googled some software called 'xpad', but on my computer it's nothing but a gray empty window -- an annoying bug, although I've googled a patch for this, I've got no feeling for it.

Finally I got someone's comment on some bbs -- "create a paint text file on the desktop, and then stretch the icon large enough..." -- that's it! It was quite an annoying feature to me at the first time, but now I cannot even remember it when I do need it now...

This trick works well, except for that there cannot be too many words.

2010-04-05

Webkit 下中文字体问题的解决 | Solution to the problem of unexpected Chinese fonts in webkit

也许是仅局限于webkitgtk

之前尝试epiphany的时候就发现了这个问题,但是由于epiphany对我来说只是一个备用浏览器,所以没管它。 今天给empathy搞adium主题时这个问题再次蹦了出来,我决定干掉它。

https://bugs.launchpad.net/ubuntu/+source/webkit/+bug/502610 这里有些讨论,里面有个链接指向了改fontconfig的办法,但是我想我这里并不是这个问题,因为我在~/.fonts.conf里已经之定好了我希望的中文字体(主要是serif, sans-serif, monosapce这几个列表),我还是觉得这个是webkit的问题。

empathy有个选项可以开启webkit debug模式:/apps/empathy/conversation/enable_webkit_developer_tools 我用它查看元素,发现字体总是sans...目前解决方法是手工改css,找到.msg的定义,加入 font-family: "font name 1", "font name 2";

另外就是epiphany,虽然它不能给各个语言指定字体,但是好歹支持用户css,于是加入如下内容:

@charset "UTF-8"; // 如果字体名有中文
* {
font-family: "font name 1", "font name 2" ! important;
}

这样问题基本可以解决




Or maybe it's only a bug for webkitgtk, I'm not sure.

Days before I encountered this bug when I was trying epiphany, but I didn't pay much attention on it since I use it only as a backup one. However today the bug came out and started to trouble me again when I was applying an adium theme for empathy, and then I decided to get rid of it.

There are quite some discussions in https://bugs.launchpad.net/ubuntu/+source/webkit/+bug/502610 , and someone there provided a solution that to modify config files of fontconfig. But I think it's not the case at least for me, since I've specified my preferred fonts of the generic font families (serif, sans-serif, monospace). I think it should be webkit's fault.

Enabling "/apps/empathy/conversation/enable_webkit_developer_tools" will enable the debug mode of empathy, where I can inspect the HTML elements (that's cool!), I found the font of messages are all "Sans", and I got no solution except for manually modifying the css file of the theme, just add the following lines in the ".msg" block

font-family: "font name 1", "font name 2";

About epiphany, I wonder why I cannot specify font for different languages/charsets just like firefox, but at least it supports user specified css, so I created one with the following content:

@charset "UTF-8"; // since the name of the font I'm using contains Chinese characters
* {
font-family: "font name 1", "font name 2" ! important;
}

and it works like a charm :)

2010-04-03

ubuntu flash 中文乱码的解决

症状是所有中文都显示为方块

网上搜了很多方法,看上去都很暴力。另外在https://bugs.launchpad.net/ubuntu/+source/fontconfig/+bug/207198有很多讨论。

所有的方法都集中在/etc/fonts/conf.d/49-sansserif.conf这个文件上,不是修改就是删除。

(以下为个人猜测)

这个文件的用途是给没有通用字体名的字体加上sans-serif这个名字,比如说我想在标题栏上使用Comic Sans, 但是如果出现了中文怎么办?一般对中文的支持都是在serif, sans-serif,monospace这三个列表里加上中文字体,但是如果我指定的是Comic Sans,系统如何知道去哪里找中文字体呢。

所以这个文件就有用了,它给没有制定通用字体名(sans,sans-serif,monospace之一)的字体强行加上一个sans-serif,这样看上去就比较合理了。

而flash是怎么回事我就不知道了,因为不是所有的flash上显示中文都是乱码,youtube上的是乱码。

我在~/.fonts.conf里给sans-serif列表前端加了两个字体,一个英文一个中文,中文在后,这样可以让两种语言都能正确显示(因为中文字体对应的字符集包含英文的)。但是结果是flash就认第一个,不能匹配到第二个。我猜是flash请求时的问题,当然也可能是fontconfig的问题。如果我去掉了第一个字体,flash倒是正常了,但是所有字符都用那个中文字体显示了,不爽,所以这个文件不能动。

至于sansserif.conf这个文件,直接删除自然是不大合理,不知道会匹配到哪里去。目前的临时解决办法是把最后那个sans-serif改成我指定的那个中文字体,想了一下从逻辑上讲的通。

但是这个毕竟不是办法,让一般用户改这个还是不合理。如果是flash的问题自然好办,如果不是的话,我觉得可以给50-user.conf更高一点的级别,让用户自由度更大。

2010-04-02

compiz 鼠标指针问题

症状是gnome里改了指针主题以后,(在打开compiz的情况下)标题栏,gnome-panel上的鼠标指针还是以前的(不知道是哪里来的),总是是不会跟着改变。

https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/459647上某人提到了修改/usr/share/icons/default/index.theme,我看了一下,是一个link,而且是带有alternative的。

于是用update-alternatives更改了一下,重启X,一切OK。

另外怀疑创建~/.icons/default/index.theme也可以解决问题,没有验证。

利用共享内存加速firefox

被同学怂恿了半天,禁不住诱惑,改了一下,确实变快了

方法是 about:config 修改 browser.cache.disk.parent_directory 为 /dev/shm/firefox
然后重启firefox

Debian系 ipv6 6to4 tunnel 脚本

有个在线生成脚本的网站,很不错 http://debian6to4.gielen.name/

不过也许改成自动根据ipv4地址进行配置会更好

[转]ubuntu 下由于没有公钥,下列签名无法进行验证: 解决方法

Link: http://www.noteip.com/?p=983

W: GPG签名验证错误: http://linux.dropbox.com karmic Release: 由于没有公钥,下列签名无法进行验证: NO_PUBKEY FC918B335044912E

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5044912E

若缺少其他公钥,则将命令中两处5044912E改为NO_PUBKEY FC918B335044912E中最后8位即可!

grub2 配置命令备忘

之前装Windows把grub搞挂了,用ubuntu 9.10的盘不能恢复,才发现grub2时代已经来了

又搞了个ubuntu 9.04的盘恢复以后,索性就升级到了grub2。当时有很多问题,尤其是分辨率那个。现在装了10.04,似乎没什么问题了,常用配置命令整理如下

旧版升级:
sudo upgrade-from-grub-legacy

去掉memtest:
sudo chmod -x /etc/grub.d/20_memtest86+

修改背景图片/颜色:
sudo vim /etc/grub.d/05_debian_theme 注意背景black表示透明,否则会挡住背景图片

修改控制台分辨率:
sudo vi /etc/grub.d/00_header 在 set gfxmode=${GRUB_GFXMODE} 后加入 set gfxpayload=keep
注意同时要修改/etc/default/grub里面的 GRUB_GFXMODE

其他参数:
修改 /etc/default/grub, 里面的注释写的很清楚的

更新grub菜单,重新搜索内核等等
sudo update-grub
这个很不错,一个是能自动搜索windows loader,另一个就是再也不用为“是(hd0,4)还是(hd0,5)”之类的问题发愁了

windows server 2008 r2 当桌面系统使用的配置

我原来的windows 7 rc到期了,所以搞了个免费的学生号装windows server 2008r2,效果不比windows 7差,就是需要折腾一些服务设置啥的。

最近在http://weblogs.asp.net/israelio/archive/2008/02/21/windows-server-2008-as-workstation.aspx恰好又看到了,因此转过来备忘:

  1. Disable shutdown event tracker
    Start->Run->"gpedit.msc" -> Administrative tools->System-> Display Shutdown event tracked -> Disable
  2. Disable IE Security
    Start->Server Manager->Configure IE Sec->Off both options.
  3. Enable Wireless Support
    Start->Server Manager->Features->Add Feature->Wireless LAN Services
  4. Enable Audio support
    Start->Run->"Service.msc"->Windows Audio -> Automatic
    Start->Run->Services.msc"->Windows Audio Endpoint Builder->Automatic
  5. Install hardware drivers
    I am using ThinkPad t60p so my driver list is here
    Note that mobility center is missing from windows 2008 server so there is no need to install it.
    IBM Network access connection will crash on you if you will not enable the wireless support (Look above)
  6. Enable Vista Experience (look & feel including Aero, Media Player etc.)
    Start->Server Manager->Features->Add Feature->Desktop Experience

    More info including how to enable sleep support on windows 2008 server you may find over this kb: http://support.microsoft.com/kb/947036)
  7. Enable Themes
    Start->Run->"Service.msc"->Themes->Automatic
  8. Enable .NET 3.0
    Start->Server Manager->Features->Add Feature->.NET Framework 3.0 Features
  9. Enable Windows Search (for searching outlook emails)
    Start->Server Manager->Roles->Add Roles->File Services->Windows Search
  10. Enable SuperFetch
    Start->Run->"regedit"

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters

    Add a new DWORD by the name of EnablePrefetcher and assign is the value of 3
    Add a new DWORD by the name of EnableSuperfetch and assign is the value of 3

    Start->Run->"services.msc"->SuperFetch->Automatic
  11. Install Messenger
    Latest Live Messenger will not install on Windows 2008 Server, you should install a former version (8.1 and not 8.5) and then you may copy the Live Messenger folder from a working machine and work with it.
    http://www.microsoft.com/downloads/details.aspx?FamilyID=d78f2ff1-79ea-4066-8ba0-ddbed94864fc&DisplayLang=en
  12. Install Skype
    Latest Skype version will crash 2 seconds after login, you need to install a former skype version Skype 3.1.0.152 works great.
    http://filehippo.com/download_skype/2473/
  13. Install Office 2007
  14. Install Visual Studio 2008
  15. Setting Processor Scheduling
    Start->Control Panel ->System ->Advanced system settings-> Advanced -> Performance -> Settings->Advanced->Adjust best performance->Programs
    update:
  16. Changing DEP Mode
    Start->Control Panel ->System ->Advanced system settings-> Advanced -> Performance -> Settings-> Data Execution Prevention-> Turn On DEP for essential Windows programs and services.
    update2:
  17. Fixing ASP.NET Development Server
    After installing visual studio you might want to start working with Casini, the asp.net dev server but it seems that the ie cant find it.
    Edit the hosts file located at: C:/windows/system32/drivers/etc

    comment the following line :
    ::1 localhost
    by replacing it with:
    #::1

    (the "::1" is use for the localhost for ipv6)

有一些其实我这里不需要,但是也转过来了。

2010-03-13

软件推荐: checkgmail & ibus-sunpinyin

一句话:

checkgmail: 靠feed读取未读邮件,可以在不打开gmail的情况下标记为已读,十分方便。

ibus-sunpinyin: 靠统计模型的拼音输入法,响应速度非常快。

2010-02-23

linux 光盘镜像挂载工具

虽说linux下挂载iso一个mount就搞定,可是对于平时常见的镜像cue/bin, mdf/mds就没啥好办法了。

今天偶然发现furius iso mount这个软件,还不错,虽然路径中有中文字符就不识别,但总算是有一个能用的工具了。

值得期待。

2010-01-12

pygtk 异步显示对话框

需求是这样,我有一个主窗口,有自己的事情做,同时需要监视一个文件,如果有了变动就蹦个对话框出来,一开始的想法是

def handler():
dialog = gtk.MessageDialog(...)
dialog.run()
dialog.destroy()

gobject.threads_init()
gtk.gdk.threads_init()

gtk.io_add_watch(source, gobject.IO_IN, handler)
xxx_window.show()
gtk.main()

结果是对话框能显示出来,但是点击ok之后就卡死了,ok按钮也保持在“按下”的状态

后来看到了http://old.nabble.com/Deadlock-problem-when-calling-messagebox-function-with-idle_add-td25027865.html

于是在handler首尾分别加上gtk.gdk.threads_enter() 和 gtk.gdk.threads_leave() 就可以了

2010-01-10

内存错误调试工具 valgrind

偶然从某论坛看到的

valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./a.out

目前只会这么一种用法,但是一下子就找到了病根,太棒了!

以后再研究研究。

GameConqueror 0.09 -- Linux 游戏作弊工具

你是否喜欢游戏修改?
你是否一直在寻找`CheatEngine for Linux`?
那么你不该错过:


Gameconqueror 是一款Linux游戏修改工具,用PyGTK写成,以scanmem作为后端。

我的目标是实现CheatEngine的大多数功能,成为名副其实的`CheatEngine for Linux`

现在已经实现了基本的搜索功能,支持不同的数据类型和搜索类型,如下:

数据类型:不同长度的类型:int{8/16/32/64}, float{32/64},未知长度的类型:int, float, 未知类型:number, 字节串和字符串:bytearray, string
搜索类型:相等,大于,小于,变化,未变,增大,减少

=============================================

下载:

PPA
https://launchpad.net/~coolwanglu/+archive/scanmem
我只在64bit Karmic下进行了测试,其他环境如果不能正常使用请告知,谢谢

SVN
svn checkout http://scanmem.googlecode.com/svn/trunk/ scanmem

主页:
http://code.google.com/p/scanmem/
下载时注意选择0.09版本

运行需要python和python-gtk2, 编译需要libreadline(大多数发行版应该都默认安装吧)

=============================================

GameConqueror的BUG或者不恰当的使用会导致程序崩溃,请务必注意备份数据,资料等等。

安装后应该在“游戏”类别里出现菜单项,也可以直接运行gameconqueror(请在终端内运行,见下)

查看Value的悬停提示(tooltip)可以了解各种搜索语法,参考了金山游侠

至于那个烦人的终端窗口,现在只能在这里看到搜索进度和出错信息。我之前主要是实现scanmem的各种功能,界面改进则是下个版本的目标

=============================================

未来考虑实现的功能:

- 界面改进(搜索进度条,出错提示,用户交互等等)
- 指针搜索
- 可选的浮点数取整方式
- 十六进制内存查看/编辑器

不会实现的功能:

- 变速 (类似变速齿轮,这个不是不想写,而是不会写,有谁能教教我?)
- 反汇编器

欢迎使用,感谢反馈。

GameConqueror 0.09 -- Linux Game Hacking Tool

If you are a game hacker
If you've been looking for a `CheatEngine for Linux`

Then you can't miss this.

==============================================


GameConqueror is a game hacking tool for linux, it's written in PyGTK and uses scanmem as its backend.

It's supposed to be with most useful features of CheatEngine for Linux.

Currently, I've implemented almost everything about scanning, involving variant data types and scan types:

Data Types: int{8/16/32/64}, float{32/64}, unknown type(int or float) and unknown width(will try each of them), byte array and string
Scan Types: equal, greater, less, changed, unchanged, increased(by), decreased(by)

This should be enough for most cases, so I decided to release it at the current status.

=============================================

Here's how you can get it

PPA (for Ubuntu users)
https://launchpad.net/~coolwanglu/+archive/scanmem
(I've not test it in 32bit environments or Jaunty, do please inform me if it doesn't work)

SVN
svn checkout http://scanmem.googlecode.com/svn/trunk/ scanmem

Homepage:
http://code.google.com/p/scanmem/
make sure you selected the correct version `0.09`

You'll need python and python-gtk to run it, and to build it from source code, you'll need libreadline (this should have been installed for most of you)

=============================================

NOTE THAT GAMECONQUEROR MAY CRASH YOUR PROGRAM DUE TO BUGS OR IMPROPERLY USAGE, DO BACKUP YOUR PROGRESS BEFOREHAND.

To use it, actually I've created a menu item, which could be found in the 'Games' category, or you can run it by executing `gameconqueror`, and please do this in a terminal (see below)

Read the tooltip of the label 'Value' to get familiar with the syntax

About the annoying terminal window, now this is the only place where you can see the progress of scanning, and the error message if something goes wrong. This terrible thing is basically because I've mainly focused on the features of scanmem so far, and I'll fix this in the next version.

=============================================

What will be added in the next (or maybe future) version:

- better ui (progress bar, error message, user interaction, etc...)
- search for pointers
- optional float rounding method
- memory viewer/editor


and what will not be added
- speed hack (I've no idea about how to implement this in Linux, can anyone tell me plz?)
- disassembler
- many other `too powerful` features in CheatEngine


any feedbacks will be appreciated.


2010-01-05

autotools, deb 和 PPA 不完全攻略

最近在给自己的GameConqueror折腾 PPA, 那少不了折腾标题里的三样东西。下决心看了一遍三个东西的文档,整理如下

链接
autotools:
AutoconfAutomake

deb packaging:
Debian New Maintainers' Guide
Ubuntu Packaging Guide
Building Package for PPA

PPA stuff
PPA Overview
Uploading


那么一个一个说:
注意: 本篇系个人总结而非教程,如有疑问请参阅上述链接。


1. AUTOTOOLS
autotools 的精髓是让开发者免于手写繁琐的Makefile,同时又让最后生成的源码包符合GNU的一套标准。然而autotools本身也很难用。。。入门门槛比较高。当然难用是相对的,掌握了基本要领就可以了

需要手写的文件一般是一个configure.ac和若干个Makefile.am, ac和am分别是autoconf和automake的缩写

configure.ac定义了源码包整体信息,如名称,版本,编译环境等,最后根据configure.ac输出configure,而configure可以判断编译环境是否满足需要,这就是著名的./configure && make 的前一半

Makefile.am则是Makefile的另一种格式,由于绝大多数C/C++或一些其他语言的程序编译,打包,安装等等都是同一模式,所以才有了automake,Makefile.am的作用是决定程序的编译方式,还有各个文件的类型,是否打包,安装位置等等,这些由automake生成许多Makefile.in一起打包,等到编译时./configure会把Makefile.in再变成Makefile

关于configure.ac, 最开始可以用autoscan生成一个模板,自己慢慢改,有许多宏,都可以在autoconf的网页上查到

一般(我看到的)分为两个部分,前一半检查编译环境,后一半把检查的结果输出,一般就是进行宏替换等等。

检查编译环境,一般无非是编译器(是否存在,编译选项,特性支持),库(是否存在,版本),条件编译(是否启用的某个功能,或其他编译时指定的参数),这一部分去查AC_CHECK*,AM_CONDITIONAL这些宏好了,很好用

第二部分是宏替换,相关的宏是AC_CONFIG_FILES和AC_OUTPUT。Makefile.in是自动生成的,也会自动被替换,不用管它。我遇到的情况是需要写一个脚本,里面有个路径是安装路径,这样的话,我需要写一个script.in:

DATAPATH=@INSTALLPATH@

# do anything with $DATAPATH

然后在configure.ac里加上AC_CONFIG_FILES([script])

以及AS_AC_EXPAND(INSTALLPATH, "some path")

这样到时候configure的时候就会生成一个script,里面是DATAPATH=some path

其中AS_AC_EXPAND不是autotools里的宏,我是从ubuntu-tweak包里抄来的,再往上就找不到确切出处了

把这段放configure.ac里就好了
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
dnl
dnl example
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local

AC_DEFUN([AS_AC_EXPAND],
[
EXP_VAR=[$1]
FROM_VAR=[$2]

dnl first expand prefix and exec_prefix if necessary
prefix_save=$prefix
exec_prefix_save=$exec_prefix

dnl if no prefix given, then use /usr/local, the default prefix
if test "x$prefix" = "xNONE"; then
prefix=$ac_default_prefix
fi
dnl if no exec_prefix given, then use prefix
if test "x$exec_prefix" = "xNONE"; then
exec_prefix=$prefix
fi

full_var="$FROM_VAR"
dnl loop until it doesn't change anymore
while true; do
new_full_var="`eval echo $full_var`"
if test "x$new_full_var" = "x$full_var"; then break; fi
full_var=$new_full_var
done

dnl clean up
full_var=$new_full_var
AC_SUBST([$1], "$full_var")

dnl restore prefix and exec_prefix
prefix=$prefix_save
exec_prefix=$exec_prefix_save
])

另外需要看看AC_SUBST这个宏以及一些标准路径定义,如datadir等等

那么configure.ac基本就这么回事了,下面是Makefile.am

网上的很多教程上来就说“对于一个简单的hello程序,我们可以写如此一个Makefile.am”,但是再往下就没有了。但是像我每次看到Makefile.am里面的bin_PROGRAMS, xxx_SOURCES等等,我会想bin是啥玩意, PROGRAMS又是啥 -- 基本没查到,只能看文档。

实际是这样的
bin_PROGRAMS: bin是安装路径,即${prefix}/bin, 而prefix就是configure时指定的那个--prefix
_PROGRAMS: 是autotools里预设的宏,好比说,我想到了LaTeX里的\documentclass,基本就是一回事,其他还有_SCRIPTS, _DATA, _LIBRARIES,具体去查文档

如果定义了bin_PROGRAMS = scanmem # scanmem就是我正在搞的那个包
那么下面就会有scanmem_SOURCES = xxx.c yyy.c 这种,scanmem_XXX就是指定scanmem的具体内容了,除了_SOURCES还有_CFLAGS等等

类似的例子是dist_doc_DATA = AAA BBB, 这样 AAA BBB 会被安装到 docdir 里去,这也是个标准定义,一般是${prefix}/share/doc/$PACKAGE。 dist_则是前缀,为了将来把AAA BBB一起打包, make dist 默认是不把_DATA的内容放到包里

另外你可以可以自己写scanmem_PROGRAMS这种,但是要注意定义scanmemdir,就是对应的安装目录

还有一些:
EXTRA_DIST: 这种是强制把某些内容放到源码包里
SUBDIRS: 表示make的时候需要光顾的目录,如果 SUBDIRS = aaa . bbb, 那么就分别到aaa, 当前目录和bbb去make一番

常用的就这些把,记得把每个目录的Makefile.am都加到configure.ac里去,如
AC_CONFIG_FILES([Makefile
src/Makefile
xxx/Makefile
])

所有东西都搞完以后打个autoreconf (如果缺文件可能需要加--install)就齐活了,这时候已经可以./configure && make 了,如果想打包就make dist,这时候才终于发现了autotools的好用。。。

关于autotools的感想就这么多,总之还是看文档最有效,说的已经很清楚了。

2. DEB 打包
首先需要装一堆脚本,我也忘了有哪些了
主要需要的是debian这个目录,里面必要的文件是control copyright changelog rules这几个文件,如果没有的话可以用dh_make -e 这个命令生成一些基本的,但是我还是建议对照着一个现有的deb包看

control最简单了,照猫画虎就好了,第一大段是源码包信息,下面若干段是deb包信息,这个源码包最后打出几个deb包来就写几段

changelog需要一定格式,用dch命令,非常好用

dch:在最新的changelog entry加一段文字
dch -i: 新建一个changeleog entry,版本修订号加1
dch -v :新建一个changelog entry, 指定版本号为version

另外,最后的deb包的版本是由changelog最新一项决定的

rules:这个是打包用的Makefile,对于简单的包,可以用cdbs,虽然一听新名词显得很麻烦,但是实际上只需要如下几行

#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

DEB_CONFIGURE_EXTRA_FLAGS := --enable-gui

就行了,最下面是自定义的configure参数,还有一些其他的类似的变量

另外务必在control的Build-Depends里加上cdbs

copyright:最“没用”也是最难搞的,说明这个包是谁整的,原来作者是谁,原来的文件分别的版权和协议(由于我的包是多作者多协议,所以很麻烦),最后是这个包的协议。 这个文件对照着说明慢慢整好了。。。

这些文件都搞定以后,用debuild或者dpkg-buildpackage就好了

具体操作是这样:

首先搞来源码包,如scanmem-0.09.tar.gz,把它改名为scanmem_0.09.orig.tar.gz,注意包和版本号中间的-改为_,另外就是加个.orig
然后解压,进入scanmem-0.09目录,建立debian目录,写需要的东西。(可以用dh_make或者copy一份)
然后debuild,等会儿就好了

其他说明
1.debuild是编译成.dsc .orig.tar.gz .diff.gz这三个文件,还有个.changes 而dpkg-buildpackages则是最终搞若干个.deb

2.我的另一个需求是一个源码包搞出两个deb package出来,这个我搜了好久,现在似乎唯一可用的资源是ubuntu packaing guide以及这个链接http://www.miriamruiz.es/weblog/?p=42,我再整理一下,大致是这个样子

我现在是想编译两个包,分别是scanmem和gameconqueror,那么control文件里自然要分别写一套信息,而另一方面在debian目录里建立scanmem.install gameconqueror.install两个文件,分别是需要的文件列表,可以用通配符,例如
#scanmem.install
usr/bin/scanmem

#gameconqueror.install
usr/bin/gameconqueror
usr/share/gameconqueror/*

这样就可以了。

另外就是,默认rules是把需要的内容安装到debian/tmp/下,而如果用dh_make按照single binary的设置输出,rules文件会设成安装到debian/scanmem,需要改成tmp,否则报错

由于我主要是给PPA打包,所以用到的是debuild, dpkg-buildpackage以前自己编译内核是用过

3.我看了Debian的打包说明,发现了svn-buildpackage这个好东西,适合我这种直接在svn里搞的人。

直接在svn里建立debian目录和相关文件,然后svn-buildpackage --svn-builder=debuild -S -sa -k就搞定了,最后的东西到../build-area里去找,另外--svn-builder后面这堆参数是为PPA用的

3. PPA
ubuntu 社区的PPA确实是个好东西,装了很多PPA很是羡慕,现在也终于有一个自己的PPA了

激活PPA的大致流程是:

注册Launchpad帐号
建立一个PPA,设置名称,说明等等
创建一个自己的OpenPGP密钥,发布到Ubuntu Key Server, 再导入到Launchpad
签署Ubuntu Codes of Conduct,就是拿自己的私钥加密一个文件再上传

所有步骤在上面所述的PPA Overview链接都有说明,界面简介,高效,甚至有趣,我在操作过程中笑了好几次。倒不是多幽默,主要是确实好用,也是第一次实际操作公钥私钥这种东西。

然后就是上传了,按照Uploading Guide 慢慢来就好了。如果编译没问题,这一步很简单。只是注意要导入自己的公钥,以及签署Ubuntu Codes of Conduct。



基本就这些了,再一次跟开源世界亲密接触,真爽!