Monday, December 14, 2009

Idea for a simple bib tool

I was using Zotero for my research readings, however, it is a bit too heavy for me, and I want a tool that can be portable across machines. So I am planning to write a bib tool for myself when I am a bit free sometime next spring.

The most important concept in this tool:

  • Keep it Simple: there will NOT be fancy setup interface, but a config XML; there will not be many export styles for that is latex’s business.
  • Depend less: there is already many advanced tools for bib organization, but they depend on this and that. I plan to implement all this tool with Python and sqlite3, so it can be put into U-key/Dropbox, and used anywhere.

The basci senarios is:

  1. User start the tool, which set up a local web sever at a high port (eg: 8080), and open any browser to land on the interface.
  2. To add a new paper, user have to
    1. upload a pdf file
    2. add bibtex info by
      1. upload a crospending a bibtex file
      2. fill a form to generate bibtex info
    3. add optional tags
    4. add optional note
  3. To view paper:
    1. start a search (empty field means any)
    2. a list of reference is returned
    3. (optional) open pdf file
  4. To export
    1. start a search
    2. select paper and add to “basket”
    3. go to export folder and get a sorted bib for all and BIB’s for each files and copies of PDF’s

Suggestions are always welcomed :)

Wednesday, December 9, 2009

SumatraPDF is really FAST

I have reading a lot of pdf files recently, and I often open a file, read a handful paragraphs and close the file. While Adobe Reader provides great render quality, it is a bit slow.

So I turned to SumatraPDF, which is an open source pdf reader based on MuPDF and brings several useful functionalities, such as searching and copy.

Thursday, December 3, 2009

What in_lto_p has _p suffix in GCC 4.5

Abstract: Curiosity killed the cat XD

Usually we use _p suffix to pointers in C language, but it is not the case for in_lto_p in GCC 4.5, so I searched for the reason, and according to <> :

A _p suffix indicates a boolean test for the condition described by the rest of the name. (This comes from Lisp.)

And it can be supported by this wiki page<> :

This practice originated among users of the Lisp programming language, in which there is the convention of appending the letter “P” on elements to denote a predicate (a yes or no question). It is most commonly used at MIT and the University of California, Berkeley, or among computer scientists working in Artificial intelligence (which frequently uses Lisp).

So _p for predicate not pointer here :)

Wednesday, December 2, 2009

Bash environment memo: profile, bash_profile & bashrc

Abstract: I'm trying to explain the process of bash setup in this article.

Keywords:bash, shell, environment

It is usually hard to answer the question where this variable is set, because there is SO many different files involved. So let's start with some concepts:

interactive login shell
The shell started after a successful login, using /bin/login, by reading the /etc/passwd file.
interactive non-login shell
It is normally started at the command-line using a shell program (eg.$/bin/bash) or by the /bin/su command. It is also started with a terminal program within a graphical environment.
non-interactive shell
It's usually used to execute a shell script

An interactive login shell generally initializes with the following configuration files:

/etc/profile -> [~/.bash_profile] -> [~/.bash_login] -> [~/.profile]

