Saturday, July 12, 2008

How to install XP SP2 on HP mininote

Installing XP on an HP mini-note is a very challenging process if you don't know how to do it. Below are the key steps:

  1. Shrink the preloaded Vista partition. For example, boot with the System Rescue CD, type startx to enter X11 and run gparted to do it graphically. Easy.
  2. If you go ahead to install it using the XP CDROM, setup will fail with a BSOD (blue screen of death) with error code 0x0000007b after loading its builtin drivers. This is because XP SP2 needs a VIA chipset driver in order to properly access the SATA disk in protected mode. To fix this problem, boot into Vista, download and unpack the VIA chipset driver from HP. There is a sub-folder named "driver" and that's what you need. Copy the XP files from the CD, use nLite and try merge the drivers into the files (tell it to load all the drivers found in that "driver" folder and then exclude inappropriate ones such as the 64bit ones), make a new iso image and burn it into another CD. To burn an ISO image, follow these steps.
  3. Use that CD to boot and install XP.
  4. Now, you can only boot into XP but not Vista because XP has taken over the MBR. To fix the problem, follow these instructions to restore the Vista boot manager.

Sunday, June 29, 2008

How I got over the hurdles to migrate from XP to Kubuntu 8.04

Why installed Kubuntu?

Short answer: I planned to plugin my XP hard disk on a new computer, but it didn't work. At the same time I had always been thinking about the idea of switching to Linux as my home major desktop one day, as I mainly do Java development and writing (OpenOffice) at home. Why KDE instead of Gnome? I always like KDE.

Long answer: My original computer hardware failed to boot. As I have an existing retail copy of XP, so I ordered a Dell computer without an OS (N-series. BTW, the N-series are not available on their Hong Kong web site, you have to contact a salesperson using the instant-messaging to get a custom quotation. BTW, the salesperson was very efficient & helpful. Do not try to contact pre-sales using emails. I got no reply at all). On arrival I found that it has only the SATA interface, so I couldn't put my existing IDE hard disk with XP nor my existing CDRW drive into it and thus it couldn't boot. The only way to install an OS on it immediately was PXE. I don't know if XP can be installed like that, but I had done it with Ubuntu at work.

Network install

So I set up a TFTP & DHCP server on my brother's XP computer to start a network install of Ubuntu according to this article. It was easy and took less than 10 minutes in setup. I had to enable PXE in BIOS (by default it was disabled).

Do NOT use Kubuntu 64bit nor KDE4

At first I chose to install Kubuntu 64bit and KDE4. But later reinstalled using Kubuntu 32 and KDE 3.5.

64bit is not going to speed up anything as my computer has 2G (64bit is good only if >4G & you have programs using 64bit pointers, otherwise you're just wasting the memory by storing 32bit points in 64bit cell). In addition, 64bit versions of the software just aren't as stable as 32bit ones. For example, 64bit OpenOffice can't find the JRE.

KDE4 is unstable as hell. A lot of crashes in here and there in all KDE applications (adept, network manager, user manager, etc). Help indexing doesn't work. Network manager failed to connect and crashed. Some software requires user interaction during install such as agreeing to the JDK license, but adept will not show you that so you are left wondering why the progress is stuck at a certain point. Even if you tell it to show you the details, somehow the text interface is not working. When editing user accounts in the user manager, it sets the uid of users to 0 (root)!

Don't think that KDE3.5 is old. It is very modern, powerful, beautiful and rock solid. Never had a single crash.  For me it can do everything that Windows can do in terms of a desktop environment.

Making the keypad work like Windows

I am used to the arrow keys in the keypad. In Kubuntu, they also work. But if the Shift key is pressed, they will input digits. To make them act as shift-arrow, I had to enable an option in the "regional & language" GUI (NOT the keyboard GUI!) that says "Shift with numeric keys works as in MS Windows" on the "Xkb Options" tab.

Ugly font in Firefox

You'll see ugly font in many web pages in Firefox. This is because the use of the helvetica font. Ubuntu maps it to the nimbus font using fontconfig. However, the nimbus font looks good in printing but ugly on screen. The easy solution is to turn on auto hinting for the fonts and sub pixel anti-aliasing (I don't know exactly what they mean though). To set it for each user, it can be done in the GUI. To set it for the whole system, I manipulated the symlinks in /etc/fonts/conf.d. I added 10-antialias.conf, 10-hinting-full.conf and 10-sub-pixel-rgb.conf from the /etc/fonts/conf.avail folder.

MS core fonts

I have OpenOffice documents using the Arial and courier fonts. They look completely different in Kubuntu due to the lack of such fonts. The best way to fix this problem is to install the MS core fonts. Just google and you'll find the details.

Making English the default locale for me

To allow my family members to use the computer, I chose Chinese as the system wide default language (LANG and LANGUAGE). For myself, I want English. This can be done easily using the KDE GUI (regional & language). However, it doesn't modify LANG (I don't know where it changes) and only works for KDE applications. Gnome applications such as Firefox & OpenOffice look at LANG and still display their UI in Chinese. To fix the problem, I had to modify .xsessionrc:

export LANG=en_US.UTF-8
export LANGUAGE=en

Inputing Chinese in the English locale

Even though I use mainly the English in my work, I still need to input Chinese from time to time. By default the en locale uses xim which doesn't work with Chinese. I had to configure it to use scim. This is managed by the "alternatives" mechanism in Ubuntu:

update-alternatives --config xinput-all_ALL

Using the Chinese version of KDE for family members

My family members will need the Chinese version of KDE. This can be done by choosing Chinese in the KDE GUI. However, Chinese will be unavailable for selection until you install some packages:

aptitude install kde-i18n-zhtw

Installing the Flash player

You need to install the flashplugin-nonfree package.

Enabling CPU frequency scaling

To save energy, basically I followed this article. I enabled CPU frequency scaling in the BIOS and add acpi_cpufreq to /etc/modules. I don't need th put any of the governor into the modules file though. By default the governor is "ondemand" which should be good for most people.

Directory tree in the file manager

I really wanted to get back the Windows explorer style file manager: the directory tree on the left hand side. Konqueror has this function: a view profile named "File Management". To launch it with this profile, create a shortcut with command line:

kfmclient openProfile filemanagement

MIT Scratch

I've been using MIT Scratch to teach my niece programming. Even though it is written in squeak and squeak is available for Ubuntu, it won't run due to the missing ALSA sound plugin. The easiest way to fix it is to run it in wine.

Games

My dad was running two Chinese chess games in XP. Only one of them runs in wine (in the process I needed to download DLLs such as the VB runtime or MSVC runtime. Just google for them). I can't find any good Chinese chess games that can run on Linux (including Java).

My mom wants to play MahJong. I found a flash MahJong game that runs fine in Firefox.

Web authoring

I was using Nvu in XP. In Kubuntu, I installed Quanta plus. It works quite well.

Online backup

I was using Mozy which has worked very well. Because it has no Linux client, I am going to switch to spideroak. Don't know if it works or not yet.

Ctrl-F11 in Eclipse doesn't work

I am used to pressing Ctrl-F11 in Eclipse to re-run the last program. In Kubuntu it doesn't work because it is the shortcut to switch to the 11th virtual desktop. To fix it, go into the keyboard GUI and choose the "shortcut sequences" and set the shortcut to none.

Conclusion

Overall I find that Kubuntu needs a few critical tweaks before it is useable by end users, in particular, in the CJK market. Such tweaks are not very well documented and take quite some serious research efforts, even for an experienced Linux/Ubuntu server administrator. However, once it is tweaked, it is fast, rock solid, powerful and cool. Some applications may be unavailable (eg, games, Mozy) and limited in capabilities.

Friday, March 21, 2008

Why people hate Tapestry (or even Howard)

Recently I've seen quite some people expressing their hatred towards Tapestry or Howard (eg, on theServerSide, on the Tapestry mailing list, blogs). Admittedly I made a mistake by recommending Tapestry to quite some people and organizations in Macau and now they're stuck with T4, however, objectively speaking, it is not the fault of Howard or Tapestry. Every one of us should take the responsibility for carefully evaluating any given technology before adoption, including its track record of compatibility and etc.

After all, all Howard did was to release his code for others to use for free under the Apache license. Presumably this is good will. In addition the Apache license clearly says there is no warranty of any kind. It's up to us to decide to use it or not. Sure, Howard might have made promises that he might be unable to meet ("This should finally crack the backwards compatibility nut, allowing you to have great assurance that you can upgrade to future releases of Tapestry without breaking your existing applications."). But everyone is entitled to publish his own objective and there is simply no guarantee that it will be realized. I guess some people are angry because they think they were tricked. However, I still think it is the responsibility of the technology evaluator to look for facts, not promises. There is no way to tell whether someone is lying or just wishful thinking. Ultimately, we are free to adopt something or not and it is our sole responsibility, be it commercial or open source.

Why is this an imporant issue? We, technology evaluators, must recognize our own mistakes in order to avoid repeating it in the future.

Tuesday, October 9, 2007

Applying scala to solving real world problems

Scala is no doubt an excellent language. However, problems like 8-queen or quick sort in the scala doc just aren't  convincing to software professionals in the industry. So I'd like to show how to apply it to solving real world problems in Java. Here let's consider the logging problem in Java. Usually people write code like:

        if (log.isDebugEnabled())
        {
            log.debug("Foo is: " + foo);
        }

Why check isDebugEnabled() if the log object will not log the message if debug is not enabled? This is for performance. If we didn't have this check, the toString() would always be called on foo and the result would always be appended to "Foo is:" to form a new string, even when debug was not enabled.

Scala can easily solve this problem using called-by-name parameters:

class Log {
  var isDebugEnabled: Boolean = false;
 
