2009-12-20

Gimp Polaroid Filter

To make my photo posting on my blog more interesting, I have usually resorted to use Gimp's "Round Corner" Script-Fu. I like this script because it drops a shadow so that my photos seems pop up from the background.

Later on, I encountered several blogs on internet like:
Gimp Making Border (in Chinese) (link)
Turn a digital photo into Polaroid with Gimp (link)

The idea is to make a digital photo resemble a photo-print and make it lay on a surface with some irregular shadows.

I very like this idea but find the steps clumsy if I have repeatedly do photo postings on my blog.

So... I start to write my first Gimp script!

Most of the Gimp macros are written in Script-Fu. It is said that it is a language called Scheme (however, I have learned Lisp before and I still cannot differentiate Scheme from Lisp because of their similarity!)

I hate Lisp because the proliferation of brackets and I have difficulties to make the opening and closing brackets match.

Anyway, after a one-day tutorial on learning the Script-Fu, my first Gimp script is born. It works as follows:
  • it adds a border to similar the print paper
  • it creates a shadow and then use the perspective effect to make the shadow irregular
  • it finally adds a background to match my blog background
I have tested my script in my two only Gimp environments, viz. version 2.2.17 (on Win98SE) and 2.6.2 (on Win XPP)

Installation steps:
  • download the script (link)
  • put it to the script directory (in my Windows environment, it is C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts)

Execution steps:

- open a photo, like


- run the script, which will solicit the following parameters


- the result is as follows:

2009-11-06

Using LINQ to retrieve XML data

Although it is like "to use a cannon to kill a mosquito", I find using LINQ to read XML has a clear advantage - to read the node like an associative array (like PHP).

I use the following VB example to illustrate:


Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xml_str As String
xml_str = "<ROOT><FIELD1>VALUE1</FIELD1><FIELD2>VALUE2</FIELD2><FIELD3>VALUE3</FIELD3></ROOT>"
Dim xmltree As System.Xml.Linq.XElement
xmltree = XElement.Load(New System.IO.StringReader(xml_str))
Label1.Text = xmltree.Element("FIELD2").Value
End Sub
End Class



I deliberately use a string to hold the XML content in this example, although the native constructor can be as simple as

Dim xmlTree1 As XElement =
<Root>
 <Child1>1</Child1>
 <Child2>2</Child2>
 <Child3>3</Child3>
</Root>

2009-11-03

Using VB 2008 Express as client to consume SugarCRM Web service

In additional to my previous example of using AXIS as web client, I now use VB.NET as another example to consume web service. Moreover, I will just the open source SugarCRM as web service provider.

SugarCRM
The wsdl link is as follows (the host name depends on your installation. I use localhost here)
http://127.0.0.1/sugarcrm/soap.php?wsdl
as shown in the following IE screen dump


VB
The set up is a little bit tricky, as the initial menu does not have any web service item. The steps are as follows:
(1) Project > Add Service Reference


(2) Click the "Advanced" button (Do not type the WDSL link yet)


(3) Click the "Add Web Reference" button


(4) Type the WSDL link and press "Go" button. The web service description will be displayed. Then choose a reference name you like (I use SugarCRM) and press "Add Reference"


(5) You will find VB has added the WS reference in the Solution Explorer


(6) Ironically, VB will now have the "Add Web Referebce" menu item available in the Project menu


7) Now you can start to write codes to consume the web service. Since my example just illustrate the principle, I have hard-coded many things. The logic is there is a Button1. If I click this button, it will call the login method of SugarCRM. The session id returned will be displayed as Label1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim soapservice As New SugarCRM.sugarsoap
Dim credential As New SugarCRM.user_auth
Dim opensession As New SugarCRM.set_entry_result
credential.user_name = "admin"
credential.password = getMd5Hash("password")
credential.version = "1.0"
opensession = soapservice.login(credential, "SugarCRM")
Label1.Text = opensession.id
End Sub


The convenience of using VB is its IntelliSense which can enumerate the available options.


I have declared three objects
soapservice - the client stub
credential - the first argument of the service, containing the user id, md5 of the password and the version.
openssion - the returned result of the service. One of the most important field is the session ID