In some systems, the /etc/profile script will look for additional settings in /etc/profile.d/*.sh, and the ~/.bash_profile usually sources ~/.bashrc.

When an interactive non-login shell starts, it first copies the environment of its parent shell and then reads its settings in the following order:

/etc/bash.bashrc -> [~/.bashrc]

Remember that only exported variables of its parent shell is copied, functions and aliases of its parent are NOT inherited.

A non-interactive shell simply copies environment from its parent, and does not read any configuration files.

Thursday, November 5, 2009

Mount internal filesystem without passwd with udisk (formerly devicekit-disk)

Abstract: Use policykit to avoid root password for mount an internal filesystem.

Last week, I updated my Arch Linux laptop, and got the new deviekit-disk. Then I found that the authorizations set with gnome interface, which actually sets, stops work. I have to give the root passwd when I try to mount an internal filesystem, which is really bothering:(

Luckly it is not hard to solve this problem with Policykit, though there dosen't seem to be a sweet GUI to help. All you have to do is simply create a text file named anything with suffix .pkla in /etc/polkit-1/localauthority/50-local.d/ and fill it with the content below:

[filesystems mount internal privs]

In case you have udisks2 instead of udisks, the action should written like this:


Here I allow all users in group disk to mount internal filesystem without root password. disk is the default group of storage devices, you should add yourself to this group. Otherwise you can specify your login name:


To see all possible actions, check /usr/share/polkit-1/actions directory.
You can always man pklocalauthority for more info:)

Update (May 22nd 2012)

Udisks2 uses different action name.

Update (Oct 25th, 2011)

Latest udev will set storage devices of group disk. So I specify group disk instead of storage now.

PS: I moved to a new blog.

Update (April 3rd 2010)

People from are making a great progress - by renaming devicekit-disk as udisk (Sounds talking about flash disk, isn't it?)... So you got to change Action=org.freedesktop.devicekit.disks.filesystem-mount-system-internal to Action=org.freedesktop.udisks.filesystem-mount-system-internal.

Dear sirs/madams from, will you please stop renaming things? It's not fun, at all :(

Update (April 16th, 2010)

It seems /etc/polkit-1/localauthority/50-local.d/ is a better place to apply your own settings.

Update (Nov 2nd, 2010)

The configuration file has to be named with suffix .pkla to be recognized, for more details you can man pklocalauthority. And lots of thanks goes to Awebb who kindly points this out :)

Sunday, September 27, 2009

looking for a web software for knowlege sharing

I am currently looking for a web-based software for knowledge sharing in our lab, I've investigated some blog, cms and also wiki softwares, but none seems to fit :(

We just want something which is easy to setup and maintain, and can organize different kind of materials. CMS's are powerful, but relatively hard to used...Wiki seems to lack some kind of structure. Blogs are easy to use, but does not organize resources well.

So what do you use in your lab, my dear readers?

Wednesday, September 16, 2009

QEMU "host only network"

Abstract: Setup an LAN network of only the host and guest.

Recently I'm trying something on qemu and want to access the guest from the host more freely than user mod port redirect, but I do not want to expose my guest to the host network. All I did is to wrap everything into a script:


IFNAME=`sudo tunctl -b -u $USERID`

sudo ifconfig $IFNAME $HOSTIP netmask $NETMASK up

echo ":: Host IP is $HOSTIP"
echo ":: Run the follwing command in guest to set IP and gateway:"
echo " # ifconfig eth0 $GUESTIP"
echo " # route add default gw $HOSTIP"
echo ":: Starting QEMU with TUN/TAP network..."

qemu -hda webdev.qcow \
-boot c -m 256 \
-k en-us -localtime\
-net nic,vlan=0,model=rtl8139 \
-net tap,vlan=0,ifname=$IFNAME,script=no,downscript=no

sudo tunctl -d $IFNAME

Btw, I find sticky note gadget on iGoogle a great tool to share a couple of lines between machines - I'm writing on my Windows laptop and the script is in my Linix desktop, just a few paste and copy brings the script here :)

Monday, September 7, 2009

VIM Modeline is your friend

Abstract: Add modeline to a file can help VIM remember file-specific options.

I've got to port some application to another arch these days, so I have to deal with a lot of files that does not follow my usual coding standards, and I don't want to edit my VIM settings now and then, so I turned to modeline for help.

To add modeline to all the files, I simply did a find & echo like this:

for f in `find . -name '*.cpp' -o -name '*.h' -print0| xargs -0i echo {}`;do echo -e "\n/* vim: set ts=2: */" >> $f;done

Saturday, September 5, 2009

How to insert formatted date in VIM

Abstract: Remember to escape the percent sign

I find that I cannot simply prefix a r! before plain date command to insert a date in VIM today, When I tried to insert date with

:r !date +%u

I got an error, the reason lies in the percent sign, which stands for the current file in VIM ex-mode. For example, you can count the current file like this:

:! wc %

Thus to insert a formatted date, you have to run:

:r !date +\%u

Thursday, August 13, 2009

Good Book: CERT C Secure Coding Standard

Abstract: a good reference book on coding in C

It's a good reference book on coding nicely in C, which is the most dangerous programming language I know except for brain-f*ck...

Another good point is that you can read it free online:

Thursday, July 30, 2009

Backup with Acronis and without CD

Abstract: Boot Acronis True Image from grub.

Acronis True Image features online backup, however sometimes you may still want to do a off-line one, then normally you have to either install Acronis to hard disk or use a rescue media CD. Since I have both Arch Linux and Windows installed, I do not want to install Acronis to hard disk because I want to have grub in MBR. But I cannot use rescue cd either, because my cd has already been dead for years.

I've tried to make a usb disk rescue media, but it simply does not boot :(

So here's what I did:

  • Generate a rescue ISO with Acronis;
  • Expand ISO file and copy all in Recovery Manager to a directory on hard disk;
  • Write in Grub's menu.lst:
    title Acronis
    root (hdX,Y)
    kernel /acronis/kernel.dat quiet vga=0x317
    initrd /acronis/ramdisk.dat

  • Reboot and select Acronis from grub

