2008年10月31日 星期五

monitor HSI if it reaches 10676 in 5 to 7 weeks.

過去歷史低位必需Re-Test。10676點必須面對考驗,企得住再算。通常需要五至七星期。即五到七星期內恒指唔再創新低,10676點先算係 強力支持;即最早明年1月,最遲明年3月先知道本周10676點係咪見底(只有1987年10月股災,Re-Test喺三十四個交易天後便出現)。投資者 唔使估底,只需等候Re-Test便可。如喺五至七星期內恒指低於10676點,即最近幾天只係一次強力反彈。有咗呢個武器,你便唔使加入估底行列。

Monitor HSI:10676 if it will reaches again by December. If HSI drops lower than 10676, then it confirm there is rebound starting on 28 Oct and 10676 is not a bottom.

2008年10月25日 星期六

A happy weekend

On this Saturday, I went out for a whole day. Many thanks to my colleagues in Taipei call me come out for fun. Starting at 1000 in the morning, we went to one of my colleagues owned shop for chatting and drinking Chinese tea with some snacks. Talking, chatting, eating for almost two hours, which is not common in Hong Kong. In Hong Kong, normally, we go out to yam cha that you need to eat more than talk. The time is very leisure and the feel is good though I am quite tried to talk too much.

At noon, we went out for meal in Wing Hong Street (永康街), a famous food street in Taipei. That was a Taiwanese-style Japanese restaurant serving BBQ food that located almost opposites of a open space carpark. The food is very good as it cooks just after you make a order. However, it is a kind hot as sunshine was at our back. Then at about two, we went to play badminton. Interestingly, we'd spent almost 3 hours together to pick the racket and to reach the badminton hall in Lo Chau (廬州). Since our guide forgot where it is and we drove around and around, asking pedestrian and police. My colleauge told me in this area, people normally speaks in local Taiwanese but not Chinese that makes them some worry how to communicate. I wonder if they don't know Taiwanese. Finally, a Taxi driver pointed us to right direction and a old man confirmed us there is a badminton hall. Yet before we met the old man, we suspected for a while there was no badminton hall in the area.

Well, we played for over 1 hours and my whole body is very pain now. Very good exercise and fun. Then we went back to Taipei city for dinner at a BBQ and hot pot restaurant just behind my staying hotel at eight o'clock. It is very convienence for me. That restaurant is good and it costs us NT$480 per person with unlimited food. They also server Hagen Dias and Japanese ice-cream too. Very full and joyful dinner this night and I'm really happy to meet those friends there and have a very good time.

From BBQ and Hot Pot in Taipei

I am still wondering the chance for me to work in Taipei and to meet so many exciting and interesting things and people there. This is a very interesting and different experience that makes my life has more stories to tell.

2008年10月15日 星期三

Error executing POSTGIS DECLARE (the actual query) statement

What is this?
-----8<-------8<-------
msDrawMap(): Image handling error. Failed to draw layer named 'bc_voting_areas'. prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from bc_voting_areas WHERE the_geom && setSRID('BOX3D(1421927.909699 176424,2103636.090301 687278)'::BOX3D, find_srid('','bc_voting_areas','the_geom') )' Postgresql reports the error as 'ERROR: column "oid" does not exist LINE 1: ...inary(force_collection(force_2d(the_geom)),'NDR'),OID::text ... ^ ' More Help: Error with POSTGIS data variable. You specified 'check your .map file'. Standard ways of specifiying are : (1) 'geometry_column from geometry_table' (2) 'geometry_column from (sub query) as foo using unique column name using SRID=srid#' Make sure you put in the 'using unique column name' and 'using SRID=#' clauses in. For more help, please see http://postgis.refractions.net/documentation/ Mappostgis.c - version of Jan 23/2004. msPOSTGISLayerRetrievePGVersion(): Query error. Error executing POSTGIS statement (msPOSTGISLayerRetrievePGVersion():select substring(version() from 12 for (position('on' in version()) - 13))
-----8<-------8<-------

I try to connect PostGIS using Mapserver with sample database from PostGIS. My map file is as follows:

# Start of LAYER DEFINITIONS ---------------------------------------------
LAYER
CONNECTIONTYPE postgis
NAME "bc_voting_areas"
CONNECTION "user=postgres password=postgres dbname=tester host=localhost port=5432"
DATA "the_geom FROM bc_voting_areas"
STATUS ON
TYPE POLYGON
CLASS
COLOR 255 255 200
END
END
# End of LAYER DEFINITIONS -------------------------------

I have verified the above layer definition thousand times and don't know what happen.
Then, I have to read the error message again and again to see what can I do. Just spot a strange message "ERROR: column "oid" does not exist LINE 1:" meaning the system is looking for "oid" but it does not exist. I go to check the table. Bingo, no "oid". It seems this is the cause, but why there is no "oid" populated?

Finally, thank to the Internet, I've found the following message:

> New version of Postgresql (8.1) does not create OID column by default
> when creating a table (oid is globally unique identifiers used by
> Postgresql and also used by Mapserver to uniquely identify a row of
> result).
>
> My solution was to enable oid-generation in postgresql, by editing the
> postgresql.conf (in the postgresql/8.1/data folder)
> Search for "default_with_oids", uncomment the line and set the
> variable value to "on".
> Then, regenerate your postgis tables.


