Thursday, October 25, 2012

Using USB thumb drive on Windows XP Guest with VirtualBox on Mac OS X Host

According to this post, to use a USB thumb drive on Windows XP guest in a VirtualBox machine on a Mac OS X host, one needs to use only one processor in the VirtualBox setting.  What a surprising setting!

Tuesday, October 09, 2012

NullPointerException When Creating New LibreOffice Database File

When I tried to create a new database file in LibreOffice (version 3.6.2 on Mac), I encountered the following error:

SQL State: S1000
Error code: -27

file input/output error java.lang.NullPointerException.properties

The reason was that I had added a newer version of hsqldb file in the classpath.  The one I added was hsqldb-2.2.6.  It seemed that LibreOffice expected a version of 1.8.0.

After removing those hsqldb files from the classpath, I could create a new database file again.

Saturday, September 15, 2012

國民教育爭議中的「邏輯錯誤」

國民教育爭議不斷,今天讀報仍可見到有趣觀點!

明報今天刊登的一篇評論,「國民教育科爭論中的邏輯錯誤」(簡稱「國文」),作者以提出一些「攻、防雙方都不曾察覺的邏輯錯誤」,提醒大家留意。該文引用學民思潮聲明,舉出兩個例子,作為六種邏輯錯誤的例證。

例一:「但近日由政府贊助的國民教育服務中心及浸會大學當代中國研究院編製的《中國模式——國情專題教學手冊》,當中內容偏頗,嚴重扭曲民主概念,大力歌頌中共所謂『民主集中制』,赤裸地進行政治灌輸!此證明民間對國民教育淪為『洗腦教育』及成為政治灌輸工具的指控並非無的放矢。」

「國文」作者以例一,解釋「稻草人錯誤」,「巧合錯誤」,「混淆相關和起因」,「以果證因」四種邏輯錯誤。不過有趣的是,例一的結論為「指控並非無的放矢」,「國文」的作者卻將例一與對「國教科課程指引」(簡稱指引)的批評拉埋黎講,以顯示頭三種的邏輯錯誤。舉例說,作者認為教材是稻草人,批評者不應因為稻草人(教材)有洗腦成份,於是推論「指引」有洗腦成份。很可惜,例一並非以指引有洗腦作結論,反而「國文」則以指引有洗腦成份作攻擊對象,作為作者論據中的稻草人!

再睇「國文」中舉的另一例子。

例二:「此外,現時政府資助國民教育機構的準則欠缺透明度,只怕將來市面上絕大部分國民教育教材都會以政治正確及避談敏感議題為依歸。」

「國文」作者以此例子解釋「滑坡錯誤邏輯」和「類比錯誤」。例如作者說:「其內在的邏輯推理是:現時政府資助國教機構的準則欠缺透明度,所以將來政府必然欠缺透明度,因此將來市面上必然只有政府欽點的機構提供教材,於是大部分教材必然都會政治正確。」於是作者認為例二犯上了滑坡錯誤,即以一連串的可能性當為必然。可惜的是,例二的用詞是「只怕」,即是表達某可能性去到值得關注的程度,但沒有斷定此可能性為必然。也許作者也意識到例二並非說必然,因此以「內在」邏輯作解說,以推論出滑坡錯誤。

今次輪到睇「國文」的結論:

「(1) 雖然學民思潮已取得初步勝利,但並不代表他們言之有理和思維正確。(2) 他們只是成功利用了社會大眾的深層恐懼心理和表面情緒反應而取得了成功,是「盲拳打死老師傅」的典型案例,值得學界反思。」

第一句我沒異議,只是照計有興趣去睇「國文」中的邏輯錯誤的讀者,都應該會有此理解,不用作者提點。

不過第二句就有點問題。該句中的「只是」,即是指恐懼心理和情緒反應是學民思潮取得初步勝利的唯一原因,亦即否定了學民思潮其他批評的理據。本文基於例一例二,已舉例指出「國文」作者所講的邏輯錯誤是有問題。不過就算例一例二真的有邏輯問題,也不等於學民思潮所有的批評(或者大部份)的批評是有問題(例如作者似乎沒有考慮過學民思潮對指引的直接批評)。

而就算言之有理和思維正確不是學民思潮初步勝利的原因,但這不等於他們的勝利只可以是因為恐懼和表面情緒!若果要推論某事不能因為A而引起,因而只可以因B而引起,需要先提出某事只可以因為A或B而引起,而不能有其他起因。不過觀乎「國文」全文,沒有解釋為何學民思潮的初步勝利,只可以有學民思潮「言之有理」和「恐懼心理」兩個起因,為何不能是因為巿民自己對國民教育有合理的擔憂,也為何不能是某些論者所講的什麼勾結外國勢力等原因。至於為何恐懼心理和表面情緒可以是合理原因,「國文」亦沒有提出任何理據!

收緊按揭成數 => 更多人買細價樓?!