  def debug(msg: => String) {  //msg is a string expression that is unevaluated
    if (isDebugEnabled) {
      System.out.println(msg); //evaluate msg as if it is a function
    }
  }
}

Now you call this method and provide an expression and it won't be evaluated unless debug is enabled:

    val log: Log = new Log();
    var foo: Int = 123;
    log.debug("Foo is:"+foo); //won't be evaluated
    log.isDebugEnabled = true;
    log.debug("Foo is:"+foo); //will be evaluated inside the debug() method

Tuesday, September 25, 2007

My thoughts on the differences between Tapestry and Wicket

After working with both Tapestry (3.x, 4.x and some alpha versions of T5 and as a committer) and Wicket (1.2x and 1.3 betas), below is the differences that I found:

Genius vs developer community

In Tapestry, it is Howard who writes most of the code and makes the final decision. There are a few committers but they are either working on T4 which is going to be superseded by T5 or just fixing bugs or writing documentation. I believe this is because Howard is such a genius in programming that few committer is up to a level to technically challenge him. In addition, as he wrote most of the code, naturally he gets the final say. But most importantly, I think it is because star programmers normally aren't good project managers. When I was a committer in Tapestry, I always wanted Howard to take more on a role of articulating and sharing his vision of T5, inviting active code committers and reviewing their code instead of writing his own (like Linus does with Linux). It seemed that I didn't succeed. Maybe he believes it takes less time to write code than relying on others to implement his vision, after all not many people are smart enough to understand his vision, not to mention to write high qualify code as he.

In Wicket, decisions are always made by technical discussions among the many active committers (8 or so) and then a vote. Those committers are active in the sense that they wrote and maintain significant parts of Wicket (e.g., core, unit testing framework, portlet, ajax). The creator of Wicket is no longer the most active code contributor. In fact I once saw him asking others on the mailing list how a part of Wicket worked!

Performance vs ease of use

A major design goal of Tapestry is high performance. In fact, Howard reserves T5 and Java for situations when high performance is required, while dynamic languages should be used for the rest. This design goal leads to the decision that 1) page objects should be pooled and are stateless as the state is maintained separately. 2) a component can generate multiple element in the output and therefore the component tree is vastly different from the element tree generated.

In Wicket, performance is not a design goal. Instead, it is the ease of use. This leads to the decision that 1) page objects are stateful and 2) there is a direct one-to-one mapping between the component tree and the element tree generated. These differences make it very easy to learn Wicket, to create Wicket pages and to understand how a Wicket application works, at the cost of heavier use of the session. In addition, this also supports the Back button transparently in Wicket as each page in the browser corresponds to a unique page object in the session. In Tapestry, one could use client persistence to store the state to achieve a similar effect. However, client side state is insecure by nature.

Expressive power vs conceptual familiarity

Just like other world class programmers, Howard favors the ultimate power of expression. That is, he hates any kind of duplication or any boileterplate code. Therefore, one can find a lot of domain specific languages in Tapestry and a lot of automatic magic running to free the programmer from any chore.

In Wicket, everything except the HTML code is done in Java. Plain old Java, not a domain specific language built on topic of Java annotations. There is more boilerplate code, but the programmer will get first class tool support (content assist), compile time checking, refactoring, API doc generation and access and etc. More importantly, it is a lot easier to learn because there is no new concept/language to learn (e.g., a listener in Tapestry is just a plain Java abstract method in Wicket, a validator in Tapestry is just a Java object in Wicket). The use of domain specific language also creates a barrier for functional enhancements. One has to build the function itself and then enhance the parser.

Code quality vs functionality

I've never seen any code that is as good quality as the Tapestry code. The Wicket code just won't compare! One can easily find duplicate code, untestable code due to the extensive use of concrete classes instead of interface, classes having specific logic to handle some specific arguments if they along to a certain classes (fragile) and etc.

Is this a bad thing for Wicket? Yes in a sense. However, this is the result of having a lot of code contributors, including those who are not genius but have a strong itch and the ability to code a solution. So the other side of the story is that Wicket tend to have more working functions than Tapestry (tree component, more ajax functions, modal dialog, dynamic images, wizard. role based authorization, captcha, breadcrumb, ...).

Technology driven vs user driven

Howard strives to create a framework that is technically excellent so to attract users. However, users can seldom persuade Howard on what is good for them. The Wicket team seems to listen to the users on what they want.

Technical advances vs version compatibility

I felt Howard, as a technical genius, has an unstoppable urge and unlimited energy to improve the Tapstry code. Therefore, whenever he sees a technical advance that can improve the code quality, he can't wait to adopt it (T3=>T4 using IoC; T4=>T5 using annotations replacing for XML and convention over configuration), hoping to deliver an excellent shiny new framework for users to enjoy, while leaving the old incompatible version behind.

The Wicket team on the other hand favors version compatibility more than technical advances.

Final words

So, which is better for you? It's up to you to decide. I've written a book on Wicket and another one Tapestry 4.1. The first several chapters in both books are free, so you can check them out yourself.