Then I check the postgis documentation again and find a section called "Using Mapserver". I think I should have read it before starting the test.

The cause is that there is missing oid and I need to create it for mapserver as it requires oid to work properly. Then I run the following two commands to create and index oid in the bc_voting_areas table.

1. alter table bc_voting_areas add column oid serial;
This command adds a new serial column called oid in the table.

2. create index bc_voting_areas_oidx on bc_voting_areas (oid);
This simply creates a new index.

I can output a map with the following link finally.

http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/postgis/postgis.map&layer=bc_voting_areas&mode=map

Cheers... Keep exploring postgis, postgres and mapserver.

2008年10月6日 星期一

The Rules Of Life

股聖、Dennis Gartman及Puggy Pearson)都係投資界泰斗,他們訂下九大守則,投資者只要遵守便「麥克、麥克」。(信報財經新聞, 2008.10.07)

前三條由股聖所訂。一、唔好輸錢。一旦面對虧損便設法減少損失(我老曹將佢改良為止蝕唔止賺)。

二、股票市場設計係將金錢由經常性買賣者手中轉到有耐性投資者戶口中。平時遠離證券行,唔好經常炒出炒入。

三、投資者需要的是氣質(Temperament)而唔係智慧。例如獨立思考、對自己有信心而唔係過分自信及控制個人情緒(我老曹改為有智慧不如追逐趨勢)。

另外三條由Gartman所訂。一、屋內永遠唔會只有一隻曱甴。正係福無雙至,禍不單行。去年8月次按危機後,至今金融機構接二連三出現問題,證明永遠屋內唔會只有一隻曱甴。

二、喺牛市中可長線持有,熊市中只宜拋空(我老曹改為牛市中不妨做好友,一旦熊市來臨便持盈保泰,因我老曹冇膽拋空)。

三、只有基礎分析與技術分析一致先入市,投資集中優質股,入市時機用技術分析。

最後三條由Puggy Pearson所訂。一、20/80定律。無論喺賭場或期指市場,贏家只佔20%,輸家佔80%。要成為20%少數,必須明白Top Down或Bottom Up策略(何謂Top Down?例如去年10月股市見頂後便保持睇淡,直到出現一浪高於一浪為止;何謂Bottom Up?即股市見底後便保持睇好,直到出現一浪低於一浪為止)。利用Pearson嘅方法,各位唔使經常問我老曹熊市幾時完?喺恒指一再出現新低環境下只宜 Top Down。

二、學會管錢。好似賭錢咁,冇理由鋪鋪買,只有形勢最有利時先賭,同時限注(例如熊市中,只動用30%資金,牛市中才動用70%資金)Keep It Simple;唔好賭你輸唔起嘅錢,賭錢時要輕鬆而唔係搏殺;明白風險與回報關係。一如沙蟹,當形勢有利時去盡D,形勢不利時要識投降(唔好忘記止蝕沽盤)。

三、了解自己,嚴守紀律。大部分人賭錢往往輸死而唔會贏死。理由係贏錢時縮,輸錢時賭氣。成功賭徒及成功投資者便相反,就係贏錢時去盡D,一旦輸錢便縮。

上述三位都係當今投資泰斗,值得各位學習。只要善用九大方法,保證你六十歲退休時富有。

Error parsing Geometry

I follow a postgis workshop document to learn postgis. There is a instruction to insert three records manually and then do some calculation with a operator "ST_Distance".

However, whenever I use it, it returns an error. I don't know why but I suspect there is problem in the SRS.

It is just a simple query:

create table points ( pt geometry, name varchar );
insert into points values ( 'POINT(0 0)', 'Origin' );
insert into points values ( 'POINT(5 0)', 'X Axis' );
insert into points values ( 'POINT(0 5)', 'Y Axis' );
select name, AsText(pt), ST_Distance(pt, 'POINT(5 5)') from points; < This returns error in parsing geometry. Why?

2008年10月2日 星期四

給老婆看的文章

親愛的老婆,

請細看,下次做facial時請留意:

美容、瘦身業的銷售方法-行內人 (信報財經新聞, 2008.10.2)

近年美容、瘦身行業發展蓬勃,行業利用較為特別的宣傳、推廣和銷售方法,以下介紹一些和顧客相關的方法,供大家參考。

在宣傳和推廣方面,大多起用廣為大眾熟悉的名人作公司代言人,特別是演藝界人士,由於他們有不少支持者,所以較容易引起潛在顧客關注公司的產品和服務。
優惠

在宣傳過程中,公司通常會以一個較低價錢來吸引顧客惠顧,這是一個「全包價」,令到顧客感到十分優惠,但通常他們忽略了這些超低價錢只是吸引顧客接觸公司的第一步,有了這個接觸,公司便盡力銷售其他服務,而這些額外服務或產品,價錢大多十分高昂,令顧客以數十倍的價錢來購買一些原先沒有想過要的東西。超低價的服務其實附帶很多限制。

