Friday, December 21, 2007

是日金句

「你有冇咩野想講?」

-.-... 真係… 攪到我都唔知講咩好… orz...

Monday, December 17, 2007

Interconnects

Haven't done any DIY in the past few months... orz... busy busy busy...

Yesterday went out to buy some components to make an interconnect for my old discman and CK²III.

The cable is nothing fancy, at least not in the league of "audiophile grade". It is the Canare "star quad". Around HKD16 per meter. Although the price is not audiophile grade, but Canare "star quad" is famous in preventing hums and electro magnetic interference. It is commonly used in many studios and on stage.

The "star quad" contains 2 twisted pairs and a braid shield. Of each twisted pair, one cable is blue and the other is white.
Commonly most people will use the colored (blue) cable to "carry" the left / right channel and connect the white cable to ground. But some people claim that due to dielectric etc reasons (@.@), using the white cable to "carry" the signal gives better sound... So that was what I have been doing in the past when I used the "start quad" cable.

Since this interconnect is primarily for my discman and desktop headamp setup, one side is terminated with a Canare F12 3.5mm "headphone" plug, and the other side are 2 Canare F10 RCA plugs. Really like the Canare plugs, solid and heavy (brass inside!!).

Also got some spare F10 plugs... planning to make a pair of RCA interconnects using Gotham cables later :P




Sunday, December 16, 2007

破事兒

早兩日睇左《出埃及記》隻 DVD。

吸引我去買呢隻碟既原因係佢個故事(廢話…買戲睇就係睇故事嫁喇)。戲入面男主角係一個當差多年的警察,而係一個機緣之下,佢走去查一單怪 case:有個偷窺犯話佢知呢個世界上有班女人計劃要殺曬d男人。而d女人之所以上廁所要咁耐,就係因為佢地係廁所入面商量殺人大計。咁個犯就話自己係偷入女廁去拍低女人d殺人計劃罪証。

=__=

好鐘意呢d有d無厘頭,啜核得黎又過癮,睇完有得諗下兼「加d想像力就可發一餐白日夢」既戲。:P 加上部戲d燈光呀,配樂呀等等都唔錯,明顯唔係普通既港產爛片。於是上網 search 上導演彭浩翔d料同睇下佢個 blog。發現佢今個 weekend 有新戲上,叫「破事兒」。

初初唔係好明咩叫「破事兒」。直至今日行過書局,見到彭浩翔原來出左本同名書。以為係電影小說之類既書,冇咩期望,只係拎上手隨便揭揭。點知原來係十幾篇的短篇小說,係收錄番彭浩翔多年前幫報紙雜誌寫的文章。

揭左幾頁就決定要買番屋企睇。二百頁唔夠,十八篇既短篇文,個零鐘一口氣睇曬。唔錯呀!唔少短篇都古靈精怪,個結局有d真係睇到想笑,有d又睇到嘆氣。最重要係一路讀,一路有d睇緊戲既感覺!

原來「破事兒」係彭浩翔一個 friend 既 blog 名。意思係一 d 小事:「塵世有幾許事可堪動地驚天,還不是去似微塵,所有種種,回頭再看,就那麼回事。愛慾生死,也不過是些破事兒。喜歡那份豁達大度,所以特借此為書名。」

之後上網睇下「破事兒」部戲的預告片。睇落亦都係由幾個短故事組成的,好似唔錯…不過我估我都係會等佢出碟先睇 :P

Monday, December 10, 2007

是日金句

[橫掂都係白狗偷食,黑狗當災,死人都做白狗啦。至少有得食喔]

Sunday, December 9, 2007

The grass is always green

Read this interesting piece today, from the book The Paradox of Choice


... inevitably, you will encounter people who are younger, better looking, funnier, smarter, or seemingly more understanding and empathetic than your wife or husband. But finding a life partner is not a matter of comparison shopping and "trading up". The only way to find happiness and stability in the presence of seemingly attractive and tempting options is to say, "I'm simply not going there. I've made my decision about a life partner, so this person's empathy or that person's looks really have nothing to do with me. I'm not in the market - end of story."


When you make a decision, try to tell yourself it is nonreversible.

Saturday, December 8, 2007

本年度十下十下最終回

經過接近十個禮拜,幾乎冇停過的 weekend 十下十下活動,今日終於完成了應該係今個年度的最後一次的 gathering… 多謝兩位靚女賞面上黎打邊爐同吹水~~




下年冬天再約大家上黎十下十下!

Wednesday, November 28, 2007

Reducing memory usage of FOP

Here is a straight forward example on using FOP to generate PDF reports:

......
<fo:page-sequence master-reference="simpleA4">
......
  <fo:flow flow-name="xsl-region-body">
    <xsl:apply-templates select="the-bean" />
  </fo:flow>
......
</fo:page-sequence>
......


The original data is in form of Java beans. A container contains multiple Java objects of "TheBean". The data is converted into XML by Castor. You can notice that the XSL file simply "apply-templates" based on the beans. FOP is smart enough to loop through all the beans of type "TheBean" to render the reports.

But this straight forward approach has a problem. FOP writes output and free up resources on a per-page-sequence basis. In the above example, the "apply-templates" tag is within a page sequence. This means FOP will loop through all the data before wriing the output PDF. In one particular test, in order to generate a report with 11MB of data in XML format (the PDF output is over 400 pages), FOP used up 1.3GB of memory.

To get around the problem, we could use a difference page sequence for each object:

......
<xsl:for-each select="the-bean">
  <fo:page-sequence master-reference="simpleA4">
......
    <fo:flow flow-name="xsl-region-body">
      <fo:block>
        <xsl:apply-templates select="." />
      </fo:block>
    </fo:flow>
......
  </fo:page-sequence>
</xsl:for-each>
......


Here, the for-each loop will iterate the beans one by one using different page sequence. Using this approach on the same 11MB XML file, the memory usage is reduced to below 48MB.

If each object needs to maintain its page number count, we could use a variable to name the "last page block" differently:

......
<xsl:for-each select="the-bean">
  <fo:page-sequence master-reference="simpleA4"
    initial-page-number="1"
    force-page-count="no-force">

    <xsl:variable name="count">
      <xsl:value-of select="position()"/>
    </xsl:variable>
......
      Page <fo:page-number/> of
      <fo:page-number-citation
      ref-id='last-page{$count}'/>
......
    <fo:flow flow-name="xsl-region-body">
      <fo:block>
        <xsl:apply-templates select="." />
      </fo:block>
      <fo:block id="last-page{$count}"/>
    </fo:flow>
......
  </fo:page-sequence>
</xsl:for-each>
......


Note the use of force-page-count="no-force". It is to prevent FOP from inserting a blank page between page sequences.

Sunday, November 25, 2007

Saturday, November 17, 2007

行呀行

之前話過每個禮拜都要出去行下運動下,不過上個星期偷懶…好在今朝戰勝睡魔。出發時天色陰暗,仲以為會落雨。點知愈行愈好天,仲有涼風,行得好鬼舒服!





Saturday, November 10, 2007

是日金句

十一月十一日,1111,四條光棍,係大陸的「光棍節」。大陸人好怕單身咩?!


剛見識到的「光棍節」名句: 『一個人吃飽,全家不餓』。 係單身的無奈,還是好處? =.=

Friday, November 9, 2007

因為豆漿濃啊

網上論壇新興的「無厘頭」回覆… 『因為豆漿濃啊!』

=.=...

Sunday, November 4, 2007

又係十下十下呀!

今晚又係同朋友打邊爐… 應該係連續五個 weekend 了… =__=...

不過今次有d唔同:第一次有七個人咁多一齊打,差d唔夠椅子添…真係唔好意思 :p 。其次係我第一次食大閘蟹!唔係講笑的。不過原來我屋企人唔食大閘蟹,因為個個都係寒底一事係堅嫁!我食完真係有d暈暈地… @.@… (不過亦都可能係我飲得太多 :P)

PS. 多謝大家俾面上來玩!

Saturday, October 27, 2007

是日金句

「本來諗住關心下佢… 點知越講越衰」

Thursday, October 25, 2007

12 years



what can you accomplish in 12 years?

Sunday, October 21, 2007

DVD authoring

Recently downloaded a video in MKV format. MKV is quite a popular format when distributing video contents. One of the reasons is that MKV is extremely flexible. It can virtually mix any video/audio content in it. But this also posts a challenge when converting it.

First, let's check what is in the MKV file so that we know what to do. mkvtoolnix is a handy tool for that. Use the mkvmerge command to see the file structure:

mkvmerge -i 5Centimeter.mkv


And this is the output for my MKV file:

File '5Centimeter.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)
Track ID 3: subtitles (S_VOBSUB)
Track ID 4: subtitles (S_TEXT/ASS)


Here is the analysis:


  • The first track is the video in MPEG4 format. We will need to convert it to MPEG2 for DVD

  • The second track is the audio in AC3 format. We can just reuse it in the DVD. No conversion required

  • The video is a Japanese anime and track 3 is the subtitle file

  • Someone is nice enough to include a translation of the subtitle in Simplified Chinese format in track 4. But note that it is in text format . So we will need to convert it into image format for the DVD


Initially I thought I could use avi2dvd to do most of the conversion jobs since it supports MKV format and subtitle generation etc. But after several days of struggle, I concluded that it can't handle Chinese subtitle nicely. So instead, I just used it to do the video and audio conversion, format/frame rate changes, pull down etc tedious tasks and generate a "DVD ready" ISO for me, without the subtitles.

avi2dvd is actually an GUI for many freeware programs. There are many options to choose from. BTW, I used the HCenc encoder, which is slow (almost 3 hours to encode the 1 hour video on my 3200+) but is supposed to give good result.



Once we have the ISO file, we need to demux it. This is to get the converted video (and audio) files so that we can multiplex them with the subtitles. I used VobEdit for that.

The subtitle requires lots of work here. First, use mkvmerge to extract the text from track 4 into a file. It is in SRT format with GB encoding. As I couldn't find a freeware tool that can handle SRT directly for DVD authoring, so here is the process on how to convert it into SUP format:

  • Since I prefer to read Traditional Chinese, so I used ConvertZ to convert the content into Big5.

  • Use Subtitle Workshop to convert the SRT file into Substation Alpha (SSA) format




  • Use MaestroSBT to convert the SSA file into SON, with the text rendered as bitmap. Choose the output to be 4-bit compressed bitmap files. Since I am rendering Chinese text with Big5 encoding, I changed the default font setting. Also need to adjust the margin etc. In the Color Rendering section, I chose "Two colors for text, one for outline, no antialias". Note down the color used. We will need this info later.




  • Use son2vobsub to convert the SON file to SUB format

  • Use SubToSup to convert the SUB file into SUP format


... and finally... we have a usable subtitle file... orz...

Next, use IfoEdit for the final mutliplexing. Choose "DVD Author" -> "Author new DVD". Select the video, audio and subtitle files. Set the correct language for the audio and subtitle. Then click OK to generate the DVD files (those VOB, IFO etc files).



Then a little trick. Since the subtitle is generate in specific colors, we need to set it in the IFO file so that it can overlay nicely on the video. In IfoEdit, select the "VTS_PGCITI"->"VTS_PGC_1" node. Then look for the "Color 0 Y Cr CB", "Color 1 Y Cr CB" etc entries. They are the color codes for the subtitle:

Color 0 = Background
Color 1 = Outline
Color 2 = Letters
Color 3 = Anti-alias


Here are the codes for different colors:

White: EB 80 80
Brown: 30 B8 6D
Black: 10 80 80
Green: 50 50 5A
Oliv: 71 89 47
Naval: 1C 76 B8
Púrple: 3D AF A5
Turquese: 5D 47 92
Grey: 7D 80 80
Silver: B4 80 80
Red: 51 EF 5A
Lime: 90 22 35
Yellow: D2 92 10
Blue: 28 6D EF
Fucsia: 6A DD CA
Aqua: A9 10 A5




Change the values to reflect the colors used when we generate the subtitle images using MaestroSBT. Click "Save" to update the IFO. Then click "Disc Image" to generate the final ISO.

Preview the ISO. To get the position right, I needed to re-generate the subtitle file a few times... orz. When everything is OK, use a burning program (e.g. DVD Decryptor) to burn the image to a DVD-R... and we are done!

Saturday, October 20, 2007

Encoding video for N80

The Nokia N80 has a bright and (relatively) high resolution screen (352x416). But unfortunately, the RealPlayer on the phone can't play MP4 streams at the max native resolution. After some trail-n-error and some googling, here are the settings for encoding video for N80:


  • File format: MP4

  • Video codec: MPEG-4

  • Audio codec: AAC

  • Resolution: 352x288

Monday, October 15, 2007

十下十下 Revolution

係剛過去既星期六又係「十下十下」中渡過。五個人烚下烚下又一晚。今次唯一特別係我除左事前洗洗切切一輪之外,其餘買料呀,食完之後洗砂煲罌罉之類 D 粗重野全部有人代勞…哈哈,爽呀!


不過唔知點解,經過連續幾個禮拜既「十下十下」,我屋企個雪櫃 D 野不少反多。依家成個雪櫃都係 D 咩丸乜丸、肥牛、烏冬、汽水…… orz

Saturday, October 6, 2007

十下十下 Reloaded

好多菜…好多蝦…好多肥牛…仲有好多豆腐!



PS. 今次有食烏冬,仲要係「手打烏冬」!事關某人兄話「我呢世人唔係手打烏冬唔食既!!」 :P

Thursday, October 4, 2007

dilbert

vacation



man month

Monday, October 1, 2007

十下十下

曾幾何時,我個個禮拜都至少會係屋企一個人烚下烚下打邊爐一次的。D 屋企人覺得我好奇怪,一條友有咩好打邊爐。不過… 一條友其實出街亦都冇咩好食 orz …。 可惜,對上一次租住間屋因為太多雜物,連食飯枱都冇張,所以都冇係屋企打邊爐好耐。難得今日係「十一國慶暨搬屋兩個月後終於清曬 d 紙箱有番個廳用」的大日子,決定要十下十下黎慶祝。

今晚菜單:

新界菜心。$7 斤。又平又靚。食左半斤咋。



$5 金菇。吉之島有 d 好靚既金菇 (個菇頂真係金色嫁!)…不過貴。下次先試。食住 d 平野先!


$20 「游水蝦」半斤。事關六點幾先決定要十下十下,去到街市時已經冇曬活蝦…好在呢 d 蝦都 ok。至少肉質都爽。


$75 澳洲和牛。成餐至貴係佢,不過食落真係唔同 d :p 。


當然唔少得 d 乜丸物丸…仲有雜菜餃添!


大會指定飲品:啤酒同肥曲…



湯底一邊係清雞湯加鮮番茄,另一邊係李錦記麻辣湯底 o_0 。


好飽呀!不過係洗洗洗洗洗洗洗完曬 d 碗碗碟碟之後又有 d 餓… 先發覺唔記得食包烏冬… =_="

PS. 同場加映,我終於有番個廳用喇!

Sunday, September 23, 2007

喜百合

是夜去左 MegaBox 的喜百合食晚飯。d 野食唔錯。炸子雞,小籠包,松鼠魚等等全部都好好食。之後仲叫左幾過甜品。我自己既合桃露 ok。 反而 share 的豆沙鍋餅非常正。d 豆沙唔似出面食果 d 咁甜,個皮又脆脆地兼有咬口。

另外個拔絲係你面前「拔」俾你睇既。見佢開支忌廉汽水,倒入一碗冰到「拔」。不過…點解拔完都冇絲既?

有片為証喲:

四部戲

係剛過去的一個禮拜,睇左四部戲。好耐都冇試過咁樣「煲碟」法。

先睇左朋友借俾我既 Life is Beautiful 。睇之前並唔知到原來係二次大戰片黎。老實講,如果淨係睇開場個十幾分鐘的話,真係會以為睇緊鬼佬版「周星星」d 戲。個故事係圍繞二次大戰時,主角點樣用樂觀的態度,令佢身邊既人,特別係佢個仔同太太,渡過難關。比起 Schindler's List,呢部戲冇咩煽情場面。同 Saving Private Ryan 比,又連一個荷里活式的大場面都冇。對猶太人所受的逼害,套戲都係用一 d 隱喻的鏡頭表達。例如集中營的人會討論老弱的人會被騙去洗澡,其實係被送入毒氣室。跟著鏡頭會見到德軍送一大班人平靜地行入「澡堂」,然後鏡頭一轉,只係見到煙囱噴出大量黑煙。所有「慘情」場面的處理都係隱隱約約的,可能是要突出主角的樂觀性格。但呢 d 都冇減少呢部戲的震撼性。總括黎講,唔錯。

