Wednesday, August 14, 2013

NASCAR真人騷

我對真人騷相當抗拒,原因?太戲劇化!「真」的成份不高。不過最近卻看了一個,是汽車添加劑製造商Peak贊助Michael Waltrip車隊招一名新成員受訓。參加這個節目的車手經過多重考驗,當然少不了賽車,也有鬥快速避開障礙(例如賽事進行中遇到的壞車),鬥短時間進出維修站,還有非賽車:演出為Peak宣傳的廣告片,鬥演得好。睇開美國賽車的朋友都知Peak現任代言人是新聞多多的Danica Patrick, Danica有在節目出現指導參加者做廣告所需演技,她算駕輕就熟了。有人睇有車睇,這個節目總算冷場不多。我支持這個節目的另一個原因是Michael Waltrip車隊的車手: Michael Waltrip作為車手戰績不俗(兩次贏得Daytona 500大賽),車隊論budget算不上頂班,旗下卻猛將如雲:包括老而彌堅的Mark Martin,爭標前列分子Clint Bowyer等等。

Tuesday, August 13, 2013

Progressive Insurance Radio Ad

I don't like watching their TV commercial. The actress is probably quite good at acting but she's NOT pretty and looks kinda annoying (even though I know she has many fans) Man, its radio ad is even worse! I hear them a lot on TuneIn radio. Apparently I'm not the only one who couldn't stand them. Check out these negative comments on the forum of another online radio site.

Monday, August 12, 2013

爵士高手雲集聖荷西

第一次去要收費的聖荷西爵士音樂節,十幾年前去還是免費,不過廿元入場費可看足全日,也是超值,希望大會給音樂人的報酬好一點。這位音樂人分享他在夏日音樂節的報酬及經驗,甚為有趣。

下午三點到達downtown,最近在附近學結他所以對泊車情況也略知一二,找到隔幾條街的免費車位再踩車過去慳了五元。具體地址也沒有事先看地圖,總之向人群及音樂的方向踩就不會錯,原來是用圍欄包著市中心廣場(即博物館及Fairmont酒店對出那個)圍欄以外也有表演場地,都不見收費站!似乎可付可不付,我也沒有多探究,總是先去圍欄入口買票吧。再看看節目表,原來Fairmont酒店內就有一場Touch of Brass Big Band,老實說甚少聽Big band,這個演出還有女歌手,唱得甚為動聽。

四點鐘到上演「重頭戲」的Main stage看Javon Jackson with Les McCann and Dr. Lonnie Smith. 後兩位是玩Soul jazz keyboard的元老級人馬,McCann除了彈琴還唱歌,唱的藍調很有味道。我雖然不喜聽vocal,接連兩場聽了一點還可接受。Dr. Lonnie Smith則是我一向十分推崇的organist,彈起來總是霸氣十足又游刃有餘。

五點鐘節目表列了在Fairmont演出的是Joe DeRose and Amici.單看名字,直覺上是一男一女前者彈後者唱的組合(例如Tuck and Patti),在官網仔細看看卻是另一回事:DeRose是一位出自Berklee的fusion jazz鼓手,Amici是指和他合作的樂手好友,其中包括我以前也聽過並甚為欣賞的結他手 Hristo Vitchev,當日他用Tele彈出的聲同fusion十分夾,solo非常精彩。6弦Bass手Dan Robbins的技術同樣令我歎為觀止。他們的原創作品各有特色,例如其中一首由DeRose介紹乃係源自一條在座友人提供的bass line/riff.



六點鐘重回Main stage是為了看著名Smooth jazz色士風手兼電台節目主持人Dave Koz and friends,是那幾個friend?後來才知,總知意外驚喜。雖然論深度Smooth jazz無法和"Real"(傳統/主流/現代) jazz相比,但我其實一直都不太抗拒,說到底當天如果沒有聽Kenny G今天的我會不會聽及玩jazz也是疑問。和Kenny G相比,Dave Koz給我的感覺更懂得製造商機;近年Smooth jazz大衰退,他就和其他幾位和他知名度不相上下的色士風手合作同台演出,搞得聲勢浩大頗有突圍而出之感。雖然這個說法有點不尊重女性音樂才華,但有點姿色的女色士風手一向受人注目,以前就有Candy Dulfer,今次的Mindi Abair亦肯定增强這個lineup吸引力不少。這次演出更是明刀明槍搞大眾化:玩的都是70/80年代的pop/R&B/soul/funk作品,包括翻玩Sly and the family stone, Earth, Wind and Fire, James Brown, Herb Alpert,台下觀眾明顯相當受落,很多聞歌起舞。(雖然主流爵士網評一如所料對此不以為然)
(Left to right: Gerald Albright, Dave Koz, Mindi Abair, Richard Elliot)
總括來說我很高興去了這次音樂節,短短四小時也十分滿意。