Now you see, Acronis Rescue CD is actually Linux :)

Tuesday, July 28, 2009

bool & GCC

Abstract: I'll try to clear up confusion about bool for non-compiler people;)

Even some of my teammate on compiler would misunderstand bool with GCC some times. So I'm trying to make it a bit clear:

bool is not an valid type in C89, which is referred as ANSI C sometimes. Therefore, if you are working on a project that is supposed to be compiled with an ANSI C compiler, do not use bool type. However, bool is valid in C99 as _Bool, so you can use it safely if your code is not expected to be compiled with an ancient compiler;)

In GCC code, you can see 'bool' here and there, but bear in mind that it's fake - it's actually unsigned char, defined in gcc/system.h. This is because GCC is expected to bootstrap with an ANSI C compiler.

In C++, bool is always valid, you don't have to worry about bool.

SnipMate is fabulous

Abstract: A textmate-like snippet script for VIM.

I've been using snippetemu for about one year and happen to find another snippet script for vim - snipMate. After a try, I do think snipMate is much better than snippetemu, for tow reasons:

  • Its snippet format is simple and clear.
  • No placeholder.

I do suggest give it a try even if you're not a fan of TextMate, because it really makes coding easier.

You can find snipMate's VIM page here.

Tuesday, July 21, 2009

Firefox 3.5.1 (Shiretoko) fails to launch in Arch Linux

Abstract: Firefox 3.5.1 needs libjpeg.

After updating my Firefox (Shiretoki) to version 3.5.1 in Arch Linux, I cannot launch it. When I tried to start it from command line, it says:

$ firefox
Coundn't load XPCOM

Then I tried to run xulrunner directly, I got a Error message saying that libjpeg cannot be found. So I installed libjpeg-7-1, and Firefox is back again. Hopefully the Arch people can add libjpeg to Firefox's dependency.

Monday, July 20, 2009

Pm-hibernate with MX440

Abstract: Some tweaks to avoid black screen after resume from hibernation with old nVidia MX440 graphic card and Intel motherboard.

First edit the setting for pm-utils in /etc/pm/config.d/config(you can name this file whatever you like).


Then I edit /etc/modprobe.d/modprobe.conf(the modprobe.conf is here for Arch Linux, but may lies in different place in other distros):

blacklist intel_agp

Then reboot the computer, and try hibernate again, everything goes well :)

Monday, July 13, 2009

How to Compact Virtualbox vdi

Abstract: a memo on how to compact virtualbox vdi files.

VirtualBox comes with a utility to compact vdi files which drops zero block. So the problem is how to write zero to unused blocks. If you have a windows guest, run the following command in cmd:

sdelete -c

If you have a linux guest, run this:

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

And in the host run:

VBoxManage modifyvdi harddisk.vdi compact

These may reduce the size of vdi files considerably if it has been used for a long time.

Tuesday, July 7, 2009

"The greeter application appears to be crashing"

Abstract: Resolved "The greeter application appears to be crashing" problem after updating Linux system.

I don't know whether this could be called a solution... actually just a tip if you happened to come across a same problem. I updated my Arch Linux, and after reboot this dialog box jumps up and gdm could not start normally. I checked the system and found the problem was caused by a full filesystem. I cleaned up some old files and then everything goes right.

So I guess I should give more disk space to / in the future.

Wednesday, June 24, 2009

Google Service Blocked by Chinese Gov

It seems the Chinese government is now crazy about blocking foreign websites, now, and all services of Google except are now blocked by the Great FireWall.