為了達到銷售目的,銷售人員會盡量把顧客與外界隔絕,把他們留在狹小房間內,鼓勵顧客拿出信用卡,並提出可免息分期,變相增加了顧客的承擔能力,在這些壓迫銷售環境下,不少顧客也會中招,買了一些昂貴但沒需要的服務。

為了保障自己,不少合約條文都是以保障公司為原則,個別不良商戶或其銷售人員,更可能口頭承諾提供優惠甚至誤導顧客,及後顧客投訴時,才發現這些優惠或原先承諾根本不存在或無效。

另外,一些較常用的優惠手法是套票或綑縛式銷售,即要顧客購買或多次使用相同服務,即套票,平均價錢十分低;而綑縛銷售是讓顧客以平均較便宜的價錢使用不同類型服務,目的是讓顧客感到有着數。

由於購買了套票,顧客是會重複接受服務,公司當然不會放棄繼續向顧客銷售其他服務和產品,目的當然是增加銷售。
顧客需要

更有趣的是,一般套票是有期限的,即在指定時間之前使用,否則無效。有些公司並沒有放棄持有逾期套票的顧客,仍十分積極去約見這些顧客。見到顧客後得知他有興趣用套票的話,便給予適量的續期,但顧客須補回一些費用。此外,若顧客對套票服務沒有興趣,公司銷售人員會轉為銷售其他服務或產品,同樣是壓迫銷售,以及利用套票剩餘價值來購買其他服務和產品。購買愈多新服務和產品,折扣愈高,希望顧客有買得愈多愈平的感覺。

這些美容和瘦身公司的不良銷售方法當然不值得推廣,但他們以套票、綑縛式銷售,並積極接觸顧客,不斷向他們銷售,他們對顧客需要的了解,可給其他公司借鑒。當然公司不要介意向長期和忠心的客戶提供價錢上的優惠,以保留好客。

2008年10月1日 星期三

Brilliant people and competent people

I've just read an article about commercial software vs. open source software. For open source software, those users are expected to have much knowledge in problem solving. For commercial software, you would definitely rely on vendor to solve your problem. Unfortunately, my experience tells me they always fail or they cannot provide you a best solution. Interesting, but I don't admit it as mentioned in the article that commercial vendor is likely to make simple problem harder to solve and so telling you they are the only one who can solve the problem. Well, it gives a good reason to use and buy their software.

I worked in two GIS vendors before. I think this could be one of the strategies to sell, and it should be a good one. However, to use this strategy you should have a idiot customer and they do have much money in their pocket willing to spend as well. Recalling my experience, there is an example in my mind. Vendor A solution became obsolete and that vendor B approached them. However, Vendor B didn't has solution and still made the deal.

To build a system, you have to solve many difficult problem technically or psychologically. What I mean psychologically is about people management. Anyway, I agree with the writer of the article that there are two kinds of people and there is a very nice division of work.

For hard/difficult problem, we need a lot of people to solve it, right? The answer is "No". We need a few brilliant people to solve hard problem, and we need a lot of competent people to implement solution. As in very large map database company likes the most biggest one in the world, just only a few brilliant people can control definition of database scheme, design and workflow, the reminding tasks would be done by a pool of competent Engineering people.

Having a crowd of developers with no clue what to do is just ineffective and definitely more costly. Having a few developers with a strong sense of direction is what we are striving for.

In any case, when choosing software, do think, do research, not just hear what the Sales and Marketing people tell you.

Do "Think" is much useful than hard working and this is the difference between brilliance and competence.

Comparison Between Open Source and Commercial Software

Loading data into Postgis

Recently, I've tried to use Postgis and understand how it works. Perhaps, I can use it in the future. Postgis is not a standalone program but it is a spatial extension of Postgres, which is an open source object-relational database system.

To load data into Postgres with Postgis, I have the following is ingredients.

1. Postgres 8.3.4; It can be downloaded from http://www.postgresql.org/
2. A shape file data. You can use any shapefile you can find it anyway.
3. A compatible windows environment, I use my notebook running Windows XP for this test.

Steps:
1. Install Postgres;
During installation of Postgres, it will ask you to define superuser password. I define it by myself, otherwise, system will create a very secure password for you, which is impossible to remember. In addition, system will ask you to create a new window account for services control.
2. Using Application Stack Builder in Postgres to download and install Postgis.
You need the superuser password to complete this task.
3. Prepare environment to run
i. Copy the following files from Postgres to a c:\temp\pgtools
comerr32.dll
country.sql
gssapi32.dll
k5sprt32.dll
krb5_32.dll
libeay32.dll
libiconv-2.dll
libiconv2.dll
libintl3.dll
libpq.dll
pgsql2shp.exe
pg_dump.exe
psql.exe
shp2pgsql.exe
ssleay32.dll

ii. Copy the shapefile to c:\temp

4. Run the following command converting shapefile to postgres sql
>shp2pgsql c:\temp\country country > country.sql

After this, a country.sql will be created.

5. Run the following command to load the sql into postgres
>psql -d postgis -h localhost -U postgres -f country.sql

After step 5, you can open pgAdminIII to check your database and you will find a new table called "country".