Saturday, March 13, 2010

My List of Android Apps

I have been using HTC magic for 5 months. Although apps installed on top of cyanogenmod change week by week (if not day by day), I'd like to take a snapshot as shown below.

  • 3banana: take quick notes. I sometimes use it to draft tweets which are sent out later when network connection is available.
  • Aldiko: ebook reader (specifically, an ePub reader). The builtin support of Feedbook catalog is fantastic.
  • Amazon: for quick lookup of prices.
  • APNdroid: control GPRS/EDGE/3G traffic.
  • ASTRO: file manager. Can also manage apps, show SD card usage, and display running processes/services.
  • Barcode Scanner: scan various codes. Good to scan QR code in Web to install apps.
  • Battery Monitor: show remaining battery percentage in notification area.
  • Bible KJV: the Bible.
  • CalWidget: highly customizable calendar widget. I just places one 4x4 widget at my left home screen. Much better than default widget.
  • Cavedroid: one addictive small 3D game.
  • EasyMoney: financial status manager.
  • FlipSilent: simply flip your phone to mute all sounds.
  • Google Pinyin: input method for Chinese.
  • Google Sky Map: cool app to view stars.
  • Google Voice: free SMS (English text only to non-GV users).
  • GPS Status: show GPS information as well as a compass.
  • handyCalc: a very powerful calculator. Serve as unit/currency converter as well.
  • HiDict: support offline dictionary.
  • iReader: I mainly use it to read transcripts (plain text format) of Tell Me More from NPR News.
  • Kids Paint: free drawing on screen. My daughter likes it.
  • Listen: podcast client. Integrate subscriptions with Google Reader now.
  • MarketEnabler: for rooted phone only. Useful for purchasing apps when your country is not in official support list.
  • My Tracks: I mainly use it for geotagging now.
  • NetCounter: look up data plan consumption instantly.
  • NewsRob: two-way synchronization with Google Reader. Grab contents for offline consumptions.
  • Places Directory: convenient to search nearby restaurants, banks etc.
  • Real Blackjack: try this one if you want to practice card counting...
  • RMaps: view maps offline.
  • Secrets: store your various passwords, account information here. Have strong security protection.
  • Shopper: shopping program from Google.
  • Shuffle: GTD tool.
  • Sipdroid: SIP client. Can be combined with Google Voice for free calls to US numbers.
  • SpacePhysics: challenging 2D physics game.
  • Swype: fantastic English input method.
  • Twidroid: Twitter client. Supports proxy API.
  • World Weather Clock: I now place two widgets on my home screen: one for home city, another for the destination I'm going to travel.

There are many cool apps that I installed and uninstalled later, because I seldom used them although they are awesome. For example, Layar, Shazam and Google Goggles are just some of them.

Thursday, January 1, 2009

Upgrading SBCL

Recently I upgraded SBCL from version 1.0.22 to 1.0.23. Then my window manager, Stumpwm refused to start. I have to solve the issue, otherwise I will start using console exclusively starting from 2009.

My first reaction was to reinstall stumpwm package. But when compiling, SBCL is complaining that there are version mismatch for stumpwm dependencies. I tried to solve the issue by reinstalling that package, but I met the same problem for its dependencies. I realized that I just stumbled upon dependency hell. I don't want to go through the same process of installing every CL package when I upgrade SBCL. So I need to find one simple solution. Indeed it exists: just delete all *.fasl files in SBCL's site directory (which is /usr/lib/sbcl/site under Arch Linux.), and then SBCL will rebuild all the installed packages. So the following command just solves the problem (assuming Arch Linux).

find /usr/lib/sbcl/site -name "*.fasl" -delete

Update (2009-2-11): do NOT run above command on the parent directory /usr/lib/sbcl, otherwise the fasl files bundled with SBCL will be deleted and many functionalities (e.g. ASDF) will break.

Wednesday, December 24, 2008

Adjusting Photos for Web Albums in Batch Mode

I use Picasa Web Album to store my photos online. To save the precious storage at server, I have to change jpeg files before uploading them even for those taken by my old PowerShot S30 (which outputs photos with resolution 2048x1536, which is beyond the display capacity of most monitors today). To reduce file size, one normally need to reduce both resolution and image quality.

So how to adjust images in batch mode? There are various solutions of course. The one I take is to use the combination of find/xargs/mogrify (Note that mogrify modifies files in place. Therefore one may use convert instead of mogrify to preserve original files.) in Linux. Note that mogrify is one of ImageMagick utilities and may need separate installation depending on distribution. Following is my work flow when publishing images online.

Firstly, I select images with my preferred viewer gthumb. Images are rotated if necessary. During browsing, I copy the chosen files to another folder and run the following command in that folder:

find . -iname "*.jpg" | xargs mogrify -resize resize-option -quality quality-option

(I find the above command from here.)

Several notes regarding the above command:

  • resize-option could be either absolute (e.g. 800x600) or relative (e.g. 50%). For my S30, I use the latter which reduce the photo resolution to 1/4 of its original size.
  • quality-option is JPEG compression level. The larger the value, the better the quality, but the larger the file size. I often set the value as 60 to save space.

So for photos from my S30, I use the following command:

find . -iname "*.jpg" | xargs mogrify -resize 50% -quality 60

After running above command, photo file size can be reduced around 10 times. This means that I can put more images into my web album.

Wednesday, August 20, 2008

W(S)XGA+ Resolution in VirtualBox

Note: this post is related to a workaround for one specific problem encountered by the author.

Recently I switched from coLinux to VirtualBox. VirtualBox provides guest addition which includes enhanced support for Video. Originally it worked fine for me. Due to unknown reason, the problem arises: I could not use resolution 1440x900 (WXGA+) or 1680x1050 (WSXGA+) any more. WXGA+ is the native resolution of my laptop, while WSXGA+ is the resolution of the external LCD when the laptop is placed in a dock. After tweaking for a long time, following is the solution I found so far (I installed Gentoo Linux as guest OS).

1. Revert video driver from VirtualBox to Vesa

This is done by editing /etc/X11/xorg.conf, change one line in Section Device from Driver "vboxvideo" to Driver "vesa".

2. Install support of 1440x900 and 1680x1050 to VESA BIOS

Add parameter vga=864 as Linux bootup parameter (e.g. in /boot/grub/grub.conf) for resolution 1440x900, or vga=865 for 1680x1050.

When Virtual machine is turned off, run the following two commands at Windows command line prompt, assuming virtual machine is named "Gentoo":

VBoxManage setextradata "Gentoo" "CustomeVideoMode1" "1440x900x24"
VBoxManage setextradata "Gentoo" "CustomeVideoMode2" "1680x1050x24"

Start virtual machine, select resolution 1440x900 or 1680x1050 for console display. Note that the resolution for console is not necessarily the same resolution for X, i.e. you can use 1440x900 for console, and 1680x1050 for X.

3. Add modelines for resolution 1440x900 and 1680x1050.

I use gtf to generate needed modelines. For example for resolution 1440x900 with 60 Hz refresh rate, I use the following command:

$ gtf 1440 900 60

which give the following line:

  Modeline "1440x900_60.00"  106.47  1440 1520 1672 1904  900 901 904 932  -HSync +Vsync

I do not like the suffix _60.00, therefore what finally end up in section Monitor of /etc/X11/xorg.conf is (with addition of modeline for 1680x1050):

 modeline "1440x900" 106.47 1440 1520 1672 1904 900 901 904 932 -HSync +Vsync
 modeline  "1680x1050"  147.14  1680 1784 1968 2256  1050 1051 1054 1087  -HSync +Vsync

In addition, the two modes should be added in section Screen of /etc/X11/xorg.conf as well, my current setting is:

Section "Screen"
 Identifier "Screen0"
 Device     "Card0"
 Monitor    "Monitor0"
 DefaultDepth     24
 SubSection "Display"
  Viewport   0 0
  Depth     24
  Modes    "1680x1050" "1440x900"
 EndSubSection
EndSection

4. Select the resolution

Now the toughest part. You may have noticed that in section Monitor, there are two lines about HorizSync and VertRefresh. After experimenting, my conclusion is that one should comment out them when using 1680x1050 while enable them for 1440x900. Weird.

Since I need to switch between these two resolutions frequently, manually editing file /etc/X11/xorg.conf is boring. Therefore I write one script to automate the task. I named the script as xres and invoke it as sudo xres 1440 for resolution 1440x900 and sudo xres 1680 for 1680x1050. Following is its content:

#!/bin/bash
case $1 in
    1440)
        sed -i 's/^#    HorizSync    31.5 - 64.3/       HorizSync    31.5 - 64.3/' /etc/X11/xorg.conf
        sed -i 's/^#    VertRefresh  50.0 - 70.0/       VertRefresh  50.0 - 70.0/' /etc/X11/xorg.conf
        ;;
    1680)
        sed -i 's/^     HorizSync    31.5 - 64.3/#      HorizSync    31.5 - 64.3/' /etc/X11/xorg.conf
        sed -i 's/^     VertRefresh  50.0 - 70.0/#      VertRefresh  50.0 - 70.0/' /etc/X11/xorg.conf
        ;;
    *)
        echo "Supported horizontal resolution: 1440 and 1680."
        exit
        ;;
esac

Thursday, July 24, 2008

Experiencing Stumpwm

What Emacs is to editors, Stumpwm is to window managers.
--Bill Clementson (link)

Introduction

Recently I switched from GNOME to Stumpwm (wiki), which means that I jumped out of a desktop environment to a simple window manager. So far, I'm very satisfied with such a change and never looked back. Stumpwm, as its website says, is a tiling, keyboard driven X11 Window Manager written entirely in Common Lisp. This definition summarizes the reasons why Stumpwm is so suitable for me.

First, Stumpwm is a tiling, keyboard driven window manager. This is very useful to boost productivity. When working, it is desirable to minimize context switching. Tilting combined with keyboard driven enables working with several applications simultaneously as if your are dealing with one single program. Let me give an example. As described in previous post, with Emacs as development environment, it is easy to fire up one browser within Emacs itself to preview blog post. However it is painful to switch between Emacs and browser. Before using Stumpwm, I am considering ways to integrate Emacs and Firefox together. With Stumpwm, such dream is just trivial to fulfill: one can show Emacs and browser side by side, with a few keystrokes to switch between them. Everytime you make changes in Emacs and request the results to be shown in Firefox, they are shown simultaneously. No more need to leave your hand for mouse to click back and forth between Emacs and Firefox. This gives you the feeling of integrated environment. Note that I just use Emacs and Firefox as an example, and such convenience is applicable for every application. Currently, the problem is that I'm so accustomed to Stumpwm keystrokes that I somehow confused the keystrokes of switching between windows in Stumpwm and Emacs!

Second, Stumpwm is written in Common Lisp. which means that you can build Stumpwm with your favorite CL implementation and you have a Lisp runtime when you work under Stumpwm. A powerful programming language is just embedded within your window manager and you can invoke it at any time. The other benefit is that you can configure your window manager as you like, even when it is running!

You may get a feeling on how Stumpwm works by watching this nice video.

Installation

Given the above lengthy introduction of Stumpwm, you may wonder how to install this gem. Here we assume that you have some knowledge about Common Lisp. Basically, installing Stumpwm is to compile it with your preferred CL implementation, and tell your system to run Stumpwm as your window manager.

Installing Stumpwm on Gentoo Linux is straightforward. Throughout this section, we will assume that SBCL is the CL implementation. Stumpwm website suggests turn off threading support in SBCL (disable USE flag threads) for better performance. To install, simply type emerge stumpwm. Note that at the time of writing, there is also an ebuild called stumpwm-cvs. Simply ignore it since it is actually a very old version, not the bleeding edge version suggested by its name. Advanced users might consider to get git version for latest cool features.