Wednesday, July 31, 2013

Everybody wants to rule the world: Blues version

I've just learned about a few new releases from Concord/Telarc's newsletter. One of them is 7 Cities by the blues rock group Moreland & Arbuckle. This is the first time I heard of their music. The most special track to me is their cover version of "Everybody wants to rule the world," the huge hit of Tears for Fears.

Tuesday, July 30, 2013

意外驚喜

由於放假加上聲樂節目關係,已有個多月未去過Noontimeconcerts,今天的節目終於輪到我喜歡的弦樂四重奏(曲目是Smetana, Borodin的作品)。出車後,發覺沒有帶單車鎖,唯有由聽音樂改為到唐人街買野食;一如所料,金門餅家又放假。再到園林點心,竟然見到牛脷酥!這是我在美國首次吃到。之後再遊一會單車河:望望Luna Rossa的大本營(來自意大利的LV Cup參賽隊伍),以及新起好的海傍小公園,倒也不俗。

Sunday, July 28, 2013

Vasona park一遊

在半島居住後,比以前少了去扒獨木舟,皆因最近我家的Shoreline park的湖實在太小,一下子就環湖一周,不夠過癮;再加上踩單車已花去很多時間。昨天踩了Montebello,今天正好轉轉活動,發掘一下扒艇的新地方。Google找到位於Los Gatos 的Vasona park,決定試試。

其實Vasona park是老地方,picnic試過,萬聖節之夜玩過,單車踩過,只是艇未扒過。我一直都認為那裡環境優美,但一如其他美好的事物,壞處就是多人爭;矽谷雖然處處都有適合遊玩的公園,已比其他地區優勝不少;始終也有一些像Vasona這樣較受歡迎。停車場收費六大元,如用來津貼一下保養的經費,也算合理,總不能因為該處居民有錢要他們全數負責吧。想慳這六元也很簡單,把車停在附近街上再踩單車過去即可。

租艇中心比告示的十一時還要早點點開檔,有點意外驚喜;在我之前已有幾家人租水上單車,該中心也有當今最熱門的Standup paddleboard 出租,他們有大約十多塊,開門不到一小時,已差不多全數租出!我租的是獨木舟,職員問我租一小時還是半小時,我推斷湖不會太大,果然,我租了一小時如果不hea夠環湖兩周,不過比Shoreline還是大一點點,不至於一眼睇晒!我想我會再回這裡玩水上活動,記得早一點去便可。

Saturday, July 27, 2013

正義有罪?

挺身而出指責執法不公重要,定係扮假道學人士重要?答案十分明顯。

有無學生純情到以為老師在私人時間都唔會講粗口?如果有,係時候醒醒。

Tuesday, July 23, 2013

Force some rows to appear last in SQL

Everyone who writes SQL knows ORDER BY, which forces the result to be ordered by the values in the specified column. I had a scenario where I not only needed to ordered by the values in a column but also wanted a certain value to appear last. Naturally I go to Google first and as usual it found me what I needed from StackOverflow. See this post, which was about forcing rows to appear first. For my purpose I just needed to flip the 0 and 1 in the CASE-WHEN. BTW, if one still wants the results to be ordered by that column, simply add that column after the CASE-WHEN in ORDER BY.

Thursday, July 18, 2013

表裡不一

人地封面故事講一個外表呃晒人既疑犯,寓意睇野唔好睇外表咁無知;成班人就為左呢個封面鬧爆人,係咪對號入座呢?

Music app and channels