Web censorship ans secrete police are now bringing the country back to the bad old days :(

Tuesday, June 9, 2009

Sigh...blocked again :(

As everybody knows, there is a Great Firewall(usually called GFW for short) between we Chinese internet users and the 'out side world'. Unluckily for some unknown reason, blogger and blogspot is blocked by GFW recently which does cause me a lot of trouble to keep blogging here... Anyway, I will try hard to keep this site updated.

Get Chrome Work in Arch Linux

Abstract: several steps to get chrome working on Arch linux

  • Google only provides deb pkg officially, damn...

  • download the deb pkg from:

  • unpack, copy everything in opt to /opt

  • mkdir lib32 in /opt/google/chrome, and make symbol links as:

  • enjoy chrome...though I can't input Chinese in its linux

Update Jun 13, 2010: Now chromium is in the official repo, and if you'd like to use Google Chrome(beta), it's in the AUR.

Tuesday, May 19, 2009

The problem of pm-hibernate solved

Abstract: Solve the problem of pm-hibernate restarts computer.

When I try to hibernate my laptop running Arch Linux with pm-hibernate which is also used by GNOME behind the scene, it restarts immediately after hibernate to disk. I checked Arch wiki and find a link to opensuse wiki Pm-Utils. After add a s2ram force option as instructed, the problem is solved. I added the following lins to /etc/pm/config.d/config

S2RAM_OPTS="-f -p -m"

The "-p" parameter was the key to a successful hibernate for me.

Sunday, May 17, 2009

Script to synchronize VIM settings

Abstract: My scripts to backup vim setting and synchonize between Windows and Linux.

Finally I cannot bare the boring work of copying my vim settings around my labtop(with both windows and linux installed), lab pc and working server. So I write a few scripts to automatic this work for me:)

The first script is used to copy the scirpts to a certain dir on my laptop that can be share accross Windows and Linux systems. tr and sed are used to convert file format and handle some syntax difference.

if [ -d $BACKDIR ] ; then
echo "Backup to $BACKDIR"
mkdir "$BACKDIR"
echo "Make backup dir $BACKDIR"
rm .vimrc
rm .gvimrc
rm -rf .vim
cp '/cygdrive/c/Documents and Settings/Yuanjie/_vimrc' .vimrc
tr -d '\15\32' < '/cygdrive/c/Documents and Settings/Yuanjie/_gvimrc' | sed 's/set guifont=\([^:]*\):h\([0-9]*\)/set guifont=\1\\ \2/' >.gvimrc
cp -r '/cygdrive/c/Documents and Settings/Yuanjie/vimfiles' .vim

After files are moved to the synchronize folder, I init a git repo and push it to a host. The synchronize script on the Linux side goes like this:

if [ ! -d "$BACKDIR" ] ; then
echo "trying to mount drive e ..."
pmount /dev/sda9
if [ "$?"=0 ] ; then
echo "drive e mounted"
echo "drive e cannot be mounted"
cd $HOME
tar cjf .vim-setting.$(date +%F).tar.bz2 .vim/ .vimrc .gvimrc
rm -rf .vim/ .vimrc .gvimrc
cp -r $BACKDIR/.vim $HOME
cp $BACKDIR/.vimrc $HOME
cp $BACKDIR/.gvimrc $HOME
if [ "$EMOUNT"=1 ] ; then
pumount /dev/sda9
if [ "$?"=0 ] ; then
echo "drive e unmounted"
echo "drive e cannot be unmounted"

The scirpt above tar the original setting files and copy the new settings from the synchronize dir. Since the drive is not always mount, a dir test is used and drive will be mounted with pmount. The synchonize scirpt on Windows is similar but simpler than this, but guifont setting in gvimrc will have to be changed back like this:

sed 's/set guifont=\([A-Za-z\\ ]*\)\\ \([0-9]*\)/set guifont=\1:h\2/'

Notice that you may have to modify this in case there's number in your font name...

Thursday, May 14, 2009

EE in side?

Well I promised that I will blog about technique-related stuffs in English, but that is NOT always easy, especially when I want to talk about something not exactly technical… So let me try ;)

Today I helped Emma understand the confusing chip manual from TI, which is actually quite ordinary for a guy who was majored in EE – like me ;) Computers, cellphones, PDA’s and all lovely electronic gadgets are just chips connected on PCB in my eyes, and all programs to me are just bit streams flowing on the binary circuit… Parallelism has never be something hard for me since all the parts on a circuit should be working simultaneously (though some of the chips can be disabled to save energy or for some other reason…)

I do find some differences between me and those ‘genuine CS’ guys XD – What occurs to me when I meet difficulty in my experiments is to build a ‘lab-made’ hardware environments of my own instead of buying from some vendor; CS people say that this CPU features loading 8 instructions a time, while I say this CPU could work better with block-reading storage devices since reading multiple continuously stored instructions at a time is more efficient...

Currently I’m working on GCC and studying machine learning and data mining techniques, which are all interesting, but sometimes I do miss those days with FPGA and various chips and I’m still dreaming of building my CPU (perhaps with FPGA) which implements my instruction set, designing a circuit to support it, and finally writing a kernel, a compiler and several applications to form a minimal environment in my programming language for it. I don't believe this will be of any academic significance... but it really sounds INTERESTING~

Sunday, May 10, 2009

Converting between WAV and MP3 with simple open source tools


A short memo on converting between mp3 and wav files

Today I find some conf call audio records are so big for my little hard disk so I decided to convert them from WAV to MP3 format. I make use of a simple (more precisely, simple to use) tools to do the job -- lame.

Since all my wav files to convert sit in the same folder, I make use of a little bash:

$ for f in `ls -1 *.wav | sed s/\.wav$//` ; do lame $f.wav $f.mp3 ; rm -v $f.wav ; done

Easy, isn't it?

Converting mp3 files back is just as easy, though there should be some quarlity loss which I don't believe can be noticed for a conf call record;) The mpg123 is as simple as its name 123, you just have to give it the name of the file to convert

$ for f in `ls -1 *.mp3 | sed s/\.mp3$//` ; do mpg123 -w $f.wav $f.mp3 ; done

Tux Drawing

I'm not sure whether is a good idea to put it here, anyway, I think Tux is technique-related...

Done in OpenCavas(Maybe I should use Linux and GIMP to do this, but I really don't like GIMP)... This took me several minutes after a pencil sketch on real paper.

Saturday, May 9, 2009

How to use git-http-fetch with a proxy


This post offers a tip on how to use git with a http proxy

I noticed a mail in the Chinese Google Summer of Code mail list today, which askes how to use git-http-fetch when a http proxy have to be used to access the git host. I don't believe there is any way to do so with GIT, but I don't think this should be a tough problem either. Remember git is only a common program, though it does many magic>. So it should work with http proxy just as other programs do.

Remember how we access the internet with a proxy in bash? All we have to do is to set the http_proxy environment variable.In bash we simply do:

export http_proxy=”http://<proxy-server-ip>:<port>”

Or you may:

http_proxy=”http://<proxy-server-ip>:<port>” git http-fetch <your-params>

And be aware that the name of the environment variable is in lower case.

Wednesday, May 6, 2009

How to process large text file efficiently in Python


Three different ways of processing text file line by line are given in the order of increasing efficiency.

I have to handle a large text file of space-separated data in python, and the data goes like this:

tag1 tag2 tag3
12 34 12
123 345 12

the first line is tags for each column, and the rest lines hold data. Since the tags are fixed, I can code it directly in to my script, that is to say the first line should be skipped. My first script goes like this:

file = open('foo.txt', 'r')
for line in file.readlines()[1:]:
#do something

This script requires a vast amount of RAM, since it has to store a list of all lines! So it is wise to use iterator:

file = open('foo.txt', 'r')
first = True
for line in file:
if first:
first = False
#do something

The second script works much better than the first one, because the lines are read one by one from the file by using a iterator. However, the first flag is not a neat way to skip the first line for we have to test the flag many times, which makes no sense. And the problem is solved in the third script:

file = open('foo.txt', 'r')
for line in file:
#do something

the 'fileread.line()' command will perfectly move the file position one line forward, and the iter will then start from the second line:)

Monday, May 4, 2009

How many lines does it take to learn a new language?

It seems to be impossible for me to learn a new programing language by reading books without practice, so the question in the title occurs to me – how many lines does it take to learn a language?

The number obviously depends on many factors: whether it is the first programming language to me, if I have learned a language with similar grammar/design before, the size of the standard library… and a lot!

