Monday, December 18, 2006


dojo, rico, xap, atf, kabuki,
google web toolkit...

so many toolkits/tools... so little time...

Monday, November 27, 2006

Patching Firefox 2.0

bon echo

In office, the standard browser we use is IE 6. Fine. But once in awhile, some of my colleagues and I like to use Firefox to browser the Internet. Mostly because it has the tabbed browsing feature.

Since we don't want the company proxy to track us down for using a non-standard browser, we overrided the User-Agent setting of Firefox so that it appears as IE.

The only problem is, when the user agent is changed, the Java plug-in will start to complain that "Java Plug-in for Netscape Navigator should not be used in Microsoft Internet Explorer". This is a known "bug". But luckily, Firefox is an open source project and someone already provided a solution. Basically, all we need to do is to patch the NS plugin API so that the original User Agent string is returned to all the plug-ins. Simple, huh? Well...

Lesson learned: Read the document carefully!

I used to compile Firefox 1.x on my Windows machine with Cygwin. But this time I want to try Firefox 2.0 with VCC. Mostly because the performance of the executables compiled with gcc is kind of disappointing. However, setting up a new compilation environment for Firefox is more time consuming than I anticipated. All becuase I didn't RTFA!

As I already have VCC 6.0 installed, I thought I was all set. It turns out that VCC 6.0 sp6 cannot be used to compile Firefox! I retried the build process and failed many times before I re-read the Build Prerequisites... yuck! Anyway, after I re-installed the VCC with sp5, the build process finally can be completed happily.

Anyway, I now have the customized Firefox running without the User-Agent problem. Later maybe I will try to re-compile the code to fiddle with more compiler optimization settings.

PS. In case you are interested, here is the .mozconfig that I use:

. $topsrcdir/browser/config/mozconfig

mk_add_options MOZILLA_OFFICIAL=1
mk_add_options BUILD_OFFICIAL=1
ac_add_options --enable-official-branding

ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --enable-static
ac_add_options --disable-shared
ac_add_options --disable-tests
mk_add_options MOZ_CO_PROJECT=browser

yes... i know... i shouldn't be using the official branding options... but then, i don't like the name bon echo :P

Saturday, November 25, 2006


剛看了謝安琪的 <後窗知己> MTV. 歌詞感覺好迷離, 結局好似睇緊電影 The Sixth Sense

Monday, November 20, 2006

my first mindstorms

I finally bite the bullet and bought the Mindstorms. Well, the Mindstorms NXT to be exact. I always wanted to get the original Mindstorms RCX. But given the hardware spec, I thought it was a little bit expensive.

Now with the second generation, there is finally supports for wireless (Bluetooth) communication, a 32-bit processor, USB 2.0, and more sensors... just can't resist it... :P

Here is my first robot... the default "30 minute quick start" robot in action

Saturday, November 18, 2006


heehee haha.... 我部封曬塵既 nds 又可以出籠啦...

Thursday, November 16, 2006


Just patched the ASFRecorder so that I can use my FreeBSD machine to record some radio programs. The patches are for:

  • Recognizes more mime types

  • Supports -o parameter to stream the output to stdout so that I can pipe it to ffmpeg and convert the stream to MP3

These patches can be found on ASFRecorder homepage. I just made some modifications so that it can compile with VC++ on Windows too.

You can download the source here and the Windows executable here...

(ok... so it might not be a good idea to release such patent-sensitive source code...)

Sunday, March 26, 2006

Swapping Hell: Compiling JDK 1.5 on Freebsd 4.x

In the past few days I was playing with some AJAX + Java codes. As I plan to deploy it to my web site later, I thought it would be a good idea to upgrade the JDK (from 1.3.x to 1.5.x) on the web server. As expected, my antique web server (K6 400MHz with 192MB RAM) took forever to compile the FreeBSD port. After several hours of hard disk crunching, the build process stopped as there was not enough swap space... yuck! The swap partition on the machine is only 128MB. So I used vn to add another 500MB of temporary swap file.

And after 14 hours, 49 minutes and 45.95 seconds later, it finally completed the compilation :P

Sunday, March 12, 2006

Jetspeed 2.0 with Postgresql

Tonight during dinner, my friend mentioned to me that he recently deployed a project using Portlet technology. It reminded me that when I devloped a portal site back in 2002, there was no such standard. I wanted to give Portlet a try since the draft was finalized, but yeah, I was lazy :P. Tonight I finally downloaded Jetspeed 2.

Jetspeed 2 can work with many DBMSs, including my favourite: Postgresql. But after downloading the MultiDb version installer, I found that it won't install as the appropriate SQL scripts were not created. Instead of trying to build it from source (yes, I am very lazy recently and... what the hack, I was just trying to install it on a Windows machine... so I don't want to compile from source :P), I found that similar issue has been reported and you can download the script directly.

Just start the Jetspeed installer, and it will unpack itself to an "antinstall" directory under your temp directory (e.g. C:Documents and SettingsadministratorLocal SettingsTemp). Then, before you proceed with the installer, unpack the Postgresql script package into the database directory under antinstall. Then proceed as usual.

Thursday, March 2, 2006

Calling Javascript functions from a Java Applet

Many years ago, my colleagues encountered a problem that at that time there was no generic solution. The problem was to somehow let the Javascript on a web page to verify that an Applet is loaded correctly without using polling mehtods. Out of curiosity, I tried to find out if browsers today provide a general solution and will work with (at least) both IE and Netscape/Mozilla/Firefox.

It seems that there is a valid solution since IE 4 (and yes, I haven't looked at this problem for a very long time :P). There is a way for an Applet to invoke a Javascript function and will work with both IE and Netscape/Mozilla/Firefox.

First, the applet needs to import the
class "netscape.javascript.JSObject". Although the name says "netscape",
but IE's VM has no problem running the Applet.

(BTW, to compile the Applet, you will need to include plugin.jar in your classpath (e.g. C:Program
FilesJavajre1.5.0libplugin.jar). It is where the JSObject class is located.)

When defining the Applet in the HTML, you need to add the "MAYSCRIPT"
parameter to the <APPLET> tag. e.g.

<APPLET CODE="TestingApplet.class" WIDTH="100" HEIGHT="100" MAYSCRIPT>
<PARAM NAME="initFunction" VALUE="appletLoaded">

Here, I also pass a string "appletLoaded" as a parameter to the
Applet. In my testing HTML page, "appletLoaded" is in fact a
Javascript function name. Inside the Applet, when it is loaded, it
will call this function in its init() method.

I wrote a little testing program and put the HTML, Applet, and source code

On that page, the "Click Me" button was originally disabled. When the
applet loads, it will call a Javascript function. And that Javascript
function will in turn enable the button.

(Since I sign my own certificate, so when you visit my site using SSL,
you will see a warning message. That is normal. Just click OK)

Monday, February 27, 2006

Low voltage cutoff

Added a low voltage cutoff circuit to my META42 headamp to protect the lithium battery.

Sunday, January 8, 2006

Another headamp - LC-King clone

Found David Lin's LC-King circuit while browsing the web. Tried to build one. To my surprise, its performance is close to (or maybe even better than) my loaded PIMETA. Details about my version of this headamp:

  • Uses LM317 regulator

  • Class A

  • Virtual ground circuit using BUF634. 2 x 220uF rail to rail. 2 x 470uF + 3.3uF from each rail to virtual ground

  • No input capacitors

  • Volume control circuit wired as shunt attenuator

  • Currently using OPA2111BM for U1 and TL072 for U2