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