北京最近一直下雨. 接连两天都在下, 中间会停一会儿, 多半时候是小而连续的那种. 下午的时候, 三点多钟外面黑得像七八点一样, 像是酝酿一场暴雨, 不过最后下下来的倒不是很大. 北京的雨比上海的舒服很多. 潮湿的泥土散发出得气味如同儿时在家里闻到的一样, 熟悉而自然. 上了大学到了多雨的南国, 每次下雨却只能闻到一股酸味, 非常难受. 连续几天的雨天也让气温下降了不少. 秋天到了.

MSRA的确是藏龙卧虎的地方. 前几天刘彬的同学提起一个人叫做潘爱民的, 然后问我知道不知道, 我当然知道, IT写书的大牛, 翻译了不少著名著作, 比如一本计算机网络, 当年熟读好几遍. 又说这个人目前在MSRA, 而且就在隔壁的东区, 立即带我去看… 于是乎我们两人像西天取经一样去看潘爱民… 潘爱民累了, 趴桌子上小憩呢…

潘爱民,浙江海宁人,获得了南开大学数学学士学位,清华大学工学硕士学位,以及北京大学计算机科学博士学位。

他从中学时代开始接触计算机编程,经历了从DOS到Windows各种版本的发展历程。潘爱民曾经长期从事软件技术的研究和开发工作,撰写了大量软件技术文章,1999年曾经是《微电脑世界》杂志社的合作专家。他著写了《COM原理与应用》(1999年出版),翻译了多部经典名作,如《Visual C++技术内幕》(第四、六版)、《C++ Primer中文版》(第三版)、《COM本质论》、《计算机网络》(第四版)等。

从2001年开始,潘爱民在北京大学计算机科学技术系承担研究生课程教学,共讲授了三门课程:《组件技术》、《网络与信息安全》和《程序开发环境分析与实践》,深受学生欢迎。2006年秋季在清华大学软件科学实验班讲授《程序设计与算法基础》课程。

潘爱民获得了2001年微软亚洲研究院“微软学者”称号,2002年度北京大学优秀教学奖。他现在微软亚洲研究院从事系统与安全方向的研究工作。

周末啦. 今天抽了个机会把博客的模板好好整理了一下, 汉化了小部分内容, 主要添加了些Google Adsense的广告.记得刚申请这个域名的时候就去申请Google Adsense了, 只不过那个时候几天之后给我回信告诉我不通过申请, 因为浏览量太小了. 也难怪, 新站嘛. 现在通过申请了, 我也就加上了, 倒是真不指望能赚几毛钱, 最起码这种东西放在网站上多少说明我的站有点价值吧.

郁闷死了. 还是VSTO的问题, 怎么也部署不了了. Adnan心急的很, 我也很着急, 可越是这种有的可以有的不行的情况是最难处理的. 希望周末的时候能有时间再试一试.
英文还是很重要的, Adnan一着急就亲自跑来了, 跟他交流得用英文, 说实话开始心里比较发毛, 侃了一会儿就好一些了, 说话也连贯了…嘿嘿. 专业外语咱还是没问题的, 毕竟那些个词在中文里也还是那些个词, 平常就没人用中文念那些东西, 就是Visual Studio 2008这样的数字注意别念顺口了就行了~

唉. 写了一篇, 被Windows Live Writer死掉吃掉了. 气死我了. 最近比较烦, 乱七八糟的事情越来越多, 头绪也越来越多. 我真的很不喜欢和我控制不了的事情打交道. 不过还算好的是最起码白天能够坐下来好好做点事情了. 能够坐在岗位上仔仔细细认认真真耐心编一天程, 真的是够耐心, 像刚来的时候一样了. 在MSRA, 每个人都可以用远程桌面连接到数台服务器, 在上面做开发, 我很喜欢远程桌面这个东西, 因为在那里可以将人从喧嚣的世界中分离出来, 在那里没有Outlook, 没有QQ, 没有MSN, 戴上耳机, 没有电话. 多么美好的却昂贵的源代码世界.

这是来自新加坡国立大学的一个页面,它记录了一个程序员从入门到精通,再到黑客,再荣升经理和CEO时所写的代码,
正如我们访客(注: cnbeta的访客)所评论的那样,这位程序员从青蛙变成了蛤蟆,相信同为程序员的你,看了之后您会会心一笑,我们的生活何尝不是如此呢?

High School/Junior High 10 PRINT “HELLO WORLD”
20 END
First year in College program Hello(input, output)
begin
writeln(‘Hello World’)
end.
Senior year in College (defun hello
(print
(cons ‘Hello (list ‘World))))
New professional #include
void main(void)
{
char *message[] = {“Hello “, “World”};
int i;for(i = 0; i < 2; ++i)
printf(“%s”, message[i]);
printf(“\n”);
}
Seasoned professional #include
#include