And it’s even harder to define when I should say I have learned a programming language… Having been programming in C for years, I still check the standard library now and then :(

Maybe I should define a metric of the familiarity of a programming language, ask all my friends in this trade to help me collect data, and take some statistical approach to obtain a equation of lines needed to practice a language... Hmm, a lot work to answer this simple question, isn't it XD

a python script to generate cue file


A python script to generate cue file from file names in a same folder is given.

Sometimes we have lessless music (ape, flac…) split in to different files, and a cue file may help orgnize them in some music jukebox application, i.e foobar2000. so I create a really silly script to help me…

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import os
import sys
import glob
from string import Template
from optparse import OptionParser

cue_head='''REM GENRE $GENRE

INDEX 01 00:00:00'''

def cue_gen():
generate cue file
parser = OptionParser()
parser.add_option('-d', dest='dir',
parser.add_option('-s', dest='sfx',
type='string', default='ape')
options, args = parser.parse_args()

if options.dir is None:
directory = os.getcwd()
directory = options.dir
suffix = options.sfx
print directory, suffix

files = glob.glob(os.path.join(directory, '*.'+suffix))
files = [ff[1] for ff in [os.path.split(f) for f in files]]
for file in files:
print file
begin = int(raw_input('Title offset? '))

genre = raw_input('Genre? ')
date = raw_input('Date? ')
discId = raw_input('DiscId? ')
performer = raw_input('Performer? ')
albumTitle = raw_input('Title? ')
d1 = dict(GENRE = genre,
DATE = date,
DISCID = discId,
PERFORMER = performer,
ALBUMTITLE = albumTitle)
head = Template(cue_head).substitute(d1)
cuepath = os.path.join(directory, (albumTitle+'.cue'))

f = open(cuepath, 'w')

track = 0
for file in files:
trackTitle = file[begin:-(len(suffix)+1)]
track = track + 1
d2 = dict(FILE = file,
TRACK = track,
TRACKTITLE = trackTitle)
body = Template(cue_file).substitute(d2)


if __name__ == '__main__':

I know it’s quite rough and a lot of enhancement can be made… maybe it should search for the right file extension automatically or even search the genre for the internet, and that’s just why I put it here, hopefully some of you would help to improve it XD

Sunday, May 3, 2009

Migrate to a blog is just like move to a new house...

It's tiring, but offers a great opportunity to review my stuffs - what I have been writing about, what kind of blog I hope to have, whether my posts are well tagged...

And when I was trying to make a list of all programing/makeup languages I've used, I found some of them get so rusty that I cannot even remember how to define a function in it...Hmm it doesn't sound good :(

Fresh New Blog for Tech blogging =)

Hi all,

Finally I've decided to write a new blog for my technological posts, and all posts related to technology (software, Linux system, web technology...) will be migrate here in a short period of time =)

Thursday, April 30, 2009

My Comments on Books about Shell Programming

In this article I shall introduce several books about shell programming and hopefully it will help you to determine the right one for you.

I have to learn shell to carry out some of my experiments recently, and to be honest, I don’t feel like shell very much since there are so many modern script languages out there… Anyway, as shell is so widely used, it’s not too bad to spend some time on it.

  • A Practical Guide to Linux Commands, Editors, and Shell Programming is a nice book to start for newbies :)
  • Unix Shell Programming is the best book on shell programming I’ve found, which explains how shell works clearly
  • Classic Shell Scripting is not structured as well as the the previous one, but it has a chapter on security and explains some basic ideas in more details. If you get confused while reading the previous book, check this one.
  • Unix Shell by Example explains all popular shells, including sh, bash , csh and ksh, if you are going to script for different shells you may very likely find this book useful.

Monday, April 27, 2009

Google logo today is so~ COOL!

So impressive.

Finally get Xorg-1.6 work with nVidia MX440


I describe a solution to the problem that Xorg 1.6 fails to work with Mx440 and kernel 2.6.29 in Arch Linux

I'm currently using an old PC in the lab, which features a MX440 video card, last week I updated my Arch Linux and got Xorg 1.6, and that was the start of a nightmare...

Xorg refuse to work with the legacy driver (nvidia-96xx), and won't start if the xorg.conf file exists, which is used to specify the screen resolution(though the pc is quite old, I got a big widescreen monitor…). I browsed the Arch user forum and tried all the solutions given, and finally get it work with add “nopat” option to the kernel in the grub munu.lst like this:

title Arch Linux
root (hd0,4)
kernel /vmlinuz26 root=/dev/disk/by-uuid/99b8f60e-c1eb-4482-a22f-6a49a5572401 ro vga=0x317 nopat
initrd /kernel26.img

Hopefully this can be useful ;)

Saturday, April 25, 2009

Linux is neither heaven nor hell (3)



在Linux升级的时候,需要首先做好搞砸整个系统再也看不到可爱的GUI界面的心理准备,备份好自己的文件,向图灵、冯诺依曼等计算机史上的贤者祷告,祈求得到他们的祝福。然后毕恭毕敬小心翼翼的输入升级的命令,接着就是听天由命了……可惜这些神明并不好伺候,有的时候他们会莫名其妙的降罪于我。比如我今天在笔记本电脑和台式机上同时升级我的arch Linux,笔记本上的表现很好(尽管Root Terminal不能用了,我的触摸板却神奇的好了,经过我的配置还支持了连为windos都不曾支持过的双指触控-_-b),而台式机则直接出现了最恶心的xorg错误,目前连正确的分辨率都无法设置。





[ to be continued... ]

Friday, April 24, 2009

Linux is neither heaven nor hell (2)










【 to be continued… 】

Thursday, April 23, 2009

Linux in neither heaven nor hell (1)




SUSE之后换了据说用户也很多的Fedora Core(当时还是叫做Fedora Core的,后来才改名叫作Fedora),可是我很快就被rpm打败了,依赖关系这个概念对小白太复杂了……


后来我搞了一次debian的dist update,把它搞死了……然后也懒得修理,就抛在那里去用cygwin了……

再后来就是今年开始的arch冲击了,呵呵。从只有bash, ssh, wget, ftp, make, gcc, tar, pacman, vim等几十个小工具开始的系统建造之旅。这是我第一次下了决心要把该知道的都知道了,告别没了X就完蛋的时代。一路走来,我认识了以前不认识的/etc里的大部分文件,我知道了HAL的设计思想,我知道了Gnome中挂载硬盘分区是通过pmount的……后来我发现原来系统是可以通过tar备份迁移的,再后来知道原来神奇的ZFS文件系统有snapshot功能……


【 to be continued… 】

Wednesday, April 15, 2009



当年dreamweaver横空出世,与frontpage争锋“用table布局的最强大工具”;而今虽然土坯还在孜孜不倦的出dw cs2, dw cs3, dw cs4 实际上严肃的实用网页基本上都变成用文本编辑器(比如记事本)写代码的了(不知道T大的计算机文化基础课程还要不要大家做网页了,当年会有dreamweaver可是个“先进”工具的说……如果还在教dreamweaver我就不的不鄙视一下母校何其土鳖……当然作为一个第三世界国家我没指望大学教学能引领研究和产业发展,至少也得跟上时代步伐)

的确上来就教如何手写代码看起来很是不人性化,大有要非ECS系童鞋小命的感觉,不过从只有head, title, body, p标签开始学习做其实还挺有趣的,比一个一对按钮面板不知道怎么用的dw强多了;当今网页创作工具再次倒退回到了文本编辑器时代。




Monday, March 30, 2009

Clone Arch Linux to another computer

I’ve just cloned my arch linux installation from my lab pc to my laptop, and it is much easier than I’ve expected. First I packed every thing up into a tar in a removable disk like this: (you need to change sdxx and sdyy below to your corresponding partition)

