Tuesday, March 22

A bug in Outlook RSS Feeds... or is it Firefox's bug?

Last week I blogged about how hard to find a good RSS notifier. Microsoft Outlook 2007 has RSS Feeds functionality, but when there is new items in the feed, it is not notifying the user like new email arrival.

What I want to say in this blog is, when I tried to subscribe one feed, which is using HTTPS connection, the Microsoft Outlook 2007 made a mistake. The link is like https://xxxx.xxx.com/rss.xml, then you should be able to click "Subscribe" to add it into Microsoft Outlook 2007:

(Firefox 4.0)

But when you click, you will see :

The "http://" is added in front of "https://" .

I'm not sure if that is a bug of Firefox or Outlook.
IE 8 only has has the ability to add to its own Active Feed list. I don't think it is actually useful.


Monday, March 21

Win7 Wireless connection drops

I have an old IBM Thinkpad T42p with Intel(R) PRO/Wireless LAN 2100 3B Mini PCI Adapter. Yes, it is in 801.11b, very old. But since it can copy files in 180KB/second, why should I replace it?

The router is Linksys WRT54G with original firmware. The computer can dual boot into Ubuntu 10.4, and the connection is very stable. But when it is boot into Win 7, the connection keeps dropping.

I googled "Win7 wireless drops" and literally tried all solutions but failed. The last method that works is:
In the connection property, uncheck QoS, File and Printer Sharing, IPv6, Link-Layer Driver and Responder (I have no idea what the last 2 are):

Then the connection is great! As I mentioned at the very beginning, it is copying files in the speed of 180KB/second now!

I don't know which one of the settings (QoS, File and Printer Sharing, IPv6, Link-Layer Driver and Responder) did the trick, but as long as the network is good, I'm happy. If you have the same problem, try it.

Re: Console Output from a Winforms Application

This is a reply from C#411. Tim shows how to AttachConsole for a WinForms Application. One problem is that the standard output and error output are not correctly handled so they can't be redirected. The comments has some useful hint about this.

After reading it and testing in Visual Studio (2008), here is my initial solution:

Right click the project and select "Property", in the Application tab, you can see "Output Type:" is "Windows Application" in default for Form application. Change it to Console Application, there is no modification needed in your source code. All problem solved. The output can be redirected to text file, and the command prompt is not messed up.

After doing so, there are always 2 windows, 1 for console and 1 for WinForm. What I really want is:

If the application is started with parameters, then start console window (only)
If the application is started without parameter, such as clicking the icon from Explorer, then start the WinForm.

I found FreeConsole WinAPI from Tim's solution, so my final solution is , in addition to the initial solution:

1. In Program.cs, separate the 2 cases, has parameter or not:
static extern bool FreeConsole();

static void Main(string[] args)

if (args.Length != 0)
Application.Run(new Form1(args));
Application.Run(new Form1());

2, In the Form1, add a new construction function to deal with parameters:
Boolean CloseAfterCommandLine;
public Form1(string[] commands)
: this()
Work with the parameters
CloseAfterCommandLine = true;
3, Modify the original Form1(void) to have CloseAfterCommandLine = false;
4, In Form1.Load, close the WinForm if necessary:
private void Form1_Load(object sender, EventArgs e)
if (CloseAfterCommandLine == true)
Console.Out.WriteLine("Bye. ");
...process the form.....

Now this application has both Console and Winform.


thanks, nicer and simpler solution!

Friday, March 18

Friday 星期五

本来娱乐界正在关注《好汉两对半》主角Charlie Sheen被解雇的事,有人关注了Rebecca Black的《星期五》这首歌,发现它无比难听;整个娱乐界就转向它了:

Rebecca Black是谁?她是个13岁的中学生,看到网上一个广告:$2000,成为歌星!就按价付了钱,那个公司给了她两首已经写好的歌曲挑选,她挑中了这首《星期五》,然后公司为她制作了MTV,并放到youtube, iTune上。

由于骂声如潮,她已经被评为后一代天王巨星了(Next Justin Bieber)。

Wednesday, March 16

RSS Notifier

I'm looking for an RSS Notifier to monitor some feeds. I have Bloglines and GReader account, and I read some feeds from Bloglines everyday. But what I need is a "real-time" notification when the feeds have new items, so the Bloglines or GReader doesn't fit into my need.

I thought that was an easy task. Microsoft actually has widgets call "Feed Headlines", but it only has 10 feeds, doesn't allow you to input the feed you want. The default IE RSS Bookmark and Firefox Active Bookmark can not provide notification when a new item is available. Event the Microsoft Outlook 2007 doesn't show notification.

Feed Notification is the best I can find. It is even better that Michael Fogleman open sourced this program. Thank you. When a new item is detected, this program will show up a balloon for 1~60 seconds, configurable. I would like the option to keep the balloon until user click it. Since the source code is available, yes it can be done.

First, line 1123 of view.py:
duration = wx.SpinCtrl(parent, -1, '1', min=1, max=60, size=(64, -1))
Modify it as:
duration = wx.SpinCtrl(parent, -1, '1', min=0, max=60, size=(64, -1))
Second step, line 141, 142 of popup.py was:
141 duration = settings.POPUP_DURATION * 1000
142 self.timer = wx.CallLater(duration, self.on_timer)
Add 2 lines in between:
141 duration = settings.POPUP_DURATION * 1000
142+ if duration == 0:
143+ return
144 self.timer = wx.CallLater(duration, self.on_timer)