The result is shown below

2009-10-23

CTI (Computer Telephony Integration) for SugarCRM

Recently I come across SugarCRM. It has a Community Edition which I do not need to pay. Moreover, since it is open-source, I can realize some customization easily.

I have experience in CTI (Computer Telephony Integration). But what I can search around SugarCRM is its integration with Asterisk, which is also an open source telephony project.

Because I have already an Avaya installation base, I study whether I can do some quick start work easily.

What I need are two functions:

(1) Screen Pop
To pop up the SugarCRM screen based on the Calling Line Identity (CLI)

(2) Click to Dial
Turn the phone number in the SugarCRM screen to a link that is clickable and activate automatic phone dialling

For those readers which are familar with CTI, these are just very basic features. But it is achievable for SugarCRM, this is already a great time-saver for the CRM users.

I tackle the problem in the following ways:

(1) Screen Pop
Since SugarCRM is web-based, I can simply ask the browser to navigate to a specific link.

The first question is what the link is.

In SugarCRM, I make a search with a phone number. Then I get the following screen.


Great, I find the URL is
http://127.0.0.1/sugarcrm/index.php?module=Home&query_string=test&advanced=true&action=UnifiedSearch&search_form=false&query_string=5551888&search_mod_Contacts=true
5551888 is the phone number I have typed.
Therefore in .NET code, I use:
url_str = "http://127.0.0.1/sugarcrm/index.php?action=UnifiedSearch&search_form=false&advanced=false&query_string=" _
& SkpSock1.CLID & "&search_mod_Contacts=true"
System.Diagnostics.Process.Start(url_str)
Here, SkpSock1.CLID is my CTI object to collect the CLID (Calling Line Identity) property.

(2) Click to Dial
I find SugarCRM has Skype integration, in which it will convert a phone number to a clickable link. First you need to turn this feature on in the Administration screen, as follows:

After the feature activation, you will find that when you put a mouse pointer over a phone number, you can find it the associated link is :
callto://5551234/

In Windows, each URL protocol can be managed by the "Folder Option" in the Windows Explorer. (Someone suggested registry hack. But I prefer the conventional way.)

After pressing the "Advanced" button and then the "Edit" button, you can set your preferred program to handle this protocol. In my case, I have

written a program called "qcallto.exe". Windows will pass the link a program parameter to it.

Finally, a point of SugarCRM hack. As shown in the SugarCRM adminstration screen, it requires a phone number to conform to certain format (e.g. prefixed with a plus sign). I do not like this convention. Why cannot SugarCRM simply treat all the phone number clickable?

Thanks to the PHP open sources, I find that in "c:\Inetpub\wwwroot\sugarcrm\include\utils.php" (the actual directory depends on your installation), there is a php function will determine whether a phone number is clickable:

Original:
function skype_formatted($number){
 if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
  return false;
  }
 else {
   return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' ||
   substr($number, 0, 2) == '011';
  }
 }

I change it to
function skype_formatted($number){
 if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
  return false;
  }
 else {
  return 1;
 }
}

Some final words... Although my implemented solution is Avaya-based, it is easily portable to other platforms (even for a modem connected phone line) easily.

2009-10-12

Why DC cannot shoot a picture with shallow depth of field

I carry an Optio S3 to make ad hoc photography.

According to the specification, the tiny camera has an aperture f2.6 - f4.8

However, even at an aperture f2.6, I can never shoot a picture with sufficient shallow depth of field (DOF), except in macro mode of course.

I start to ask why.