class string
{
private:
int size;
char *ptr;

public:
string() : size(0), ptr(new char(‘\0’)) {}

string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}

~string()
{
delete [] ptr;
}

friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}

string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}

int main()
{
string str;

str = “Hello World”;
cout << str << endl;

return(0);
}
Master Programmer [
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
{
// bring in the master library
importlib(“actimp.tlb”);
importlib(“actexp.tlb”);

// bring in my interfaces
#include “pshlo.idl”

[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};

[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{

// some code related header files
importheader();
importheader();
importheader();
importheader(“pshlo.h”);
importheader(“shlo.hxx”);
importheader(“mycls.hxx”);

// needed typelibs
importlib(“actimp.tlb”);
importlib(“actexp.tlb”);
importlib(“thlo.tlb”);

[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclass CHello
{
cotype THello;
};
};

#include “ipfix.hxx”

extern HANDLE hEvent;

class CHello : public CHelloBase
{
public:
IPFIX(CLSID_CHello);

CHello(IUnknown *pUnk);
~CHello();

HRESULT __stdcall PrintSz(LPWSTR pwszString);

private:
static int cObjRef;
};

#include
#include
#include
#include
#include “thlo.h”
#include “pshlo.h”
#include “shlo.hxx”
#include “mycls.hxx”

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
{
cObjRef++;
return;
}

HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
{
printf(“%ws\n”, pwszString);
return(ResultFromScode(S_OK));
}

CHello::~CHello(void)
{

// when the object count goes to zero, stop the server
cObjRef–;
if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include
#include
#include “pshlo.h”
#include “shlo.hxx”
#include “mycls.hxx”

HANDLE hEvent;

int _cdecl main(
int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);

CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF->Release();

// Tell OLE we are going away.
CoUninitialize();

return(0); }

extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

#include
#include
#include
#include
#include
#include “pshlo.h”
#include “shlo.hxx”
#include “clsid.h”

int _cdecl main(
int argc,
char * argv[]
) {
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = ‘\0’;
wcsT[0] = ‘\0’;
if( argc > 1) {
mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, “Object path must be specified\n”);
return(1);
}

// get print string
if(argc > 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
else
wcscpy(wcsT, L”Hello World”);

printf(“Linking to object %ws\n”, wcsPath);
printf(“Text String %ws\n”, wcsT);

// Initialize the OLE libraries
hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath, &pmk);
if(SUCCEEDED(hRslt))
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

if(SUCCEEDED(hRslt)) {

// print a string out
pHello->PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello->Release();
}
else
printf(“Failure to connect, status: %lx”, hRslt);

// Tell OLE we are going away.
CoUninitialize();
}

return(0);
}
Apprentice Hacker #!/usr/local/bin/perl
$msg=”Hello, world.\n”;
if ($#ARGV >= 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, “>” . $outfilename) || die “Can’t write $arg: $!\n”;
print (FILE $msg);
close(FILE) || die “Can’t close $arg: $!\n”;
}
} else {
print ($msg);
}
1;
Experienced Hacker #include
#define S “Hello, World\n”
main(){exit(printf(S) == strlen(S) ? 0 : 1);}
Seasoned Hacker % cc -o a.out ~/src/misc/hw/hw.c
% a.out
Guru Hacker % cat
Hello, world.
^D
New Manager 10 PRINT “HELLO WORLD”
20 END
Middle Manager mail -s “Hello, world.” bob@b12
Bob, could you please write me a program that prints “Hello,
world.”?
I need it by tomorrow.
^D
Senior Manager % zmail jim
I need a “Hello, world.” program by this afternoon.
Chief Executive % letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout

中文原文: http://www.cnbeta.com/articles/38875.htm
英文原文: http://sunsite.nus.edu.sg/pub/humour/prog-evolve.html

NND. 被VSTO的Deployment问题折腾了一整天, 最终找到一个Microsoft发布的Deploying Visual Studio 2005 Tools for Office Solutions Using Windows Installer文档(共分两部分, Part 1 和Part 2, 打印出来满满24页小字A4), 按照这个文档仔仔细细从头执行到尾, 结果, 不work. 崩溃… 气死我了. 搞了四五个小时是这个结果. NND. 折腾到12点才无奈地回去睡觉了. 明天接着搞…

Windows安全性搞得乱七八糟, 还给正常的程序开发以安全为目的造成这么多麻烦, 唉…