I have got a new Android device (more on that later.) This gave me a great opportunity to try out new music apps. The first one that I'd like to recommend is the TuneIn Radio App, which you have probably heard of, even before reading this, because of its advertisement. In fact, I went by their office location on U Ave in Palo Alto the other day! It's actually quite similar to XiiaLive, which I have been using to listen to ShoutCast stations (Shoutcast is a technology for serving audio streams and also a directory of internet radio) Like XiiaLive, it also has timer and alarm features, which I use quite often. It seems to offer different stations than ShoutCast though. From TuneIn Radio, I've found a few good channels:
1) Blue Rock from ROCKRADIO.com plays the likes of Buddy Guy, Stevie Ray Vaughan, Freddie King... etc. That's my favourite Blues sub-genre

2) Thrash Metal from ROCKRADIO.com plays my favourite Metal sub-genre. Death Angel, Testament, Slayer all played thrash. I've also heard Shadows Fall on it! And I "discovered" the German Thrash band Cripper featuring female vocalist Britta Görtz (another metal goddess after Angela Gossow)

3) Hair Bands from ROCKRADIO.com plays my guilty-pleasure Metal sub-genre. One of the first songs I heard was "Every Rose has its Thorn." Hard to not like it!

4) Radio Web Guitar Warrior seems to be European and played quite a bit of Power Metal. Not really my cup of tea except it usually features good guitar solo!

5) CLASSIC METAL RADIO plays a lot of mainstream/pop metal. I heard Aerosmith's Angel on it. Love that ballad! Also heard "Don't Look Back" from the "new" Queensryche (the one without original singer Geoff Tate but the vocal still sounds like him)

6) Guitar Jazz from JAZZRADIO.com. Jazz guitarists gotta love it!

7) Sax4Love (Smooth Jazz.) Another guilty-pleasure sub-genre :P

8) Jazz Radio Network

BTW, TuneIn listed both JAZZRADIO.com and ROCKRADIO.com with a Palo Alto address! Maybe it's the epicenter of internet radio.

Wednesday, July 17, 2013

Italian CamJazz

I consider myself a jazz lover that listened to a great variety of jazz, including European jazz musicians who record for the ECM label, like the Polish trumpeter Tomasz Stanko, whom I saw live at a SFJAZZ concert with Charles Lloyd (each with their own group) Well, I just learned that I should pay attention to Italian musicians when it comes to European jazz. The Italian label CamJazz has released quite a few good gems. For example, I am listening to House of Card by Fulvio Sigurta, another trumpeter. Check out this review. I like the playing of the guitarist Federico Casagrande on this disc a lot.

Monday, July 15, 2013

Sports highlight: auto racing

Can't believe I missed Tim Lincecum's no-hitter for the Giants vs the Padres last Saturday. He might never be a dominating pitcher again but this is another highlight (after 2 World Series rings and Cy Young) on his already outstanding resume. With many other sports being in the offseason, the main thing for the Summer weekends to me was auto racing. First, I watched both NASCAR races, with the Sprint Cup one won by Brian Vickers, who had to endure a few unlucky events: his health issue (blood clot) forced him out of NASCAR for a while. Then the team he raced for, Red Bull, decided to withdraw from NASCAR. I understand it's a business decision, with Spring Cup television ratings no good in the 18-to-34 age group (as of 2011) Even though Red Bull's NASCAR team is far less successful than their Formula 1 team with multiple-time champion Sebastian Vettel, it seemed competitive enough and got good exposures alongside other energy drink brands like Monster (sponsoring Kyle Busch in Nationwide) and 5-Hour (sponsoring Clint Bowyer in Spring Cup) Oh well, I don't drink much Red Bull with or without their presence in NASCAR. Anyway, Vickers doing well and finally winning a race was a feel-good story for sure.

Another interesting story has to do with Danica Patrick, again. I wrote about her current boyfriend, Ricky Stenhouse Jr caused a big crash that collected Danica at Talledega 2 months ago and the story was not mentioned a lot in the media. Well, it's the other way around this race: Danica wrecked Stenhouse. And it caught a lot of attentions! Sexism? This time most reports mentioned the Talledega crash and I found out Danica was actually not happy with Stenhouse last time (Well, she tended to be angry with anyone involved after every crash from her IndyCar days) This time she apologized on TV and admitting her fault. Nice! BTW, the third car involved in the crash was #93 Travis Kvapil, who was so mad with Danica after the crash. Guess what team he was with? BK Racing, a team formed with some remaining personnel and equipments from the now-defunct Red Bull team!

