Wednesday, November 19, 2008

Opera and SCIM...

How to use the SimpleChineseInputMethod with Opera on Linux:

Just add the following lines to your /usr/bin/opera file:

# Activate Chinese input
export LANGUAGE="de"
export LANG="de_DE.UTF-8"
export LC_CTYPE="zh_TW.UTF-8"


Actually you only need to set the LC_CTYPE variable... but anyway ;-)

Wednesday, November 12, 2008

Strange behavior with mplayer

I mainly use a 32" flat screen tv to watch my anime series... but sadly, the resolution of this nice piece of hardware is lower than the resolution of my every-day-use 19" monitor. 1366x768 compared to 1440x900.

After fiddeling around some time I found that cloning the main monitor's output with nvidia's Twinview option would leave me with a still quite reasonable performance on my desktop and still offer the possibility to 'view things' on my tv.

I set up a "TVtime" nautilus-actions with path

mplayer -fs -ass -xy 768

and parameter

%d/%f

Bad thing is that now *every* movie on the main screen is played with a 786 resolution... even if I don't use 'TVtime' or if I start my movies with -xy 1440. The window size is ok, but when I switch to fullscreen *zang*... probably a bug in LinuxMint/Ubuntu's MPlayer 1.0rc2 and/or compiz' fullscreen hint. (Just a hunch.) Anyhow, an unbearable situation.

To get past this I modified the menu entries for MPlayer a bit, using the X11 video output and -zoom option:

gmplayer -vo x11 -zoom %F

Performance is still very good, in spite of the use of software scaling (-zoom). And I never ended up with more than 65% CPU usage on an aged E6300 system with real 1080p encoded x264 material running a bunch of normal apps in the background.

Just a reminder to myself...

Sunday, September 14, 2008

Linux Mint - SCIM

Here I'll just try to present an easy and simple method to help any user set up SCIM in Linux Mint, an Ubuntu variant I found a couple of weeks ago...

Most of this little guide is found in the official Ubuntu Documentation at https://help.ubuntu.com/community/SCIM, but there are some small changes, as I don't need the full Chinese language pack (e.g. GIMP and OpenOffice's Chinese documentation...). So if you're using a western system and just want to input and display Chinese (for Japanese etc. just change the language code, ja instead of zh) this guide is for you. Let's start:

First of all you have to install the Chinese language support. Just type

sudo apt-get install language-support-input-zh language-support-fonts-zh

in the terminal and press Enter or install these packages via the Package Manager.

Since Linux Mint doesn't have the scim-bridge-client installed by default you have to install it, too. Type

sudo apt-get install scim-bridge-client-gtk

This will install the scim-bridge-client-gtk (for Gnome) and scim-bridge-agent.

Now we just have switch the Input Method on the X Windows System (Gnome)...
One last step, and you're ready to go:

Type

locale |grep LANG

This will display your locale. For example, Spanish (Spain) is "es_ES.UTF-8"

then type

im-switch -z (your locale) -s scim-bridge

for example

im-switch -z de_DE.UTF-8 -s scim-bridge

Voilà!

To use your shiny new input method right away simply restart X. ()

Wednesday, March 19, 2008

gawk vs. mawk und Konsorten

A co-worker of mine somehow lost (deleted?) her e-mails... at least some of them quite important. As it turned out, three months worth of mail mysteriously vanished from her Thunderbird Inbox.

A quick search on the internet revealed a nice little article "Restore Deleted Email in Thunderbird" on jivebay. Exactly what I needed! The only problem: My co-worker's Inbox wasn't just "over 90MB", it was about 850MB. So even my favorite Windows text editor (for those who want to know: It's JujuEdit - can handle very! large files, has support for regular expressions, among other goodies, and is freeware) couldn't handle a job like this in a reasonable amount of time. As far as I recall JujuEdit would have worked for about 2~3 hours to replace all the 'X-Mozilla-Status: xxxx's with zeros.

I decided to have a look at some command line tools from the UNIX/Linux world: awk and sed, both designed to process text-based data (like the Thunderbird mbox files). And after a while studying the sed and awk syntax I ended up with two perfectly working 'one-line scripts'.

Both versions work as expected, but they differ in execution time, and this is - at last - why I'm writing this... a short and completely fragmentary speed comparison between some text-processing tools.

The scripts:

awk '/^X-Mozilla-Status: [0-9]*/ {gsub($2, "0000\r")} {print}' Inbox > NewIn

sed -e 's/^X-Mozilla-Status: [0-9]\{4\}/X-Mozilla-Status: 0000/' Inbox > NewIn

I 'time'd both snippets several times on a (Ubuntu) Linux box and this is what I've got:

(m)awk: ~50s
sed: ~1m40s
JujuEdit (Windows): approx. 3 hours

I know, my testing environment is somewhat unique and the results are not really representative, but IMHO impressive none the less.

This way I found out that Ubuntu's standard awk is in fact mawk, and that mawk is (in this special case) about twice as fast as sed... even though awk is a full blown programming language and sed 'just' a Unix utility.

Today I added GNU awk (gawk) and, of course, Perl to my little test suite, and tried it on my own Inbox (about 160MB) in a small VM Ubuntu installation.
The gawk code snippet is similar to the awk version, the Perl line looks like this:

perl -w -p -e 's/X-Mozilla-Status: [0-9]{4}/X-Mozilla-Status: 0000/' Inbox > NewIn

mawk: ~25s
Perl: ~26s
sed: ~35s
gawk: ~40s

My conclusion:
  • mawk is indeed a very fast implementation of awk.
  • I couldn't get the quantifier / repetition operator {} work in awk.
  • Perl is such a nice thing to have.
  • I still like Linux.
Just my two cents.

It is possible, or even likely, that I made some mistakes here. Comments are welcome, I'm eager to learn... BTW, I'm well aware that zeroing out the Mozilla-Status is not the perfect solution to get deleted mails back, changing 0008 to 0000 or 0001 should do the trick.

Useful links: