Computing

My Eee PC 4G (701)

My lovely Eee PC

I bought an Eee PC [eeepc.asus.com] 4G (701) last month and had been playing and using it. It is quite a lovely machine.

I have also installed Ubuntu 7.10 on it, and make all peripherals (except the modem) to function properly. There are a lot of good resources online, including the excellent EeeUser.com. I will install Xubuntu 8.04 on it when it is officially released next week, and write an installation HOWTO if time permits.

cdlock: CD/DVD Drive Door Locking Control

CD/DVD Drives

1. What is This?

cdlock includes utilities for locking and unlocking the door of your CD/DVD drives. Once the door is locked, you should not be able to eject the tray by pressing the 'Eject' button located at the front side of the drive (even the tray is empty). It works on Linux with 2.6.x kernel.

Scroll down for technical notes. I implemented this to guard my DVD drive!

2. Source Code

cdlock-0.1.tar.bz2

To install it, simply do:

\$ make && sudo make install

The code is distributed under the terms of GPL.

3. Usage

To lock the door of a CD/DVD drive:

\$ cdlock [<device>]

The program assumes /dev/cdrom by default. The program returns zero if and only if it does not detect any error.

To unlock the door:

\$ cdunlock [<device>]

4. Technical Notes

The program is so simple and it basically does an ioctl() with CDROM_LOCKDOOR. I write this because I fail to find a handy utility just to do this simple task. Tell me if you are aware of any utility that has included this feature, or you want to include this program under the umbrella of a more sophisticated and GPL-compatible software.

I have tested the program with three CD/DVD drives. All of them work in the sense that, once I have run the utility to lock the door, the function of the 'Eject' button is virtually disabled. However, there are some weird behaviors I do not understand yet:

  • On some computers, the eject command fails to eject the tray after I have locked the door. Good. But while I expect eject to return 1 since the operation has failed, it returns 0 instead. Is it a feature or a bug?
  • I use DVD writers of the same model (LITE-ON DVDRW SOHW-1673S) on two different computers instead with Ubuntu 7.10. After locking the drives' doors, I can eject successfully on one computer but fail on another. Why is it so? I don't think I have change any setting related to the drives. Is there anything to do with the IDE cables?

Tell me if you know the answers.

Final Fight Against OOXML

Microsoft just lost the vote on OOXML! However, the war is not over yet. (For details, see the news coverage at http://www.noooxml.org/) ISO has decided to move forward to a Board Resolution Meeting from February 25-29, 2008.

We just DON'T NEED OOXML!

Say NO! to OOXML

Say NO to OOXML

A hot topic the software community is talking about these days is about OOXML [en.wikipedia.org]. What is OOXML? Simply put, it is a file specification developed by Microsoft and is currently used by MS Office 2007. Instead of giving full support to the existing OpenDocument [en.wikipedia.org] ISO standard (with 700+ pages for OpenDocument 1.1), Microsoft proposes to make its OOXML (with a 6000+ pages long proposal) an ISO standard.

So what is the problem?

Countless. The standard proposal is not open: It was not created by a group of interested parties but by Microsoft alone. Since there is already the OpenDocument standard (which is already supported by OpenOffice.org, a free multiplatform and multilingual office suite), a dual standard adds costs and confusion. More importantly, OOXML is technically flawed: It has internal inconsistencies, uses non-standard conventions (which conflict with some existing ISO standards), has some inflexible formats, has ill-formatted XML examples, has errors in spreadsheet formula specifications (for example, it forbids any date before year 1900, also a bug found in MS Excel), etc.

So, we just DON'T NEED OOXML! You can find more information about objecting OOXML at NoOOXML. Currently, the format is undergoing a standardization process within the ISO. There are politics and dirty tricks in the voting process. For example, it was suspected that Microsoft bought the Swedish vote, and Microsoft admitted it! (See this [www.os2world.com], this [www.computerworld.com], this [www.groklaw.net], this [news.zdnet.co.uk].) As a result, the Swedish vote has been declared void.

What can you do? Spread the words, sign a petition here [www.noooxml.org], and make the world a better place!

Wonderful Talks about Free Software and Copyright

I have listened to the recordings of two fantastic talks about free software and copyright by two respected authorities—Richard Stallman and Eben Moglen. I would highly recommend the talks to those who are interested in knowing more about free software, GPLv3, the evolution of copyright, etc.

Copyright vs Community in the Age of Computer Networks by Richard Stallman
Hosted by University of Waterloo Computer Science Club
Audio (OGG) [www.csclub.uwaterloo.ca].

The Global Software Industry in Transformation: After GPLv3 by Eben Moglen
Hosted by The Scottish Society of Computers and Law in Edinburgh, Scotland
Text [www.archive.org]; Audio (MP3) [www.archive.org]; Video [www.archive.org].

My Computers

1. My Home Desktop

1.1. Hardware

1.2. Software

Operating System Xubuntu Linux 8.04 Hardy Heron Microsoft Windows 2000
Usage More than 99.9% Less than 0.1% (Almost exclusively for gaming only)
Main Uses Surf websites; Check e-mails; Write programs; Watch movies; etc. Play games only for Windows (and don't run on wine); Surf IE-only websites
Firewall Protected by NAT behind a modem router
Anti-Virus (Not required) AVG Anti-Virus Free
Defragmentation (Not required) Windows Disk Defragmenter
Web Browser Firefox Firefox; IE6
Office Suite Open Office; Gnumeric (Not used here)
Image Manipulation GIMP

1.3. Various Configurations

~/.emacs

My current favorite:

;; Colors
(set-foreground-color "white")
(set-background-color "black")
(set-mouse-color "lightgreen")
(set-border-color "blue")
(set-cursor-color "yellow")

;; Tabbing
; Don't use tab if possible!
(setq-default indent-tabs-mode nil)
; Sometimes tabs are unavoidable, such as editing Makefile. Set the width.
(setq-default tab-width 4)

;; Extra mappings from file extensions to major modes
(add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))

;; Miscellaneous
(load-library "php-mode")

;; Syntax Highlighting
; Turn on the font-lock (minor) mode whenever it's supported
;(when (fboundp 'global-font-lock-mode)
;  (global-font-lock-mode t))

;; Selections
;(setq transient-mark-mode t)

;; Enable all features in the 'mule-ucs' package
;(require 'un-define)
~/.bashrc

I like to add the following lines:

# (Already in the default .bashrc, just need to uncomment these:)
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# Useful environment variables
export PS1='[\u@\h \A \w]\\$ '
export PATH=\$PATH:/sbin:/usr/sbin:\$HOME/local/bin
export EDITOR=vi

export HISTTIMEFORMAT="%Y-%m-%d %H:%M "
export HISTFILESIZE=100000
export HISTSIZE=100000

export PATH=$PATH:./
~/.bash_aliases
alias cp='cp -i'
alias rm='rm -i'
alias mv='mv -i'
alias emacs='emacs -font 9x15'
~/.mplayer/config
# Display
subcp=utf-8
font=/usr/share/fonts/truetype/arphic/ukai.ttc
utf8=yes
subfont-autoscale=2
subfont-osd-scale=2
subfont-text-scale=3
sub-fuzziness=1
# Miscellaneous
idx=1

Fix the latex2html Black Line and PNG Transparency Bugs

The latex2html program is a wonderful and popular package for converting LaTeX to HTML. However, it suffers from a black line and a PNG transparency bug even with the latest version 2002-2-1 (1.71). You should be able to reproduce the bugs and use the workaround below in Ubuntu 6.10.

The Black Line and PNG Transparency Bugs

Try to create the following bugs.tex and then use latex2html to convert it:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\cos^2\theta+\sin^2\theta &= 1, \\
\cosh^2\omega-\sinh^2\omega &= 1.
\end{align}
\end{document}

Point your browser to bugs/index.html, and you may see something like this:

An illustration of the latex2html black line and PNG transparency bugs

Look at the ugly black borders and the grey background. The black lines appear in some images regardless of the image type (either GIF or PNG) you use. (Note: You can select the image type by passing the -image_type gif or -image_type png option.) It seems to appear only when I use the amsmath packpage, so the programming bug probably resides in amsmath.perl. Besides, some PNG images don't have a transparent background.

The Workaround

If you use the GIF format, you can refer to the solutions (here and here) by Clay S. Didier. To fix PNG images, you can use my workaround below, which is partly based on Clay S. Didier's idea. I personally recommend sticking to the PNG format because it is technical superior for such equations, and does not suffer from any patent problem like GIF does. (See the League for Programming Freedom GIF page for details.)

The workaround fixes the problems by post-processing the problematic PNG images generated by the latex2html. Create the following the eqnfix.shscript for fixing the images. Note that the script depends on some PNM utilities. In Ubuntu, they can be installed from the official netpbm package.

#!/bin/sh
# Fix the latex2html black line and PNG transparency bugs
#
# After latex2html has generated the PNG images, run this script
# for each directory that holds the problematic PNG images.
#
# Changes:
#   11-Jan-07: Included a fix for PNG transparency and some small improvements
#   15-Sep-05: Created this script

# Get the directory path
if [ -z "\$1" ]; then
  cat <<EOF
Fix the latex2html black line and PNG transparency bugs.
Usage: \$0 <directory_with_problematic_PNG_images>
EOF
  exit
fi

# Fix each PNG image
for file in \$1/*.png
do
  echo Fixing \$file...
  pngtopnm $file | \
    pnmcrop -black | \
    pnmtopng -transparent "#B3B3B3" > img_fixed.png
  mv -f img_fixed.png \$file
done

Simply invoke the script for each directory that holds the problematic PNG images. For the example above:

\$ latex2html bugs.tex
...omitted...
\$ eqnfix.sh bugs
Fixing bugs/img1.png...
pnmtopng: 16 colors found
Fixing bugs/img2.png...
pnmtopng: 11 colors found
Fixing bugs/img3.png...
pnmtopng: 17 colors found
Fixing bugs/img4.png...
pnmtopng: 9 colors found

After running the script, you should see the following in your browser now:

After fixing the problematic PNG images generated by latex2html

It's obviously what you want, right?

Remarks

The fix above post-processes the PNG images and is thus not a really proper solution. The fix can fail in some rare situations if you play around with the colors of the font and the background. The best solution is to fix the source code of latex2html directly. It can be tedious to fix the bug, and I'm also not an expert in latex2html source and Perl. Please share if you have a better solution. Your feedbacks are welcomed.

Syndicate content