There were also 2 IndyCar races, at Toronto. As I mentioned before, I have been rooting for Verizon/Penske driver Will Power for the past few years. He lost his road course qualification magic for the first race and didn't start from the pole. And once again, when his car finally got to the front and started looking promising to win the race, it faded and he finished outside the podium.

Wednesday, July 03, 2013

香港房屋政策

林本利是一位我覺得頗有見地的經濟學者,從這篇分析香港政府的房屋需求評估如何脫離現實的文章可見一班;原來他有一個blog貼了他在各大報章發表的文章。


Tuesday, July 02, 2013

The Galileo affair

This post has nothing to do with the heavily promoted TV series starring 福山雅治 in Hong Kong but the scientist instead. For some forgotten reasons I brought up Galileo vs the church during a family conversation even though I have pretty much lost my interest in science after college. It was my favorite subject when I was a kid. (I guess it's abandoned because chicks found artists more cool than scientists) I barely even read "soft-core" science these days but I gradually started doing that again because of the kids. First, it's a known fact that girls in the American education system tended to be uninterested or even discouraged in this area so I gotta do something to counter balance that. Second, I wanna find some heroes that my kids could look up to. Apparently they are not too interested in great composers even though they play. I guess scientists who made discovery and contributions to our world would be easier to understand and be admired. A recent article that is related to science (and also history) and I found interesting was from Quora: the Galileo Affair was voted as the top most misunderstood historical event. (Linking to Wikipedia because you have to become a member of the latter to read its article and I still couldn't figure out how to unsubscribe) Here's the gist: Galileo's contribution to heliocentricism (i.e., the Earth going around the Sun instead of the other way around) was exaggerated. His punishment by the church because of his advocacy of heliocentricism was also exaggerated (the punishment was house arrest for the last 9 years of his life but he was not tortured. And the church didn't exactly oppose heliocentricism but rather Galileo's presentation of it)

Tuesday, June 04, 2013

愛民族及民俗

今天六四,一早見到香港傳來的良心照片,心情多欣慰少沉重。無獨有偶,也過了愛國愛民的半天。話說每逢星期二三藩市唐人街旁的舊聖瑪利堂都有午間古典音樂會,今天的表演者是自小從台灣移民美國的鋼琴家Tien Hsieh。老實說,我對古典鋼琴獨奏熱愛程度只屬中等,但直覺告訴我這可能是一個不同凡響的音樂會,再加上曲目包括華格納及李斯特這兩位我欣賞的作曲家的作品。果然,很慶幸沒有錯過!第一首是李斯特改編華格納歌劇,也是無人不識的Bridal Chorus(即「成個老襯從此被困」,好在這幾天沒有這種感覺!)Hsieh的彈奏抑揚頓挫,老掉牙的旋律也感新鮮。最後一首唐璜幻想曲更是大顯功架之作:快及大聲得來粒粒音清清楚楚,當然贏得全場熱烈掌聲!作為中國人也沾了一點光,很久不太有這種感覺了。沒有浮誇,只靠實力,實屬可貴。接著順道循例到金門餅家看看,幾個月沒開門做生意,經已沒有期望,但見門外有一條短短的隊,實在喜出望外!金門也可以「只靠實力」來形容,做出好東西,自然得到中外人士欣賞。回到office,沖壼鐵觀音。飲啖茶,食個包;香港人的生活情趣實在可愛!

Wednesday, May 29, 2013

Jazz playlist

I have been listening these few CDs:
- Todd Marcus: Inheriance
The current issue of JazzTime magazine has a special on bass clarinet: its history in jazz and its players, Todd Marcus being one of them. He led a group that included guests Don Bryon (another famous jazz clarinetist) and Warren Wolf on Inheriance. 

- Bob James and David Sanborn: Quartette Humaine
David Sanborn is probably more well-known for his "smooth jazz" efforts like his album "Close-Up" from 1988. Indeed, I picked it up because it's supposed to sound like Kenny G from around the same time. Of course, in the music circle, Sanborn is much higher regarded than Mr. G. In fact, Sanborn isn't a smooth jazzer. His more mainstream stuff sounded that way because of the R&B elements. He could play "real" jazz too. You could hear that from "Another Hand", the 1991 album he released after "Close-Up." It has my favorite version of Charlie Haden's composition, "First Song." Bob James was another musician(pianist) known for his smooth jazz work. He was an original member of the smooth jazz supergroup Fourplay. He collaborated with David Sanborn before and produced a smooth jazz classic, Double Vision, that included popular tunes like Maputo. Again, he played more than smooth jazz, as evident on this latest (2nd) collaboration with Sanborn, which is an acoustic tribute to Brubeck and Desmond. 

- Wayne Krantz: Two Drink Minimum
This was recommended by my teacher at Berklee for the interesting stuff he did with rhythms.

Last but not least, it's a sad sad day for jazz fans as pianist Mulgrew Miller passed away today because of a stroke. I still remember my first time visiting Yoshi's (in the old Oakland Claremont location) was to see him perform. The DJs at KCSM have been playing many of his works as a tribute. RIP.

Friday, May 24, 2013

ExtJS tips

My boss always joked about being impressed by my front-end skills listed on my resume (of course I was hired to do back-end work primarily) It seems that I'm considered to be more of a back-end guy throughout my IT career even though I have built UI for every job I had, including those used by engineers in manufacturing and IT, B2B buyers and sellers, etc. I have even built a tutorial/demo of using that B2B site in Flash! After a few years of hiatus from building UI, I'm finally back in the game, "fast-forwarding" from Weblogic/NetUI (yes, that's ancient technology I used last time) to ExtJS by Sencha. I visited them earlier this year. The offices and the atmosphere was so dot-com! The web UI created with ExtJS looks very slick with tons of eye-candies (which a lot of people like) You could build a good-looking basic web app with it quickly and easily. However, there are quite a few gotchas that have to do with its association model. Let's say you are a publisher who sells magazines to your subscribers. You have a one-to-many relationship between your customer and your magazines. So you created a class for the magazine model and another for the customer model. Then specify in the customer model a hasMany relationship with magazine. This is to be used with a REST-ful webservice for CRUD of customer (along with magazine relationships)

1)  You cannot create a separate store class in which you define a REST proxy with the URL of the aforementioned webservice. Instead, the proxy must be defined within the model class. Stores for customers and magazines are implicitly created. To load these stores, call Ext.ModelManager.getModel to obtain the model object and call load(<id>) on it.

2) Query of your customer REST-ful webservice could return magazines subscribed by the customer as a JSON array, named the same as the hasMany relationship. The implicitly created store for magazines associated with the customer will be populated properly. However, when you call customer.save(), the payload to the REST proxy's URL will not include the array of subscribed magazine. To make this happen, you have to override the default JSON writer of the proxy. See the second part of this post for a generic implementation that works for all associations. Alternatively, you could just implement a customer JSON writer that handles your customer/magazine relationship only, which is much simpler: basically you implement the getRecordData function. Add the fields of customer to the data object to be returned. Also loop through the associated magazine stores and add the fields to an array inside that data object.

3) Let's say you implement a drag-and-drop UI that allows user to drag magazines between the 'subscribed' and 'not subscribed' lists. Check out this example from Sencha. Each of such list is actually an ExtJS grid panel defined with its store. However, you want the 'subscribed' grid to use the implicitly created associated magazine store at run time. The name of the method to use is not that obvious. It is 'reconfigure.' I learned that from this post.