The most authoritative reference (but hard to understand) about Depth of Field is at Wiki (link http://en.wikipedia.org/wiki/Depth_of_field)

It gives complicated formula to show the relation of DOF vs. format size (though roughly speaking, DOF is inversely proportional to format size). Since my DC has a small CCD, the DOF is less shallow than the conventional SLR.

However, I try to associate the problem with APS-C or Four Thirds or micro Four Thirds.

In these cases, usually, we will use a crop factor to represent the effective focal length at full-frame (FF, at 35mm) format size . For instance, even you use a lens with 18mm on DSLR with crop factor 1.6, its effective angle of view is just same as 28.8mm at FF.

Please note that aperture is actually stated in F-number (the ratio of focal length to effective aperture diameter).

Then why not use similar the crop factor to calculate the effective DOF?

For instance, my Optio S3 has the focal length 5.8mm (equivalent to 35mm at FF). This means that the crop factor is about 6X.

Then even at aperture f2.6, the "equivalent" aperture at FF is already 6x2.6 = 15.6

This explains why I cannot shoot at shallow DOF even with the largest aperture (smallest F-number) because its FF-equivalent aperture at 15.6!

2009-10-09

Using COM objects in VB.NET

I am an old-fashioned guy and right now even though I uses VB.NET for my new programming, I still need to resort to old COM objects sometimes.

I find there is not much references to facilitate the process (e.g. I do not like command line tools). If I have a VB6 project orginally, the Studio Express can import it automatically. But if I starts a new .NET project, I find the following procedures is the quickest:

(1) Add the COM reference in the "Tools" | "Choose Toolbox Items" menu, so that the object is selectable in the left Toolbox


(2) Choose the COM Components Tab. If your object has been registered before hand, it is listed. Otherwise, click the Browse button to include it in the list


(3) Then you will find the Componet will appear in the left Toolbox. You then can drag it into your form.


(4) You will find VB.NET will automatically add appropriate references in your Project Properties, as in the following screen dump. In my cases, VB.NET add two references: one is the Interop and one is the AxInterop

2009-08-24

高清無用!

當人人都「講」高清時,我發看很多人其實都將Windows的display解像度set得比native低(可能使用者有老花?),見MSDN Blog Follow-up on High DPI resolution


從圖可見,只有55%的人用native resolution,可悲!

2009-08-06

Quick Building a Web service client using Axis

After some studies, to my surprise, building a web service client using the Axis library (not the web service itself) is in fact very easy. I would like to summarize my experience in this blog.

  1. Download Axis from the Apache web site and expand the zip file (Remark: in fact the whole package includes the server code. To build a client, only the jar files are needed. But for simplicity and because of the limited extra hard disk space, I recommend to expand the whole package).
    In my example, I have downloaded Axis version 1.1 and put it at /home/craft/whc/axis-1-1

  2. Download the WSDL file of the web service. In this case, I have chosen the free stock quote example at webservicex at http://www.webservicex.net/stockquote.asmx?wsdl and store it in /home/craft/whc/StockQuote.wsdl

  3. Use the WSDL2Java tool from Axis to crate the stub codes. Since we need to refer to the jar files in the Axis, I have built a script with classpath set appropriately
    #!/bin/sh
    java -classpath "/home/craft/whc/axis-1_1/lib/axis.jar:
    /home/craft/whc/axis-1_1/lib/log4j-1.2.8.jar:
    /home/craft/whc/axis-1_1/lib/commons-logging.jar:
    /home/craft/whc/axis-1_1/lib/commons-discovery.jar:
    /home/craft/whc/axis-1_1/lib/wsdl4j.jar:
    /home/craft/whc/axis-1_1/lib/jaxrpc.jar:
    /home/craft/whc/axis-1_1/lib/saaj.jar"
    org.apache.axis.wsdl.WSDL2Java StockQuote.wsdl
    The resultant files will be created at /home/craft/whc/NET/webserviceX/www

  4. Create the simple client code (StockClient.java) as follows (I have hard-coded MSFT (Microsoft) for the stock code)
    import java.net.URL;
    import org.apache.axis.client.Service;
    import org.apache.axis.client.Call;

    public class StockClient {
    public static void main(String[] args) throws Exception {

    NET.webserviceX.www.StockQuote service = new NET.webserviceX.www.StockQuoteLocator();

    NET.webserviceX.www.StockQuoteSoap port = service.getStockQuoteSoap();
    String result = port.getQuote("MSFT");
    System.out.println("Result = "+result);
    }
    }

  5. Compile the client code with a script as follows (Please note that I have deliberately omitted the wsdl4j.jar because the wsdl file is no longer processed at run time and ass a dot (current directory in the classpath)
    #!/bin/sh
    javac -source 1.5 -classpath "/home/craft/whc/axis-1_1/lib/axis.jar:
    /home/craft/whc/axis-1_1/lib/log4j-1.2.8.jar:
    /home/craft/whc/axis-1_1/lib/commons-logging.jar:
    /home/craft/whc/axis-1_1/lib/commons-discovery.jar:
    /home/craft/whc/axis-1_1/lib/jaxrpc.jar:
    /home/craft/whc/axis-1_1/lib/saaj.jar:." StockClient.java

  6. Run the complied class file (again, I have used a script to add the classpath. Moreover, since we need a http proxy to access the internet, I have defined these properties in during invoking the JVM using the -D switch
    #!/bin/sh
    java -classpath "/home/craft/whc/axis-1_1/lib/axis.jar:
    /home/craft/whc/axis-1_1/lib/log4j-1.2.8.jar:
    /home/craft/whc/axis-1_1/lib/commons-logging.jar:
    /home/craft/whc/axis-1_1/lib/commons-discovery.jar:
    /home/craft/whc/axis-1_1/lib/jaxrpc.jar:
    /home/craft/whc/axis-1_1/lib/saaj.jar:." -Dhttp.proxySet=true -Dhttp.proxyHost="10.36.250.25" -Dhttp.proxyPort=8080 StockClient

    The result is follows:

    [craft:/home/craft/whc (465)] run_client.sh
    Result = <StockQuotes><Stock><Symbol>MSFT</Symbol><Last>23.81</Last><Date>8/5/2009</Date><Time>4:00pm</Time><Change>+0.04</Change><Open>23.93</Open><High>24.25</High><Low>23.79</Low><Volume>53310240</Volume><MktCap>212.2B</MktCap><PreviousClose>23.77</PreviousClose><PercentageChange>+0.17%</PercentageChange><AnnRange>14.87 - 28.50</AnnRange><Earns>1.619</Earns><P-E>14.68</P-E><Name>Microsoft Corpora</Name></Stock></StockQuotes>

2009-08-04

老年十忌

新開幕的時候,曾到過中央圖書館,但發覺很吵鬧,所以也沒有再去了。

近日心血來潮,去打打書釘,發覺環境清淨了很多,真是可喜可賀!

見到國寶季老季羨林的新書《真話能走多遠》,有一篇【老年十忌】,以季老90多年歲寫這題目,特別有份量,同時亦覺得他的開明!

以下其十忌(其實只有九忌)
  1. 說話太多

  2. 倚老賣老(還有一很傳神的翻譯 To take advantage of out's seniority or old age)

  3. 思想僵化

  4. 不服老

  5. 無所事事

  6. 提當年勇

  7. 自我封閉

  8. (不見了)

  9. 老想到死

  10. 憤世嫉俗
希望自己老的時候還記的季老的教誨!

2009-07-31

中國現行稅制

在整體舊資料時,找到一份n年前在清華大學參加短期「中國營商管理研習班」的講義。

以下是經濟學院陳關亨博士《中國現行稅制》的部份內容:

主體稅種

增值稅

營業稅

外商投資企業和外國企業所得稅

簡介

對生產、銷售商品或提供勞務過程中實現的增值額徵收的稅種

以經營活動的銷售額為稅基的一稅種

對在中國境內的外商投資企業(包括中外合資、中外合作和外資企業)和外國企業的生產、經營所得和其他所得徵收的一種稅

稅基

增值額(小規模納稅人用銷售額)

營業額(銷售額)

業務收入淨額+其他業務利潤+營業外收入

稅率

17%(但小規模納稅人的徵收率為4%

一般為3~5%

一般為30%

中國企業CEO失敗的的八大原因

在整體舊資料時,找到一份n年前在清華大學參加短期「中國營商管理研習班」的講義。
以下是經濟學院鄭曉明博士在《中國企業永續經營》的部份內容:

  1. 缺乏對壞消息的處理能力
  2. 投機性太強
  3. 盲目的擴張與多元化
  4. 缺乏財務知識
  5. 決策的獨斷和無制約
  6. 疲勞綜合症
  7. 缺乏處理人的能力
  8. 沒有一個堅貞不渝的團隊

東西方文化分別

在整體舊資料時,找到一份n年前在清華大學參加短期「中國營商管理研習班」的講義。

以下是經濟學院張力軍在《跨文化管理與溝通》的部份內容:


西方

東方

自然

控制自然

聽天由命

避免不確定性行為

忍受不確定性

人類行為的本質

行動

等待

成就

歸屬

真實與現實的本質

數字事實

感覺

現實是物質的

精神

人的本質

人性本善

人性本惡

人際關係

工作、成就

社會福利

人人平等

等級

個人主義

集體主義

空間

公共的

私人的

語言

直率的

含蓄的

客觀的

情緒化

時間

有限的

無限的

現在與將來

過去與將來

2009-07-10

Using Less to view Huge Log files

My job requires me to view large application log files (several hundred M bytes). My original favourite editor, Crimson editor has limitation because it loads the full file into the computer memory.

I try to find other alternatives and have tried LTF (Large Text File) Viewer but I find it has problems to search the patterns even though I do know it exists in the file.

Moreover, these editors still resort to load a large portion of the document into the computer and consumes many CPU resources.

Suddenly I think why I do not resort to the orginal text mode utitlies. A popular is less (wiki)

But if I can make the command prompt window bigger and customize the font, the user-experience will be much better.

I have written a batch file to use the "mode" and "color" command for this customization.

The full steps of installation are:

1. download the less in in here
2. Put the download into a directory (e.g. c:\bin\less429)
3. Create a batch file (e.g. less_big_win.cmd) which contains the following lines

@echo off
mode 160,40
color 0A
c:\bin\less429\less.exe %1

4. Associate a file type with the batch file



5. Open the log file using less


6. After opening, the less application is displayed in 160x40 new window:



7. Although my file has nearly 200M byte


you can see in the Task manager, it only consumes less than 1.5M bytes

2009-07-04

嚴重抗議香港郵政之通函郵寄服務

香港郵政為了增加收入,發明了所謂《通函郵寄服務》,即發件者不用個別地址,便可濫發郵件,將無用的宣傳郵件放在我的信箱內。

我家大廈有保安員,普通人士不能隨便將宣傳品放在住宅信箱,但郵差叔叔就出入無阻。

我曾向香港郵政投訴,要求不要再接收所有的通函郵寄件,但不獲受理!

最近發覺香港郵政派發的通函郵寄件,都有一些要用放大鏡才可看到的所謂「不收取通函」聲明,註明如不欲繼續收取本機構發出的通函,請把你的地址郵寄xxxx(即個別商戶的通訊地址)。

哪有住戶那麼有心,一個一個商戶的通知,還要自己出個幾郵費,香港郵政又可漁人得利!

香港郵政自己不做把關工作,不尊重市民的權利,只將自己部門的收入放在最重要的位置。

強烈要求香港郵政懸崖勒馬,給我卑微的信箱一個喘息的機會,給地球一個減少廢紙的機會!

2009-06-20

涼宮春日的憂鬱 之 人擇原理

聽同事講TVB J2的《涼宮春日的憂鬱》卡通片(見維基百科有關涼宮春日系列的介紹),由於深夜才播,故錄了6月12日凡的第13集(J2內容簡介)看看。

一看就嚇親,內容居然講人擇原理維基)!

簡單來說,人擇原理是講宇宙是現在的樣子,是由於人類的觀察。因為人類(觀察者)的智慧,才確定了宇宙的存在!

卡通片繼續講有關重成常數、粒子質量和物理法質的概念。

自問第一次接觸有關Anthropic Principle概念時是n年前閱讀 Stephen Hawking 的普及讀物 "A Brief History Of Time",現在局然在卡通片看到,這簡直不是一套普通的卡通片!

再做少少googling,原來已有很多人講此話題,如 陳信一的世界 自神論與涼宮春日

2009-06-19

人類豬型流感之細菌與病毒

近來人類豬型流感(所謂2009美洲H1N1)在世界各地漫延,而本港各機構也廣為宣傳叫市民注意公共衛生。

但令我最感奇怪的,就是聽到那句「預防細菌散播」。

我甚至聽到有醫護人員在人類豬型流感新聞訪問中用細菌來形容H1N1病毒!

中學程度上也應該知道細菌和病毒跟本不同!

隨便Google也可找到n篇文章講其分別,如:細菌與病毒有何區別?

香港的衛生水平仍停留在1比99和口罩的水平!

2009年6月25日後補:

在茶房發覺連洗手液也是這樣混淆不清!

2009-05-26

VB Script to Switch Proxy Server

I need to switch proxy server frequently. For Firefox, there is a handy add-on called FoxyProxy. However, for Internet Explorer, I have resorted to write a VB script called switch_proxy.vbs and put it on a convenient point (either at Start menu or on Desktop)

After clicking it, the following selection menu will pop up:

For instance, if option 1 is selected, then the acknowledgment dialogue will display to confirm the new setting:

On the other hand, if option 0 to disable the proxy setting, the following dialogue will be shown:

The source code is pasted as follows:



Rem Change the following entries to suit you name
ProxyName1 = "Proxy Server 1"
ProxyServer1 = "proxy.server1.com"
ProxyPort1 = "8080"
ProxyName2 = "Proxy Server 2"
ProxyServer2 = "proxy.server2.com"
ProxyPort2 = "8080"


Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"

strValueName = "ProxyEnable"
objRegistry.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
IntProxy = strValue

strValueName = "ProxyServer"
objRegistry.GetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
StrProxy = strValue

dim usr_input
usr_input=InputBox("Current ProxyEnable = " & IntProxy & chr(13) & chr(13) & _
"Current Proxy Server = " & StrProxy & chr(13) & chr(13) & _
"Enter New Choice :" & chr(13) & chr(13) & _
"0 : Disable Proxy" & chr(13) & _
"1 : " & ProxyName1 & chr(13) & _
"2 : " & ProxyName2 , _
"Proxy Management")

if usr_input = "" then WScript.Quit

Select Case usr_input
Case "0"
strValueName = "ProxyEnable"
dwValue = 0
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

Case "1"
strValueName = "ProxyEnable"
dwValue = 1
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

strValueName = "ProxyServer"
strValue = ProxyServer1 & ":" & ProxyPort1
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue

Case "2"
strValueName = "ProxyEnable"
dwValue = 1
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

strValueName = "ProxyServer"
strValue = ProxyServer2 & ":" & ProxyPort2
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
End Select

strValueName = "ProxyEnable"
objRegistry.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
IntProxy = strValue

strValueName = "ProxyServer"
objRegistry.GetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
StrProxy = strValue

MsgBox "ProxyEnable = " & IntProxy & chr(13) & chr(13) & "Proxy Server = " & StrProxy, ,"New Proxy Settings"



You can change the first few lines of sources to reflect your requirement.

2009-05-16

命定論

又是另一嚴肅的題目!

事緣近來在明珠台再看星球大戰(By the way,我不喜歡電視台跟電影上映的次序,即Episode 4,5,6,1,2,3,來播出,所以我錄影後再跟原情節time-line看Episodes 1-6),常常聽到的一句話:This is your destiny!

的確,近來觀察身邊人,他們的行為都是某程度上受到其性格和天生的優缺點影響,尤其是年紀越大便更明顯。

佛家有講的「習氣」,現代也講基因影響行為。

年少時,覺得甚麼也可改變,所謂「命運在我手」,現在年紀大了,覺得世界在變,反而要自己變是最困難的!

自從牛頓的機械宇宙論發展到量子力學,其中的Uncertainty Principle最教我迷思,我們只可以用Probability Density Function來描述宇宙,但是當中的Randomness有多random?

數學或電腦學中,我們只有pseudo random number generator。

佛家講無常。

或者,是不是人生的過程就是體驗sigma (standard deviation)趨向zero?

2009-04-12

另類中文輸入法

我愈來愈相信我有中文書寫障礙,因為要我寫(或用電腦打)中文時常常忘記個字形(只得個字音在腦中蕩盪來盪去),但閱讀就沒有問題。

另一方面,由此英文是拼音,我英文spelling也沒有問題,所以以前我曾有英漢字典來找出我想寫的中文字,真有點諷刺!

其實中文輸入法有廣東話輸入法,但是最大的門題是:除常用的姓名外,我發%稅有多字我都不識其廣東話拼音。例如不知「賺」是"jaan"等。

後來,在網上download了廣東話輸入法的dictionary,不過我沒有安裝,反而我將它轉成html而在browser內search!方法如下:

  • 如果我知道廣東話拼音是"hung",我可直接search到「空」、「 雄」、「 紅」、「 控」等。

  • 如果我不知道廣東話拼音但記得另一同音字,如我忘記「賺」,但記得「讚」,我也可用 「讚」來search

有興趣的朋友可參考!網址如下

2009-03-03

Internet - a world without friction

When I study physics in my junior secondary years, my teacher asked me what the world would be without friction. While I was told that friction causes energy loss and reduced the efficiency of the systems, I was also aware that friction has also a place in the world to make us live better - when we saw the cars skied on an icy road!

At the time, I have made an internal conclusion - friction is good so long that it is not too strong. I draw an analogy with inflation, which most of us thinks it is good if it is, say, below 3%

When internet grows more popular, I find this "second world" is a world without friction. We can use copy-and-paste to replicate information, instead of photo-copying or hand jotting. We can search information by googling instead of browsing the catalogue in the library. We can send mails to friends and they can nearly instantly receive them instead of waiting for days as in the normal postal paper mail.

However, in a recent news report, I heard parents complaining about their lack of control on their kids how they use internets. The parents urge the government to take a more active role to make the internet "safer" to use.

While I have no kids and cannot comment on the difficulties of a parent, I try to view the problem in an alternative way.

The root problem is that in this world, there are bad guys. In a world with friction, there are hurdles for bad guys to contact us or vice versa (actually the hurdle also applies to good guys). Worst still, with the anonymity in internet, we cannot easily identify whether a guy is good or bad.

I try to draw another example. If a bad guy wants to fool somebody in the non-internet world by saying he/she is a banker, he/she may have to waste some effort to set up a fake office with a XXX bank logo. Because of relatively higher setup cost (friction), the bad guy will not make it easily unless the target fraud is a much higher amount of money!

On the other hand, in the world of internet, setting up a fake bank web site is much easier and cannot be easily trapped. Therefore the bad guys will easily spread the net to trap some innocent victims.

I consider this is just a problem of awareness. For instance, even in a phone call, we should not tell a caller our personal details, even though he/she is indeed from a famous (but foolish) university conducting a survey.

When one speaks loudly in the public transport on a phone call about his/her personal life, phone number, address etc, please do not say the pubic transport has not protected his/her privacy!

2009-02-26

我撐馮禮慈:不要消費

看2009年2月19日第248期【溫暖人間】,馮禮慈在《一望無際》講「救市……不要消費」。

他擔心在主流媒體這樣講會被罵到狗血淋頭,覺得【溫暖人間】的讀者想法會比較接近。

無錯!我十足同意馮禮慈的見解。

自從西方凱恩斯理論流行,(其實中國的保8的現在政策也不是一樣?)政府的有形之手被期望成救世主,但其實效果如何?(君不見日本經濟衰了多年?)

我覺得這好比我們感冒就去看西醫叫他開抗生素!而不會自行休息休息,以致身體缺乏抵抗力決越來越差。

人倒容易將問題外圍化而忽略自身的問題!

2009-01-31

馬多夫騙案與生育

知道外國有龐大的種金式的金融騙案【馬多夫騙案】爆煲,其實自己一直以為更大的案例就是社會保障系統,不過覺得無o麥人講,終於看許沂光才知香樹輝也發表同題的評論(連結


由於有名人出聲,也不用再多題。今次論生育。

生活了幾十年,自問還未了解生命的意義,所以對生育問題也是不了了知。聽過有父母講育兒的過程就可發現生命的意義,大概是繁衍論人云云,但講不到具體內容,只是說感受其中過程就可體驗,好似好宗教性,甚至像引誘人嘗試吸第一毒一樣!

最不恥的就是聽過有父母講育兒的目的就是以便自己老來可以有仔養,所謂「養兒防老」,這不何嘗不是另一種馬多夫騙案?

其實也想談談馬多夫騙案與婚姻,不過想來想去,還是覺得用錢鍾書的【圍城】比較貼切!