Wednesday, June 24, 2009

Google Service Blocked by Chinese Gov

It seems the Chinese government is now crazy about blocking foreign websites, now www.google.com, and all services of Google except www.google.cn 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:
    http://www.google.com/chrome/intl/en/eula_dev.html?dl=unstable_i386_deb

  • unpack, copy everything in opt to /opt

  • mkdir lib32 in /opt/google/chrome, and make symbol links as:
    http://code.google.com/p/chromium/issues/detail?id=13425

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

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

HIBERNATE_MODE="shutdown"
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.

#!/bin/bash
CURDIR=`pwd`
BACKDIR="/cygdrive/e/vim-setting"
if [ -d $BACKDIR ] ; then
echo "Backup to $BACKDIR"
else
mkdir "$BACKDIR"
echo "Make backup dir $BACKDIR"
fi
cd "$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
cd $CURDIR

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:

#!/bin/bash
CURDIR=`pwd`
EMOUNT=0
BACKDIR="/media/e/vim-setting"
if [ ! -d "$BACKDIR" ] ; then
echo "trying to mount drive e ..."
pmount /dev/sda9
if [ "$?"=0 ] ; then
echo "drive e mounted"
EMOUNT=1
else
echo "drive e cannot be mounted"
exit
fi
fi
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"
else
echo "drive e cannot be unmounted"
exit
fi
fi
cd $CURDIR

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

Abstract

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