#mount the backup disk
mkdir /mnt/backup
mount /dev/sdxx /mnt/backup
cd /
tar -cvpzf /mnt/backup/BACKUP_FILE.tar.gz --exclude=/{dev,lost+found,mnt,proc,sys,tmp,}/* /

Then in my laptop:

# boot with arch iso
# mount the dest partition
mkdir /mnt/arch
mount –t ext3 /dev/sdyy /mnt/arch
# mount the backup disk
mkdir /mnt/backup
mount –t vfat /dev/sdxx /mnt/backup
# expand the installation tar
cd /mnt/arch
tar –xvpzf /mnt/backup/BACKUP_FILE.tar.gz
# something necessary to boot
chroot /mnt/arch
cd /dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3
# modify the /etc/fstab
# make a new boot ramdisk
mkinitcpio -p kernel26
# install grub
# modify /boot/grub/menu.lst
umount /dev/sdxx
umount /dev/sdyy
shutdown –r now
# have fun

Besides what are listed here, I also changed my video card driver and edited my /etc/xorg.conf file. The workflow works well for Arch Linux, but might not work exactly with other distro(e.g. mkinicpio seems to be Arch-only), in this case you may need to consult the all-mighty adviser – Google ;)

Monday, March 23, 2009

Cannot use visudo?

Su is not always the best tool to grand permission to users, so I installed sudo on my Arch Linux system. However when I tried to issue visudo, I got the following error:

bash-3.2# visudo
bash: visudo: command not found
The reason of this is quite simple - /usr/sbin is not in the PATH environment variable by default, and you can locate the visudo command by:
bash-3.2# whereis visudo
visudo: /usr/sbin/visudo /usr/share/man/man8/visudo.8.gz
so just use the full path to visudo:
bash-3.2# /usr/sbin/visudo
then everything goes right.

Sunday, March 22, 2009

Script to set all pdf bookmarks to zoom: inherit

When you create a bookmark in Acrobat, it automaticly sets the current zoom setting to te bookmark. This may be smart and sweet for someone, but to me it's stupid and annoying. Since when I read a file in a large screen, I want a greater zoom, while on a smaller screen, I wanna save space and see more content; setting a zoom for bookmarks screws things up. Finally I found {a great perl script} that can convert all pdf bookmark to zoom: inherit.

Use the script from the zip, which set all bookmarks to zoom: inherit (the script is named as fitpage, which is a bit confusing...)

Notice that the script only works for PDF version 1.4 or earlier, if you're using Acrobat 9, you can convert the file to pdf-1.4 (Acrobat 5) by going to menu: advanced>print production>preflight, the wizard will do a nice convert job for you.

VIM in GNU coding style

I guess I'll start working on GCC recently, so I tried to prepare my VIM for GNU coding style. However, it's not as easy as I hoped, since VIM seems to favor BSD style more than GNU style which is a great waste of screen space in my view...Anyway, after a vast amount of Googling and attempts, it works now. Here's what I did to VIM: create a file named c.vim in my "~/.vim/after/ftplugin" directory, with the following content:
"GNU Coding Standards
setlocal cindent
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal expandtab
setlocal shiftwidth=2
setlocal tabstop=8
setlocal softtabstop=2
setlocal textwidth=80
setlocal fo-=ro fo+=cql
I have to put it here otherwise the settings might be overrode by VIM's default ftplugin settings.

Saturday, March 21, 2009

My Score Summary as a Nerd…

I came accross this quiz (nerd quiz) when I was browsing my RSS feeds -____-b

Overall, you scored as follows:

10% scored higher (more nerdy),
1% scored the same, and
89% scored lower (less nerdy).

What does this mean? Your nerdiness is:
High-Level Nerd. You are definitely MIT material, apply now!!!.

Wednesday, March 18, 2009


color scheme: molokai

Friday, February 27, 2009




Sunday, February 22, 2009


今天从实验室回来忽然发现在虚拟机里的arch linux上不去网了,而我还没装上图形界面呢……于是翻了俩个小时的wiki也没查出个啥问题,一直"ping”都是丢包100%

怀疑来怀疑去,终于想起来好像在实验室用ping命令也是不成功的,但是可以连接源,晚上折腾的时候手上连文本的浏览器lynx都没有,所以用ping来测试。查看了一下VirtualBox 2.1.4的help文件发现原来在vbox的NAT模式下ping不通才是常态-____-b

于是我晚上都是在瞎忙活了>_< 剩下的未解决的问题是在vbox里的arch不能访问ipv6的源,问题在哪里……


又在vbox里启动了windows xp,安装IPv6支持,还是不能看到会动的可爱小海龟:( 于是我暂时的结论就是vbox的NAT模式不能使用IPV6……


Friday, February 20, 2009


今天开始在虚拟机里面折腾 Arch,发现Arch的wiki的质量很是不错(比某U的强多了),直追gentoo呀~默认安装的Arch是没有图形界面的(这么“反动”的发行版似乎已然不常见了),而阅读wiki中关于GNOME的安装的部分才发现该发行版的GNOME的安装被分解的如此详细,一大堆早就看不顺眼的组件都可以不装:) 对于GNOME的废物组件我是很有怨念的,当年俺还是特白的小白鼠的时候(现在是比较白的小白鼠-__-b),装了某U没事干就想在新立得里面把Gnome-games卸载掉,结果哗啦哗啦一大堆我不太明白的东西滚过后,重启后发现没图形界面了T__T 当时一点法子都没有呀,只好重装了一次某U ~>_<~ 往事不堪回首(尽管至今也没啥数据放在nix下,浪费点时间而已),我不禁想如果我当初早知道有种叫做Arch的发行版,那么有可能:
  1. 我现在对linux了如指掌,成为开源应用强人
  2. 我认为这个东西太可怕了,我不想RTFM,于是至今视linux为异端

但愿本周末能在虚拟机上把KDE 4.2完整的运行起来……

Thursday, February 19, 2009

damned linux distros:(

前两天在debian lenny下发现有个东西死活装不上(谁让debian的口号是稳定呢,某些发行版current里面到东西都要比debian experimental里面都要新……而我用debian是当桌面用的,偶尔一两个程序crash一下我是不在乎的,而现在linux桌面到发展速度还是很不容小视),于是就英勇到跳槽到了fedora 10(还好我的home是个单独到分区,跳槽方便快捷)。
可是开始看起来很美的(尤其是启动界面不错,视觉系一下,咔咔)fedora用着发现也不怎么样……比如说Yum装东西到速度实在是比aptitude慢多了,在漫长到安装程序过程中干别的事情还卡:( 我的fedora是用liveCD安装的,安装后发现有网络设置不长记性到毛病,每次开机后都会自动设置成DHCP……吐血ing
于是就有了更加bt的念头,我想尝试一下传说中的小众发行版了,比如说Arch Linux(本来也挺向往gentoo的,不过现在手里没有一台”现代“配置的机器,非要用legacy machine运行这个需要自己编译一大堆东西到系统实在是太sm向了=_=)虽然bsd风格的简洁优雅到启动脚本比起sysV风格的更加适合俺这种简洁直白控,可是我不能没事去对着启动脚本发呆吧-__-||
这两天实在是没有什么动力干正事,于是就拜读了Filesystem Hierarchy Standard,还是蛮有收获的,推荐茶余饭后阅读之(现在有些发行版装软件到时候乱塞,不过其实社区的维护者也不容易,那么多包能稳定运行就不错了,何况某些路径还是hard code在代码里)
等周末了在virtualbox里面装个arch linux试试,如果有人用过给点提示哈~