It is easy!

PS, after downloading the source code, you have to install:
  • python-2.7.1
  • py2exe-0.6.9.win32-py2.7
  • ply-3.4
  • feedparser-5.0.1
  • wxPython2.8.11.0-py27
  • pywin32-216

copy 1. Icons 2. Sounds 3. Microsoft.VC90.CRT into ./dist folder
copy ./Microsoft.VC90.CRT/msvcp90.dll into C:/Python27/DLLs folder.

before succussfully compile it.


Tuesday, March 15

Nuclear Plants核电站的历史


秦山核电站是我国自行设计、建造和运营管理的第一座30万千瓦压水堆核电站,地处浙江省海盐县。一期工程1984年开工,1991年建成投入运行。年发电量为17 亿千瓦时。



世界上第一座核电站:奥布灵斯克核电站(Obninsk)1954年6月 27日运作,2002年停止。
英国第一座核电站:考尔德豪尔(Calder Hall)1956年8月运作,2003年停止。

日本原子力発電Japan Atomic Power Co (JAPC) 在 1957成立,于60年代初建设東海発電所Tōkai Nuclear Power Plant ,在1966年开始发电,后于1998年停止运作。

Friday, March 11

A lightweight XML Database

When you create an enterprise application, assume it requires database support, you can choose from MS SQL Server, Oracle, Open Source MySQL, PostgressSQL... But if you are creating a desktop application, you have to consider what kind of database engine/driver that your users already installed in their desktop.

MS Access database was a good choice, because most (but not all) users have it installed. I am always curious why they need MS Access.

Anyway, a lightweight database is crucial for desktop developer. One option is to use plain text file to store and search data. That is pathetic, if your data is complicate. I am thinking to have an XML Database, that data can be stored in structured XML file. Google tells me about XML Database:

1, Most of the XML Database projects are no longer exist.
2, Most of them use XPath, XSLT or XQuery to search data.

XPath, XSLT and XQuery have a steep learning curve, and they are not following the design of standard SQL language. What I would like to have is like the description of Ashpool project
It's goal is to use standard SQL92 syntax to query, add, update, and delete XML documents.
Unfortunately, this project is dead as well.

BTW, a compact version, sometimes call mobile version, of MS SQLSERVER is installed in all WindowsCE device. So if you are developing software for WinCE device, you don't need to worry about this.

DateTime.Kind, and SetLastModified problem (C#)

I'm using Response.Cache.SetLastModified to set the time of last modified entry in the database to the affected webpage, so that web browser knows when to cache and when to refresh for new page.

The SetLastModified gives "ArgumentOutOfRangeException" because it thinks the given time is newer than current time, and that is not allowed. The problem is, the given time was saved into database 2 minutes ago, how can it be greater (newer) than current time? I checked the sql server which is sitting in another server, and figured out they are using the same time, same timezone. The database time entry was saved as "LastModDateTimeGMT=getutcdate()".

After carefully checking all the possibilities (that means 2 hours), I focus on the DateTime.Kind property. When the DateTime entry is retrieved from database
DateTime LastModified = (DateTime)(row["LastModDateTimeGMT"])

The value of LastModified has the value of UTC time (that means 7PM, when it is 12PM local time), and the LastModified.Kind is "Unspecified".

DateTime.Kind property tells us, when the .Kind value is "Unspecified", you can call .ToLocalTime() to get LocalTime, assuming the current value is in UTC, or you can call .ToUniversalTime() to get UTC time, assuming the current value is in Local. So, in my case, SetLastModified(LastModified) calls the LastModified.ToUniversalTime() and gets 2PM of tomorrow, when this time is compared with the current time (7PM UTC, 12PM local), it prompts error because the given time is newer than current time.

After setting the .Kind to the UTC because I know the datetime in database is in UTC:
DateTime LastModified = (DateTime)(row["LastModDateTimeGMT"])
LastModified = DateTime.SpecifyKind(LastModified , DateTimeKind.Utc);
everything is good.

So the error actually comes from Sql Server: When a datetime is saved, there is no way to know what timezone it is in:
Time zone offset aware and preservation No
Daylight saving aware No
(datetime (Transact-SQL))
So C# can only give "Unspecified" to the .Kind value when the value is retrieved.

The "Unspecified" is a very dangerous status. The system (or the Microsoft Programers) tries very hard to guess what timezone that is or what timezone you want to have and gives you a wild guess result. Each time you retrieve a datatime from database or from other sources, you should always specify a .Kind for it to prevent this kind of uncertainty.

Another suggestion is: Always use UTC time (getutcdate) in database and in programing, so that you don't have trouble if your server is physically moved into to another timezone, or your program is deployed by another team that you don't know where they are.

Note: By default, the "Cache-Control" is "Private". In this status, the Response.Cache.SetETag will fail. There is no ETag output to client. So Response.Cache.SetCacheability(HttpCacheability.Public or PublicOrPrivate); must be enforced before setting ETag.

Labels: ,

You saved my time, thanx

Thursday, March 10



录像是2008年的, 老外公还在世,坐在轮椅上,精神不错。我听他们说过好几次这次采访,现在才终于看到了。