Thursday, May 23, 2013

Implementing RESTful Webservice using Wicket

Wicket alone might not be the ideal framework (check out this project that extends Wicket for such purpose) but this could be done. Simply write a class that extends WebPage. Override the renderPage method and write to the response. Finally, mount that page in Application.init() to a URL for its client. Here is the syntax for specifying the id in the URL with mountPage. (For example, a typical RESTful query looks like this: http://youraddress/order/<order id> )
  mountPage("/order/${orderId}", Order.class);

More tips:
1) PUT and POST
One of the key features of REST is using the "verb" (i.e., the method of the servlet request) to determine which of the CRUD (create, read, update, destroy) action is to be performed. It took me a while to figure out how to extract this "method" value:
        HttpServletRequest servletReq = (HttpServletRequest) getRequest().getContainerRequest();
        String method = servletReq.getMethod();
        if ("GET".equals(method))
        {
            // logic to read the object
            ...
        }

2) the payload
To create or update an object via RESTful Webservice, the payload includes a serialized form of the object (e.g., in JSON format) Again, it took me a while to figure out how to extract the payload:
        HttpServletRequest servletReq = (HttpServletRequest) getRequest().getContainerRequest();
        BufferedReader br = servletReq.getReader();
        String payload = null;
        if ((payload = br.readLine()) != null)
        {
            // process payload
            ...
        }

3) HTTP Status code
The page should return a meaningful code to the user. I found this table quite useful. Set it in renderPage() like this:
    public final void renderPage()
    {
        WebResponse response = (WebResponse) getResponse();
        response.setStatus(200); // for OK
    }

4) Return a download file
This is not RESTful but I just want to mention it here. Sometimes you want to provide a URL that would serve the browser content not in a browser window but in a download file. HTTP actually supports this using the Content-Disposition value (set to 'attachment') in the header. Let's say my page/class that extends WebPage create a zip file to be downloaded by the browser. Implement renderPage() like this:
    public final void renderPage()
    {
        WebResponse response = (WebResponse) getResponse();
        response.setHeader("Content-Type", "application/zip");
        response.setAttachmentHeader(fileName);
    }
BTW, don't rely on overriding the getMarkupType() method to set Content-Type in the header. It doesn't work that way for some reason. Set it explicitly like the above.

Wednesday, May 22, 2013

The Amazingly Flexible Jackson

Continuing my praises for Jackson, the JSON processor. I have a fairly unusual requirement for JSON generation: for a certain class of object in the hierarchy, the JSON representation needs to be all on one line. I have been using JsonGenerator instead of the ObjectMapper to generate my JSON and I knew injecting my own newlines could be done by simply JsonGenerator.writeRaw("\n") However, I rely on writeObject for that class of object, which is in an array, and writeObject is responsible for writing the commas before every elements after the 1st element in the array. So there are commas after the newlines but before the { of the object. I need to have these commas on their own line.

What I ended up doing is "hacking" the pretty printing support of Jackson. Jackson allows you to set a pretty printer to the JsonGenerator (or perform no pretty printing by setting it to null) Jackson also provided a full-blown pretty printer (the default) and a minimal one (that basically print as if no pretty printing and expect you to override some of its method to customize its behavior) I needed the JsonGenerator to add newlines surrounding the comma when writing array separators. However, this should only happen before the first { of the object, i.e., for the arrays nested within the object, it must not add newlines. Otherwise it violates the requirement of getting everything on one line! My subclass that inherits the minimal pretty printer has a boolean flag to control adding newlines so that it only adds the first time. Sounds tricky, right? Yes, it is.   

Tuesday, May 21, 2013

Jackson and polymorphism

Believe it or not, I have been manually adding {[': ......etc to generate my JSON for a while, until I discovered the open-source library Jackson, which I should have been using all along. It is very easy to turn a Java POJO into JSON and vice versa (i.e., serialization and deserialization) Check out the simple examples provided by this fellow. The only hiccup I had was related to deserialization and polymorphism. Imagine you are Jackson and parsing a block of JSON. According to the class definition, that block belongs to an abstract class or interface. Which subclass would you choose to deserialize this? Obviously you need some hints. Jackson actually includes mechanism to handle this. It's easy if you have something like 'dog' and 'cat' extending 'animal' and there is a type variable in the classes that could be used to tell whether the object is a dog or a cat. (See example 4 from this post) However, I have 2 subclasses of an abstract class that could only be distinguished by the class variables (i.e., unique attributes.) Fortunately I've found a way to solve this (See example 6 from the same post as above) Basically I wrote a custom deserializer for my abstract class. This deserializer looks for the unique attribute and find the corresponding subclass for deserialization.