Wednesday, May 23, 2007

Lord of War

Poster of Lord of War

Watched this last night, a documentary-style movie that records the world events in 1980s and 1990s through the life of a firearm dealer, Yuri Orlov.

What sets this movie apart from other Hollywood thrillers is that it doesn’t attempt to artificially render evil “evil”. Despite being responsible for the death of thousands of people, the main character, Yuri, doesn’t really have an evil look. In fact, aside from his profession, he is almost somewhat “likeable“. The writing and directing of the movie is also remarkable: the switch between light background music, humorous dialogs and shocking scenes of war and horrible living conditions in Africa. Like the first 2 minutes of the movie, the making of a single bullet, is quite entertaining… until it flies out of a rifle towards the head of a child…

The people who is doing evil might just be an ordinary person who provided himself with an ill-fated justification for what he is doing; and the horror of war might not be that far from our ordinary life.

Here are some entertaining quotes from the movie:

  • Yuri: There are over 550 million firearms in worldwide circulation. That's one firearm for every twelve people on the planet. The only question is: How do we arm the other 11?
  • Dictator: They say that I am the lord of war, but perhaps it is you.
    Yuri: I believe it's "warlord."
    Dictator: Thank you, but I prefer it my way.
  • When paid with drug by his client:
    Yuri: I can’t hand these to my bank teller at Chase Manhattan… I sell guns, not drugs.
    Client: Diversify.
  • Yuri: Back then, I didn't sell to Osama Bin Laden. Not because of moral reasons, but because he was always bouncing checks.

And here are some of the not-so-entertaining ones:

  • They say, "Evil prevails when good men fail to act." What they ought to say is, "Evil prevails."
  • The primary market was Africa, Eleven major conflicts involving twenty three countries in less than a decade. A gunrunner's wet dream. At the time the West couldn't care less, they had a white war in what was left of Yugoslavia.
  • Every faction in Africa calls themselves by these noble names - Liberation this, Patriotic that, Democratic Republic of something-or-other... I guess they can't own up to what they usually are: a federation of worse oppressors than the last bunch of oppressors. Often, the most barbaric atrocities occur when both combatants proclaim themselves freedom-fighters.
  • WHILE PRIVATE GUNRUNNERS CONTINUE TO THRIVE, THE WORLD'S BIGGEST ARMS SUPPLIERS ARE THE U.S., U.K., RUSSIA, FRANCE AND CHINA
    THEY ARE ALSO THE FIVE PERMANENT MEMBERS OF THE U.N. SECURITY COUNCIL

Tuesday, May 22, 2007

China: BlackStone Investment, Rate Raise and Stock Bubble

  • China is investing $3 billion in BlackStone. Despite the amount is relatively insignificant (about 0.25% of China’s total forex reserve), it marks the first action by China to diversify its $1.2 trillion forex reserve into riskier assets.
  • Chinese stock market defies not only gravity, but also central bank’s monetary policy. Shanghai Composite Index has hit two consecutive records in the two trading days after the central bank raised interest rates in an attempt to curb the economy (the stock market, primarily) from overheating…

Friday, May 18, 2007

WPF Samples

Check out this WPF Sample package by Kevin Moore.

  • The MineSweeper is an excellent example of custom FrameworkElement.
  • The Graph sample animates cool…
  • Be sure to check out the KevinButton (and click it).

Thursday, May 17, 2007

Force Code Comment

Writing comments is like seeing dentists: we all know it’s good, but we choose not to do it anyway…

Here is a way I see in this post here that forces developers to write XML comment in Visual Studio 2005:

  • In Project Property page, choose to output “Xml Documentation file” during build.
  • Treat the following warnings as errors:
    1591,1592,1573,1571,1570,1572

Now if a public class, property or method is missing XML comment, the project build will fail. This can be enforce on the build/integration server, so that any time anyone misses a comment, a nasty blame email will be on its way (any Payroll Department is always on the CC list).

But is it a good idea to force comments on every public class, method, property, etc? I honestly don’t know…

Wednesday, May 16, 2007

MiFID

From an article on MiFID:

You can say one thing for a business disaster these days: it's usually a lucrative "opportunity" for IT people.

Sarcasm it might sound, there seems to be some truth in it. While businesses may consider regulations such as Basel Accord or NMS as a burden, they certainly create many opportunities in the IT front. The same probably applies to accounting industry on the SOX.

Monday, May 14, 2007

What's Cool in WPF

Some of the new controls in Windows Presentation Foundation are, in the lack of a better word, brilliant! For a starter, look at the xamCarouselPanel in Infragistics NetAdvantage package. Here is a screen shot of a WPF front end I’m working on for Linq query engine:
 

In case you have been living under the rock for the past two years and has never heard WPF or XAML before, Josh Smith’s five part guided tour serves as a fantastic starting point. 

Friday, May 11, 2007

Beta Gamma Sigma

I’m in… (and can do the secret hand shakes, if any)

Did some Googling on the origin of the name:

  •  Beta is the initial letter of the Greek word bebaeos, which signifies honor.
  •  Gamma is the initial letter of the Greek word gnosis, which means wisdom.
  •  Sigma is the initial letter of the Greek word spoude, which means earnestness.

 

Planet Earth

This is truely the best series about nature and wildlife on this planet ever made, and it makes your HDTV really worthwhile. Now I can only regret that I didn’t go for a 1080p one or I don’t have a XBOX360/PS3 lying around, otherwise I’d definitely go for the HD or Blu-ray version of the DVD sets.

I have only watched a small portion of the program (that’s why I’d have to get the DVDs) and there are already so many amazing scenes: the hunt of the Golden Eagle, the first footage of a wild Snow Leopard and the mating dance of Birds of Paradise(the blue smily face is REALLY funny).

Wednesday, May 9, 2007

Defying Gravity?

Shanghai Composit Index has smashed a second phychological barriar within 3 months since late Feb. It stands just above 4000 level as of today.

Irrational Exuberance v.s Gravity, which one will win out eventually?

Tuesday, May 8, 2007

Linq to Google

Updated my artile on CodeProject:

  • Added support for parametized query and projection.
  • Refactored source code and namespaces.
  • Support for Google Groups query.

You can download the source code here.

Monday, May 7, 2007

Kill Excel in Automation

How to kill excel silently is probably the most frequently asked question in Excel automation in .Net. Here is a check list of actions I got from multiple posts in Google groups:

  1. When you close a wookbook with _WorkBook.Close,  chances are that Excel will display a dialog box asking whether to save the file, even if Application.Visible  and Application.DisplayAlerts are both set to false.
    • If you do want to save it, call _WorkBook.SaveAs before Close.
    • If you don’t want to save the file, set _WorkBook.Saved to true before Close.
  2. All workbooks and worksheets must be closed before exiting Excel.
  3. All COM objects must be released with Marshal.ReleaseComObject.
  4. Call Application.Quit to end the session.
  5. Call GC.Collect, then wait for all finalizers to complete.

If you fail to perform any of these actions, in all likelihood an instance of Excel will get stuck in the memory. Very annoy, really.

Here is the code snippet that does the trick:

//close workbooks

foreach (Excel.Workbook wb in excelApp.Workbooks) {

    //release worksheets

    foreach (Excel.Worksheet ws in wbook.Worksheets) {

        Marshal.ReleaseComObject(ws);

    }

 

    //set saved to true to avoid DialogBox

    wbook.Saved = true;

    wbook.Close(false, false, 0);

 

    //release workbook object

    Marshal.ReleaseComObject(wbook);

}

 

//exit Excel

excelApp.Quit();

Marshal.ReleaseComObject(excelApp);

excelApp = null;

 

//Call GC and wait for finalizers

GC.Collect();

GC.WaitForPendingFinalizers();

Friday, May 4, 2007

The Most "Efficient" Brand

The potential of a Microsoft-Yahoo! deal is just too interesting to pass by, so I pulled together the data below from company filings and BusinessWeek's Top 100 Brands (Microsoft data is for the whole company because detailed numbers for its Online Services segment is not available, so it’s not exactly comparable to the other two).

To my surprise, Google’s biggest advantage in it’s profit margin comes from Sales & Marketing Expenses, at only 8% of revenue, compare to above 20% for both Microsoft and Yahoo!. Use BusinessWeek’s estimate, Google’s brand value is about 15 times its sales marketing expenses, while that number for Microsoft and Yahoo! are 6 and 5 respectively. This sure makes Google one of the most “Efficient” brand out there.

  Microsoft Yahoo! Google
Revenue 100% 100% 100%
Operating Expenses  
Cost of revenue 17% 42% 40%
R&D Expense 15% 13% 12%
Sales & Marketing 22% 21% 8%
G&A Expense 8% 8% 7%
Operating income 37% 15% 33%
   
BW Rank by Brand Value 2 55 24
Sales and Marketing Exp. 9,818 1,322 849
Brand Value 56,926 6,056 12,376
B.V./Sales & Marketing 5.80 4.58 14.58

If there is going to be a Microsoft-Yahoo! deal, would Microsoft be able to create synergy by cutting into Yahoo!’s marketing expenses?

Microsoft buying Yahoo?

Rumors are flying

If you think about it, this deal makes a lot of sense: acquiring Yahoo! Inc, currently valued at approximately $44b, is a good use of Microsoft’s some $30b excess cash. According to SearchEngineWatch, this would give Microsoft a 38.6% share in Internet search business, putting it in a better position to compete with Google. The question is, given Google’s big lead, whether the regulators will still seek to block the MS YAHOO deal on the ground of anti-trust.

U.S. Online Searches by Engine, January 2007 and February 2007 (%)

January 2007 (B)
February 2007 (B)
Change
Total Internet population 100 100 N/A
Google 47.5 48.1 0.6
Yahoo 28.1 28.1 0.0
Microsoft 10.6 10.5 -0.1
Ask.com 5.2 5.0 -0.2
Time Warner 5.0 4.9 -0.1
Source: comScore Networks, 2007

M&A and LBO are still white hot (if not getting even hotter) in the U.S:

Thursday, May 3, 2007

Black Swan: The Impact of Highly Improbable

This book by Nicholas Nassim Taleb is currently ranked #5 on New York Times Bestseller List and #12 on Amazon’s Top Seller for All Books. This by itself is “highly improbable” consider the book about probability is very much quantitative oriented.

Read the author’s blog here.

Fun with Lambda.Compile: Code? Data?

Another very funky twist of C# 3.0 new features: in the following code snippet, tell what’s code (I.E. MSIL), what’s data (I.E. expression tree) and when the “data” gets compiled into “code”. (By the way, Today happens to be May 3rd, 2007).

Expression<Func<int,

    Expression<Func<int, int>>>> expr1

        = (a => (b => a + b * 3));

 

Expression<Func<int, int>> expr2 =

    expr1.Compile().Invoke(DateTime.Today.Day);

 

Func<int, int> func = expr2.Compile();

Console.WriteLine(func(10));

In case you have no clue, look into the structure of expr1 and expr2 might help:

No wonder LambdaExpression.Compile is Don Box’s favorite in C# 3.0.

Having fun…

SilverLight

Yet another exciting .NET feature to be released in the near future. Just like the .NET Compact Framework, SilverLight gives you access to a light version of the CLR (officially named DLR, Dynamic Language Runtime), especially the cool WPF stuff, to spice up the apparence of your webpage.

In order to run the demos, you need to install SilverLight plugin from here. (Notice that there is a download for Mac!!!!). Some fun demos:

And here is the Big Picture. I don’t know whether it’s just me: the logo looks very, en, Flashing

Wednesday, May 2, 2007

Are the CEP guys looking at LINQ?

CEP (Complex Event Processing) has become a very hot topic in the capital market as Algorithmic Trading gains popularity. TIBCO and Apama are two of the biggest players in the CEP engine market. There are also a handful of other vendors, including Coral8, Gemfire, StreamBase, etc).

One problem in this domain is the standardization of front end language of choice: different products tend to choose different front end approaches, ranging from SQL-like syntax, OO class library to drag-n-drop visual user interface.

I wonder whether any of them are working towards using LINQ as its .NET front end.

Tuesday, May 1, 2007

Linq To Google Image 0.1

It seems getting to the bottom of LINQ isn't as difficult as I anticipated. With two days of experimenting, I have got a crude Linq To Google Image implementation, and have learnt quite a lot about Linq's inner working along the way.

I have put together a summary on CodeProject here. And you can download the source code (at your own risk) here.

I shall probably take one step back, get away from C# 3.0 for a while and take a quick look into WCF, as that's also of great interest to me and my knowledge is pretty much still stops two years short when it was still Indigo...