跟住睇既就真係周星馳既戲 — 「功夫」。冇咩好講。純粹一部可以 shutdown 個腦睇既戲。ok 喇。想睇既原因係,早前和同事一齊食飯時,大家飲到 high high 地,係到笑某同事「可以好似肥仔聰咁係心口劃對斧頭」,於事想睇睇係咩一回事。雖然之前有人話呢部戲係想帶出什麼「本領愈大的人,責任愈大」的訊息等等。不過…算把喇,當係「周星星」既戲睇咪算囉。

再跟住睇既係 Babel 。香港上畫時譯做「巴別塔」。記得細個讀聖經故事,巴別塔的故事係講原本人類係用同一語言的。當時大家想建造一座塔直達天堂,以為自己可以同神相比。於是神決定變亂世上的語言,令大家不能溝通,最終建唔成座塔。部戲圍繞住四個家庭的事,不停 back and forth 咁跳黎跳去。大家都好似冇關係,但其實每件事最終係由另一件事帶出黎。套戲有英語,日語,西班牙語,阿拉伯語場面。真係有 d 「巴別塔」 feel。不過,唔同語言唔係最大既問題。部戲帶出的訊可能係,要真正做到「溝通」得到先係最大的問題。仲有,係好多地方上,套戲都冇正式交待到前因後果…不過都好,有 d 位俾人去諗諗。唔錯唔錯。

最後一部係 300。又係唔洗點用腦的。 CG 勁。場面血腥震撼。純觀能刺激。正正正!

Thursday, September 20, 2007

stupid jokes and stupid programmers

Received an e-card from a friend today. The URL for picking up the card is something like this:

http://www.whateversite.com/pickupcard?read=1&id=123456

The "read=1" part caught my attention. So instead of reading the e-card immediately, I did a little experiment first.

I went through the trouble of opening an account on that site and sent myself several e-cards with the "Send me an email when the card is being retrieved" option checked. And when opening my own e-cards, I removed the "read=1" part... and BINGO! The site won't send the notification email if the part is removed from the URL!

This proves:

  • The site will update the record on the first retrieval of the card and only send out the email at that time. Because even if I added back the "read=1" part later, the site still won't send out the notification email.

  • The programmers for that site made a stupid and fundamental mistake. Never ever trust any input from users, especially if it is via the Internet. As the logic is to send a notification when the card is retrieved, there is no need to use a parameter for that... at least not that obvious on the URL! Just store sender's selection in DB and check it when the card is first retrieved.

  • I have too much time! Because after the experiment I decided to make a stupid joke on my friend. When I eventually read my friend's e-card, I removed the "read=1" part so that he/she won't get the notification email (that is, if he/she indeed checked that option :P)!

pyschological balance sheet

睇緊本 The Paradox of Choice,入面有好多有趣例子。好似:

案例一:你諗住用廿元去買入場卷聽演唱會。
就係你準備買飛時,你發現自己先前係街跌左廿元。
咁問題係你仲會唔會用廿元去買演唱會入場卷?


案例二:你用左廿元去買入場卷聽演唱會。
係你入場後,你發現自己唔見左張飛,
而你又唔知自己個位係邊。
咁問題係你仲會唔會用廿元去買番張演唱會入場卷?


就案例一而言,九成人會答買。但係案例二就只有少過五成人會用多廿元買番張入場卷。

心理學家話,其實兩個案例的 "bottom line" 都係用四十元去聽演唱會。但係結果之所以有分別,係因為我地心中有唔同「戶口」去扣數。係案例一中,入場卷果廿元係 “演唱會戶口” 扣數。而跌左果廿元呢,就係 “雜項戶口” 扣。而案例二果四十元就全部都係扣落 “演唱會戶口”,所以就多 D 人覺得唔值。

佢想帶出個訊息係:我地做決定時,其實好多時都唔係 logical 的。我地有時仲勁過 D accountant 砌 balance sheet,係自己心中砌條「靚」數俾自己睇。

不過計我話,D 人係案例二中選擇唔買其實原因好簡單:人都入左場啦,洗鬼買多張飛咩! 求其搵個「吉」位坐咪算囉!哈哈! :P

Wednesday, September 19, 2007

typo bug