昨天金管局宣佈,因應「QE3」而收緊按揭成數。據電視台轉述的評論,認為這措施會令更多人不能買貴價樓,因而轉買細價樓。不知他們是否想說,因為多了人買細價樓,會令細價樓的樓價上升呢?

到底此措施對樓巿有什麼影響,恕我不能斷定。不過以上的論據,就十分有趣。按此推論,若果巿民收入下跌,亦都會因買不起貴價樓,因而令更多人轉買細價樓。但另一方面,一般人會認為,若果巿民收入上升,能促使樓價上升。若果將使兩者夾埋黎睇,即係話,無論巿民收入上升或下跌,細價數都會受到正面影響。換句話說,即係無論巿民收入如何,細價樓樓價係侷住升!

到底是否更多人會轉買細價樓?也許這是對的。當樓價下跌時,自然多了細價樓,因此可說成是多人買細價樓。若然細價樓樓價升了,也可說成是更多人買了細價樓的證據。

Thursday, July 12, 2012

Reader Page Customization in Safari

The style of the Reader page can be customized by modifying this file:

/System/Library/PrivateFrameworks/Safari.framework/Resources/Reader.html

To change the font size for the .page, the "important" keyword has to be added.

More information can be found on this page.

Wednesday, June 20, 2012

Calibre Recipes for 每日日課 & 每日聖言

I have written two Calibre recipes for downloading daily Mass readings and breviary from the HK Catholic Diocesan Liturgy Commission webpage.  They can be useful for reading offline on a e-reader like Kindle.  To use them, copy each recipe to a text file, and then "load recipe from file" in Calibre.

They download content for 60 days starting from today.  So one may ask Calibre to download these sources every 30 or 60 days.

Writing recipes are relatively easy tasks.  The difficult task is to read them daily!

每日聖言

------------------------------------- recipe starts below ------------------------------------
from datetime import date, timedelta


class MeiRiShengYan(AutomaticNewsRecipe):
    title          = u'\u6bcf\u65e5\u8056\u8a00'
    oldest_article = 35
    max_articles_per_feed = 100
    auto_cleanup = True


    no_stylesheets = True
    encoding = 'big5-hkscs'


    cover_url = 'http://liturgy.catholic.org.hk/dlcgif.gif'


    def parse_index(self):
        today = date.today()
        current = today
        feeds = []
        articles = []
        while (current - today < timedelta(60)):
            url = 'http://catholic-dlc.org.hk/mk' + current.strftime('%y%m%d') + '.htm'
            title = current.isoformat()
            articles.append({'title':title, 'url':url,
                             'description':None, 'date':current})
            current += timedelta(1)


        feeds.append((u'\u6bcf\u65e5\u8056\u8a00', articles))
        return feeds


    def populate_article_metadata(self, article, soup, first):
        title = soup.find('p', attrs={'class':['MsoNormal','MsoPlainText'], 'align':'center'})
        if title:
            article.summary = self.tag_to_string(title)
            article.text_summary = article.summary
------------------------------------- recipe ends above ------------------------------------



每日日課

------------------------------------- recipe starts below ------------------------------------
from datetime import date, timedelta


class MeiRiRiKe(AutomaticNewsRecipe):
    title          = '每日日課'
    oldest_article = 35
    max_articles_per_feed = 300
    auto_cleanup = True


    feeds          = []


    no_stylesheets = True
    encoding = 'big5-hkscs'


    cover_url = 'http://liturgy.catholic.org.hk/dlcgif.gif'
    map = {'LH1': '晨', 'LH2': '日', 'LH3': '晚', 'LH4': '誦', 'LH5': '夜'}
    pages = list(map.keys())
    pages.sort()
        
    def parse_index(self):


        today = date.today()
        current = today
        feeds = []
        articles = []
        while (current - today < timedelta(60)):
        for page in self.pages:
        url = "http://catholic-dlc.org.hk/%s_%s.htm" % (page,  current.strftime('%Y%m%d')) 
        title = current.isoformat() + self.map[page]
        articles.append({'title':title, 'url':url, 'description':None, 'date':current})
        current += timedelta(1)
        feeds.append(('每日日課', articles))
        return feeds


    def populate_article_metadata(self, article, soup, first):
        title = soup.find('p', attrs={'class':['MsoNormal','MsoPlainText'], 'align':'center'})
        if title:
            article.summary = self.tag_to_string(title)
            article.text_summary = article.summary
------------------------------------- recipe ends above ------------------------------------

Friday, May 25, 2012

Aquamacs + Emacs (HomeBrew) + site-lisp

The site-lisp directory for Emacs is:
/usr/local/share/emacs/site-lisp

So to share this site-lisp directory with Aquamacs:
sudo mkdir /Library/Application\ Support/Emacs
cd /Library/Application\ Support/Emacs
sudo ln -s /usr/local/share/emacs/site-lisp


I used this so that I can use the same version of ESS for Emacs (installed by HomeBrew) and Aquamacs.