There are mainly two ways to invoke Stumpwm. One is to run it by calling SBCL, the other is to dump a core image containing Stumpwm within SBCL and invoke that image. We will take the latter approach. To proceed, first start SBCL by typing sbcl. Next issue the following in REPL sequentially:

(asdf:oos 'asdf:load-op :stumpwm)
(sb-ext:save-lisp-and-die "stumpwm" :executable t
                          :toplevel #'(lambda () (stumpwm:stumpwm ":0")))

Next, put the generated executable stumpwm somewhere in PATH (I put it under /usr/local/bin). Since I always start X Window by typing startx, following command is used to use Stumpwm as my window manager:

$ echo "exec stumpwm" >> ~/.xinitrc

Using Stumpwm

Configuration

All stumpwm configurations are stored in file ~/.stumpwmrc, which is written in Common Lisp. Just like .emacs, this file allows you to fully customize Stumpwm. Following is my current configuration:

;;;; -*- Mode: Lisp -*-

(in-package :stumpwm)

;; Load swank.
(load "/usr/share/emacs/site-lisp/slime/swank-loader.lisp")
(swank-loader:init)
(define-stumpwm-command "swank" ()
  (setf stumpwm:*top-level-error-action* :break)
  (swank:create-server :port 4005
                       :style swank:*communication-style*
                       :dont-close t)
  (echo-string (current-screen) "Starting swank."))
(define-key *root-map* (kbd "C-s") "swank")       

;; Customize bars and modeline.
(setf *message-window-gravity* :center)
(setf *input-window-gravity* :center)
;; Turn on mode line.
(toggle-mode-line (current-screen) (current-head))
(setf *screen-mode-line-format* 
      (list "%w | "
            '(:eval (run-shell-command "date | tr -d '[:cntrl:]'" t))))

(set-prefix-key (kbd "C-i"))
(define-key *root-map* (kbd "c") 
  "exec urxvt +sb -fn \"xft:Bitstream Vera Sans Mono:pixelsize=20\"")

(define-stumpwm-command "firefox" ()
  "Run or switch to firefox."
  (run-or-raise "firefox" '(:class "Firefox")))
(define-key *root-map* (kbd "f") "firefox")

Some explanations of my configuration:

  • Prefix key: I use C-i instead of default C-t. The reason is that C-t is used in Firefox to open a new tab and also in Emacs for transpose. Then why choose C-i? I'd like to admit that it is quite difficult to select a prefix key for Emacs user. Before settle down on C-i, I fired up Emacs to see whether there is any key binding C-x where x from a to z is not used by Emacs. Unfortunately (fortunately?), Emacs binds every combination. So I can only choose one prefix key which is easy to type and I uses infrequently in Emacs. Then C-i is selected. Note that you can send C-i to application like Emacs by typing C-i i. For the following sections, please replace C-i with your favorite prefix key.
  • SLIME: the section staring with comments Load swank provides ways to load swank. Type C-i C-s to start swank. To connect to swank, simply run Emacs, and type slime-connect within Emacs, and type RET and RET to accept default host (127.0.0.1) and default port (4005). Then you can play with Stumpwm as you wish: change parameters, add your own functions etc. Note that I do not start swank automatically for security reasons.
  • Key bindings: I use C-i c to start console: urxvt instead of xterm. Note that I have also set the font for urxvt. In addition I have setup using C-i f to start Firefox in case Firefox is not started, or bring Firefox window to front if it is already running.

Key Bindings

Following is a list of key bindings I used frequently. For simplicity, I have omitted the prefix key.

  • ?: Stumpwm help
  • ;: Run Stumpwm commands
  • :: Send commands to Common Lisp interpreter.
  • Space: Go to next window
  • c: Run X terminal
  • e: Run Emacs or raise it if it is already running
  • f: Run Firefox or raise it if it is already running
  • k: Kill current window
  • g c: Create a new group
  • g k: Kill current group
  • g m: Move current window to a specified group
  • g Space: Next group
  • o: Focus shifts to next frame
  • Q: Remove all splits
  • s: Vertical split
  • S: Horizontal split