The blogging engine that I am using is called Typo. One of the nice features is the "live search", in which it starts to search as you are typing (yes... it is AJAX).

But there is a stupid bug that stopped it from working with non-latin characters. I spotted it about 2 years ago but yet the bug is still here... orz... so here it is again: To fix it, simply change the Javascript from

escape($F('q'))

to
encodeURIComponent($F('q'))

Tuesday, September 18, 2007

是日金句

「有d 人, 三十歲已經死左, 不過到七十歲才埋葬而矣。」

Monday, September 17, 2007

bug

stumbled on this "bug" while browsing internet...


Missed Calls Reminder for Symbian S60 3rd Edition




The missed call reminder program for my N80 phone is done. There are still many things missing to make it a "real" application. But at current state, it suits my needs. So I will leave it as-is. Feel free to grab the source and improve it.

The current features / bugs are:

  • By default, every 5 minutes, the program checks for missed calls and unread messages.
  • If there are missed calls or unread messages, it will beep and vibrate
  • The period of checking, beep tone, and vibrate duration are NOT configurable via the GUI. Modify the program if you want to :P
  • When there is not enough memory, Symbian will close the background applications. Should have modified this program into a background service to avoid this
  • The current method to check for unread messages is to open the inbox and loop the messages one by one. Need to find a more efficient approach / API
  • When executed, the program main screen WILL NOT show. As most of the time you don't want to see the program main screen anyway (as there is NOTHING to see!). If you want to see the program main screen, you can press and hold the menu key on your phone and select the application.
  • Update: The volume of the alert tone will follow the settings of the current portfolio


NOT FOR THE FAINT OF HEART. This program is for fun only. Absolutely no guarantee or whatsoever. Use at your own risk.

The source + binary + Carbide workspace are available. Feel free to modify the code (and remember send me the improved version :D). And here is the binary installable program.

Sunday, September 9, 2007

20070909 柏架山












rsync bugs?

For one of the web sites that I built, it has 2 servers. The main server has 2 RAID sets to backup each other. And there is another machine with an extra RAID set for off-machine backup.

Recently, the RAID on the second machine died and need to be re-configured. When initiating rsync to copy the files from the primary machine to secondary machine, the process mysteriously failed with a timeout message after coped several hundred files.

It seems to be caused by dropped network packets. So tried to use the -bwlimit parameter on rsync to reduce the speed (the machines are connected with gigabit network). And BINGO. Although a bit slow, but at least it gets the job done.

Still have no idea whether it is caused by the rsync program or the network stack or the kernel though.

Choices

Should I kill myself, or have a cup of coffee? - Albert Camus.

Life is full of choices. I just started reading the book The Paradox of Choice: Why More Is Less. In the first few chapters, the author tries to show that nowadays we are facing more and more choices. And in some ways it is not a good thing. Some examples of choices could be Choosing How to Love, Choosing How to Pray, Choosing Who to Be etc. But one particular topic that I want to write about: Choosing How to Work. Because it is somehow related to a 是日金句 I posted a few days ago... 「一鳥在手,好過百鳥在林」

(At least) In our society we have the freedom to choose our jobs. Which led to a trend that we switch jobs quite (too) often. Most people don't work in the the same company for 10, 7 or maybe even 5 years. Is this kind of job mobility a good thing? Is working in the same company for long should be classified as 係出便撈唔掂?

When should we switch job? Where should we work? By thinking about these, are we wasting too much of our time and resources?

是日金句

「唔做中,唔做保,唔做媒人三代好」

近來時常為身邊朋友的事煩惱。但其實大多數的事情都和我無什關係,我通常只是在旁乾著急。我自己不好過之外,可能不少朋友覺得我「好很煩」。所以以後都係唔好做「八公」orz。

要對俾我「煩親」的朋友說聲對不起。而想俾我煩的朋友可隨便開聲。 :D

Friday, September 7, 2007

謊言

不要對身邊的人講大話,尤其是當這大話很快或很容易給其他人拆穿。這世上並沒有所謂「善意的謊言」。

在謊言的開始至拆穿期間,痛苦的會是說謊的一方。到拆穿時,痛苦的可會是身邊的所有人。

有時,選擇 no comment 可能會更好。

是日金句

一鳥在手,好過百鳥在林

Thursday, September 6, 2007

