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">
</APPLET>


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
here.

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












Sunday, December 11, 2005

typo Live Search

Typo, the Ruby-based blog engine that I am using, has a cool "Live Search" feature (i.e. search as you type by using Ajax). However, it doesn't work with multibyte characters. I fixed it with modifying the Javascript from "escape($F('q'))" to "encodeURIComponent($F('q'))"... Then when trying to submit it through Trac, I found it has already been submitted :P

Ripping audio CD with EAC

So far, I found EAC to be the best CD ripping tools... use it with lame to get the best quality mp3. My personal favourite command-line options:

-V 0 --vbr-new -b 128 -h %s %d

Monday, December 5, 2005

Headamp

Found a nice looking volume knob for my A47 headamp.

Also, the PIMETA is almost done too. Still waiting for the AD843 op-amp. Couldn't find the right volume knob so borrow it from the A47 for photo taking :P










Saturday, November 26, 2005

普選

this are the posts i replied on a forum when we were chatting about "全面普選"
link

我都希望見到全面民主, 但好怕見到 d 咩都反對, 非友即敵的"民主派"... 橫睇豎睇都似一(民主)黨專政多過自由民主.

始終覺得大部分香港人未夠包容同成熟地接受民主...


我指的是部份人士喇

我指的"專政"並非指 political ruling, 是指他們的非友即敵, 容不下其它聲音的做事方式. e.g. 一碰到唔同聲音的 phone-in 就 cut 人線的開咪人, 我就不覺得佢做法係民主喇

e.g. 一到選舉就會有 d 旅遊車車 d 公公婆婆去投票, 之後就有餐食. 做既"光名正大", 受既又大條道理... 咁就真係做到一人一票既民主? 咁樣選法, 我真係驚到時一人一票選特首會選左個廢柴出黎 ... 太多人唔真惜自己手頭上的一票喇


如果係做 true or false 問題, 一係專政, 一係民主的話, 我當然會要民主. 但世事唔一定係得黑同白, 可以係灰色的.

如果現在即刻普選特首的話, 有幾多人有諗過選完之後要點? 個政府應該點 run? 如果佢唔得民心, 應唔應該好易推番佢落黎? 如果係咁, 佢會唔會做咩都要"聽下民意先", 成日議而不決?

上次選舉時, 台灣的陳生原本係民意中落後, 但—個"槍擊"就令佢連任... 民意真係咁易就可以左右? 一個 911, 做就布殊連任. 但到係伊拉克攪到一鍋泡, 民意創新低, 你又估佢可唔可以做到任期完? 有時都覺得幾諷刺, 老董因為北大人"升佢上神枱", 香港人反而唔洗等到佢任期完... 唉... 真係諗爆頭都唔明

我係想要民主, 但要係成熟既民主. 有時我硬係覺得有d政客為一己利益係到不停吹風...


問題係"誰會出來選?"... 假如我地選左個 100% 民主反共既人出黎, 香港有高度民主自由, 但係同北方反曬臉, 中央唔俾 jetso 香港, 經濟一落千丈, 咁會點? 香港會唔會慢慢分化, 幾次革命之後會走左去行共產? 好驚 :P

又如果一個唔覺意, 選左個一味親中的話就大檸樂 (個人意見)... 唔好忘記, 現時香港政壇上的重量級人馬大多親中

我覺得要有唔同聲音/政黨, 大家實力差不多, 而選民又理性的話, 普選才有意思. 否則只係某 d 人做 show. 所以我支持慢慢來.

Tuesday, November 22, 2005

許願池的希臘少女

玩左一排 Ruby, 今日開始試 Ruby on Rails... 用泥起 web apps 又幾簡單喎... at least for "hello world" apps 喇 :p

夜半無聊, 一路上網一路用 tv tuner 在電視台間左跳右跳. 忽然聽到一首不錯的歌, 原來播緊蔡依林的許願池的希臘少女. 上網 search, 哈~, 原來是王菀之作曲的呢~~