Tag Archives: Software

Emacs smart split for programmers

I spend most of my conscious hours in front of Emacs in a terminal window these days, and I share my configuration across all my computers. At work I have a huge monitor, so I split the emacs frame into 3 side-by-side 80-column windows. At home I have a smaller screen with room only enough for two windows. To share the same configuration file, I use the following snippet:

(defun smart-split ()
  "Split the frame into 80-column sub-windows, and make sure no window has
   fewer than 80 columns."
  (interactive)
  (defun smart-split-helper (w)
    "Helper function to split a given window into two, the first of which has 
     80 columns."
    (if (> (window-width w) (* 2 81))
    (let ((w2 (split-window w 82 t)))
      (smart-split-helper w2))))
  (smart-split-helper nil))

(smart-split)

The smart-split function split the emacs frame into a maximum number of 80-column windows. A very portable solution.

Getting Card Readers to Work on Ubuntu Edgy

I have an Acer TravelMate 3000 laptop. The card reader did not work on Ubuntu Linux, and I didn’t care, because I didn’t need it. When I needed to transfer photos from my DC, I just used the USB cable. Recently I got a Zaurus PDA from eBay and needed to format an SD card as Ext2 so that I can install Linux on it. After a lot of searching I managed to find a guide on the Ubuntu forum to get the card reader working. But the guide was in French, so I am posting an English guide here.

First, determine what controller you have:

lspci | grep CardBus

If you see something like this:

06:07.0 CardBus bridge: Texas Instruments PCIxx21/x515 Cardbus Controller

congratulations, you have the same controller as I do, and the following procedure might work for you.

Create the file /etc/init.d/tifm with the following content:

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=tifm
DESC="Texas Instrument Integrated Flash media controller"

# use lsb-base
. /lib/lsb/init-functions

retval=0
case "$1" in
    start)
        sync
        modprobe tifm_core
        modprobe tifm_7xx1
        modprobe tifm_sd
        log_end_msg $retval;
    ;;
    stop)
        modprobe -r tifm_sd
        modprobe -r tifm_7xx1
        modprobe -r tifm_core
        log_end_msg $retval
    ;;
    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop}" >&2
        retval=2
    ;;
esac

exit $retval

Make it executable and start at boot time:

sudo chmod +x /etc/init.d/tifm
sudo update-rc.d tifm defaults

To try it right away:

sudo /etc/init.d/tifm start

Plug in a card and it should be auto-mounted.

A Distributed Algorithms Simulator

I have released my Distributed Algorithms Simulator (DAS). I made it mainly because we needed to demonstrate the algorithms in one of our papers. It is general enough to simulate and visualize many kinds of distributed algorithms. Major features include: * Visualize and verify distributed algorithms. * Run algorithms in automatic mode, single-step mode, or interactively. * View port zoom in/out. * Adjust the speed of algorithm execution. * Export snapshots to image files to include in presentations or papers.

Please see the DAS website for details.

Emacs终于也有Antialiasing了

screenshot1.png 当年从Emacs改用gvim的很重要的一个原因就是Emacs的字体怎么看都不顺眼。现在Emacs终于开始支持 antialiasing (2006年都快过完了,感觉还呆在上个世纪…)。已经习惯了vim,所以没有换回的打算,不过还是忍不住装了一下玩玩。必须要用最新的 cvs snapshot 才行,这里可以找到 Ubunty Edgy 的包。

Compiz的确不错

/blogpic/compiz.png

今天装了compiz (hardware-accelerated desktop)。没做什么特别的设置就好了,对于一个Linux下还处于alpha状态的软件来说,有点让人意外。效果的确很impressive,感觉比Mac OS X还眩一些。Linux向一个能被一般用户接受的桌面系统这个方向已经走了很远。

可惜切换workspace的动画不能截图。

/blogpic/expose.png

Enabling CPU Frequency-scaling in Ubuntu Linux on Celeron-M Based Laptops

I have an Intel Celeron-M based Acer TravelMate 3000. The Celeron-M does not come with the SpeedStep technology, so it does not support frequency-scaling natively. But I got frequency-scaling working with p4-clockmod. This is disabled in Ubuntu (up to Edgy) by default, because there’s a significant delay when changing frequency on-demand. The following comment can be found in /usr/share/powernowd/cpufreq-detect.sh:

# Disabled for now - the latency tends to be bad enough to make it
# fairly pointless.

But by enabling it and turning of on-demand scaling, you can manually decrease CPU frequency to reduce heat and power-consumption when your laptop is lightly loaded. There’s how:

You need powernowd which is included in a standard Ubuntu installation. To make sure:

sudo apt-get install powernowd

Override the default configuration to enable p4-clockmod:

sudo su
echo "FREQDRIVER=p4-clockmod" >/etc/default/powernowd

To let your non-root account change CPU frequency, set the setuid bit of cpufreq-selector, so that it runs as root:

sudo chmod +s /usr/bin/cpufreq-selector

Now add the CPU frequency scaling monitor to your GNOME panel, you should be able to change the frequency by click on the icon.

Ubuntu/Debian 下的 JVM crash 问题

TopCoder 的 competition arena 在 Ubuntu Linux 下运行时会因为字体问题 crash 掉。估计还有别的 JAVA 程序有类似的问题。

用 google 找了个测试字体的 Java 程序试了一下,是一个叫 Rekha 的字体作怪。只要把 ttf-gujarati-fonts 卸掉就可以了:

$ apt-get remove ttf-gujarati-fonts

不过这样也会把 ubuntu-desktop / kubuntu-desktop / xubuntu-desktop 等顶层的包卸掉,不过那些包本身没什么内容,应该不要紧。

另外发现了一个很好用的工具 apt-file ,可以查找某个文件所属的安装包:

$ apt-get install apt-file
$ apt-file update
$ apt-file search Rekha.ttf
ttf-gujarati-fonts: usr/share/fonts/truetype/ttf-gujarati-fonts/Rekha.ttf

Gabor’s Blog: How Researchers are Reinventing the Mail Client

Gabor’s Blog: How Researchers are Reinventing the Mail Client

Email today has many annoyances. Even though we now seem to have a grip on the spam problem, many users are suffering from email overload: There are just too many emails flooding the inbox. Many are drowning in heaps of emails that aren’t even important – it’s just a colleague at work Cc-ing everyone evenly remotely connected to his project.

解决了和MSN Space同步的问题

本来有 MSN Space ,后来因为把 blog 搬到自己的服务器而删掉了。不过 MSN Messager 的 MSN Space 更新通知实在是个很好的功能。今天突然想到可以写个 WordPress 的 plugin 让基于 WordPress 的 blog 和 MSN Space 自动同步。动手前的第一步当然是google一下,果然不出所料,已经有人做了同样的事情: MSN Sync 。于是 新建了一个 MSN Space , Down 了 MSN Sync 下来,做了一些简单修改,虽然还有一些需要改进的东西,不过已经很好用了。正在和作者联系,如果得到他的允许,我会做一些我所希望的修改,然后重新发布出来。

Update一下:今天看到 priv 改进的版本 ,觉得改动和我现在的相似并且更加好用,所以我也就没有必要再发布一个版本了。

That apple looks familiar

desktop.jpg 用惯了我的PowerBook,再来用PC,觉得真是怀念Mac OSX。 无聊的时候试了一下FlyakiteOSX,结果还不错,见图(Acer TravelMate 3002)。:-)

比较适合不得不用Windows又觉得微软的UI很dull的人。