深入民心

有同事送了這幅畫給我… 看來我常常食 mc don don 的型像已經深入民心... orz



在此順便也祝這位同事早日康復~

Tuesday, September 4, 2007

Adding vibration to my missed call alert program (S60)

Used Symbian's HW Resource Manager Vibra API to control the vibrator.

First, include the header and declare a member variable in the application class:

#include 
. . . . . .
CHWRMVibra* iVibra;


In the 2nd phase constructor, create the instance:

......
iVibra = CHWRMVibra::NewL();
......


Start the vibrator when necessary:

>
......
// vibrate for 5 sec, strongest intensity
iVibra->StartVibraL(5000, 100);
......


And remember to destroy it in destructor:

......
if (iVibra)
{
    delete iVibra;
    iVibra = NULL;
}
......

Monday, September 3, 2007

Apple special event

Apple confirms that there will be a special event on Sept 5... will it be a Mac OSX based iPod?



... or maybe even an iPod touch??

man days

Sunday, September 2, 2007

mc don don

尋晚發左個怪夢:夢見自己走左入去工司附近間 mc don don。出奇地,午飯時間的中環 mc don don 竟然一個客都冇。正當我企係 counter 前諗緊食咩時(呢個動作絕對唔似我。事關我通常一早諗定食咩,一走入就會直撲 counter,以機關槍方式嗡 order 的說),突然係 counter 後面的收銀員一齊指住我,大聲叫:……









































「今日唔賣 mc don don 俾你食!」

跟住就醒左喇…… orz

~~完~~

Wednesday, August 29, 2007

Missed call alert for Symbian phones (S60 3rd Edition)

Yesterday I missed a call from my boss when I was taking a day off. I didn't notice that until the evening. This is because my Nokia N80, diff from my previous Motorola E398, doesn't beep or vibrate or give any signal periodically when there is a missed call.

Writing a program to solve this is not difficult, just a matter of finding the API to check the status of missed calls. With Google, that is easy. The Central Repository is supposed to held the information.

// We need to query the central repository
CRepository* cRepository = CRepository::NewLC(KCRUidLogs);

TInt num;
// Get the number of missed calls
User::LeaveIfError(
    cRepository->Get(KLogsNewMissedCalls, num));


But my copy of S60 3rd Edition SDK, Maintenance Release (with Carbide.c++ Express) doesn't has the definition of the constant KCRUidLogs . After some searches and guessing, it turns out that many functionalities of the S60 phones are not defined in the SDK. You will need to get the SDK API Plugin from Nokia.

Anyway, I tried to add the above code into a Hello World project that I have in Carbide. And it is working fine. I also used the CPeriodic class to set a timer to wake up the program periodically. It will beep when there are missed calls.

CPeriodic* iTicker;

......

const TInt KPeriodicTimerInterval5Sec(5000000);
const TInt KPeriodicTimerInterval3Min(1000000 * 60 * 3);
......

iTicker = CPeriodic::NewL(CActive::EPriorityStandard);
// start the timer
iTicker->Start(
    KPeriodicTimerInterval5Sec,
    KPeriodicTimerInterval3Min,
    TCallBack(PeriodicTimerCallBack, this));


TO DO:

  • Make the program to start automatically when the phone boot up. This will probably need me to request a developer certificate from Symbian Signed to sign the application.

  • Stop the application from being killed. When there is not enough memory, the OS will just kill some background programs to free up some memory for the foreground application. Need to find a way to prevent the alert program from being killed.

扎河...

staying late in office to rewrite the spaghetti SQL code...

accidentally changed the input method from normal english to chinese 速成... and when i typed "query", it became 扎河... hmmm... reminded me of 雞扎 + 河粉... (yes, i know. normally these 2 things don't go together... usually ppl will just think of 扎肉河粉... but anyway)...

... yummy...

Tuesday, August 28, 2007

continue blue

after finished the catcher in the rye, i have started to re-read this:



the curious incident of the dog in the night-time

CK²III Headamp

Repost after HD crashed

Built this discrete headamp in early April. The Cavalli-Kan Kumisa III is a all-discrete amp. The op-amps are used for DC servo only.

The big blue caps are from Vishay BC... which I heard should be as good as Panasonic FC. The rectifier diodes are "hyperfast" RHRP860.