2007-11-12

政府与股市

2007-11-09

似非而是的戒律--德兰修女

似非而是的戒律01/10
人都是毫无逻辑、不讲道理、以自我为中心的。但还是要爱他们。
People are illogical, unreasonable, and self-centered. Love them anyway.

似非而是的戒律02/10
你如果做好事,人们会控诉说你必定是出于自私的隐密动机。但还是要做好事。
If you do good, people will accuse you of selfish ulterior motives. Do good anyway.

似非而是的戒律03/10
你如果成功了,得到的会是假朋友和真敌人。但还是要成功。
If you are successful, you will win false friends and true enemies. Succeed anyway.

似非而是的戒律04/10
你今天所做的好事,明天就会被人遗忘。但还是要做好事。
The good you do today will be forgotten tomorrow. Do good anyway.

似非而是的戒律05/10
坦诚待人使你容易受到伤害。但还是要坦诚待人。
Honesty and frankness make you vulnerable. Be honest and frank anyway.

似非而是的戒律06/10
胸怀大志的男人和女人,可能会被心胸最狭隘的小人击倒。但还是要胸怀大志。
The biggest men and women with the biggest ideas can be shot down by the smallest men and women with the smallest minds. Think big anyway.

似非而是的戒律07/10
人们同情弱者,却只追随强者。但还是要为几个弱者而仗义。
People favor underdogs but follow only top dogs. Fight for a few underdogs anyway.

似非而是的戒律08/10
你多年建设起来的东西可能毁于一旦。但还是要建设。
What you spend years building may be destroyed overnight. Build anyway.

似非而是的戒律09/10
人们确实需要你帮助,但当你帮助他们的时候,反而你可能会受到他们的攻击。但还是帮助他人。
People really need help but may attack you if you do help them. Help people anyway.

似非而是的戒律10/10
当你把你最好的东西献给世界时,你反而会被反咬一口。但你还是要把你最好的东西献给这个世界。
Give the world the best you have and you will get kicked in the teeth. Give the world the best you have anyway.

你看,说到底,它是你和上帝之间的事,而决不是你和他人之间的事
You see, in the final analysis, it is between you and God;
It is never between you and them anyway.

德兰修女
From Mother Theresa

2007-08-26

Extreme Ways

Artist: Moby

Extreme ways are back again
Extreme places I didn't know
I broke everything new again
Everything that I'd owned
I threw it out the windows, came along
Extreme ways I know move apart
The colors of my sea
Perfect color me

Extreme ways that that help me
Help me out at night
Extreme places I had gone
But never seen any light
Dirty basements, dirty noise
Dirty places coming through
Extreme worlds alone
Did you ever like it planned

I would stand in line for this
There's always room in life for this

Oh baby, oh baby
Then it fell apart, fell apart
Oh baby, oh baby
Then it fell apart, it fell apart
Oh baby, oh baby
Then it fell apart, it fell apart
Oh baby, oh baby
Like it always does, always does

Extreme songs that told me
They helped me down every night
I didn't have much to say
I didn't get above the light
I closed my eyes and closed myself
And closed my world and never opened
Up to anything
That could get me along

I had to close down everything
I had to close down my mind
Too many things to cover me
Too much can make me blind
I've seen so much in so many places
So many heartaches, so many faces
So many dirty things
You couldn't believe

I would stand in line for this
It's always good in life for this

Oh baby, oh baby
Then it fell apart, fell apart
Oh baby, oh baby
Then it fell apart, it fell apart
Oh baby, oh baby
Then it fell apart, it fell apart
Oh baby, oh baby
Like it always does, always does

2007-07-04

飞行十字勋章


这名来自宾西法尼亚国民警卫队直努克救援队的飞行员在没有着陆场的情况下依然靠自己的出色技术将机尾搭在了房子上将受伤的101st士兵救走.后来这名飞行员获得了飞行十字勋章。

2007-06-03

基督教
新约全书,歌林多前书第13章


爱是恒久忍耐,又有恩慈。
爱是不嫉妒,爱是不自夸,不张狂;
不作害羞的事,不求自己的益处;
不轻易发怒,不计算人的恶;
不喜欢不义,只喜欢真理;
凡事包容,凡事相信,凡事盼望,凡事忍耐。

2007-04-29

随缘

《太极张三丰》片尾曲

制作:音乐工厂
编曲:花比傲
作曲:罗大佑
作词:林夕

刀光剑影不是我门派
天空海阔自有我风采
双手一推非黑也非白
不好也不坏
没有胜又何来败

没有去哪有来
手中无剑心中无尘
才是我胸怀
随缘而去乘风而来
才是我胸怀

唇枪舌剑不合我姿态
天空海阔才是我风采
双手一推非虚也非实
不慢也不快
没有胜又何来败

没有动哪有静
手中无剑心中无尘
才是我胸怀
随缘而去乘风而来
才是我胸怀

2007-04-02

使用 Wininet 以 PUT 方法上传文件

客户端与 HTTP 服务器通常使用 GET 和 POST 方法进行交互,其中, GET 方法是客户端从服务器取得文件, POST 方法是客户端提交数据给服务器。
当我们需要上传文件给服务器的时候,可以使用 POST 和 PUT 方法。 POST 方法通常用来向表单提交数据,此时表单的 enctype 属性被设置为默认值"application/x-www-form-urlencoded" ,当需要向服务器提交大量文本、二进制数据时, enctype 属性将被设置为"multipart/form-data" 。 POST方法的优势在于能够在一次提交过程中传输多条数据和多个文件,但是实现起来比较复杂,如果我们只是需要传输一个文件的时候,使用 PUT 方法就方便多了。
PUT 方法的实现很简单,只需要打开 HTTP 连接,发送文件大小,读取本地文件,将内容以二进制方式写入到 HTTP 消息体中, MFC 代码如下:
  CInternetSession session;
  CHttpConnection * pHttpConn = NULL;
  CHttpFile * pHttpFile = NULL;
  try
  {
    pHttpConn =session.GetHttpConnection(m_serverHost, m_serverPort);

    //接收所有文件类型
    TCHAR accept[] = _T("*/*");
    //参数需要的数组
    const TCHAR *acArray[2] = {accept,NULL};
    LPCTSTR* ppstrAcceptTypes = acArray;

    //打开PUT方法的HTTP连接
    pHttpFile =pHttpConn->OpenRequest("PUT", m_serverObjectName, NULL, 1, ppstrAcceptTypes);

    //发送提交文件的大小,m_pLocalFile为文件对象指针
    DWORD fileLength =m_pLocalFile->GetLength();
    pHttpFile->SendRequestEx(fileLength);

    BYTE buffer[HTTP_BUFFER];
    //写入文件内容
    m_pLocalFile->SeekToBegin();       
    int nRead = m_pLocalFile->Read(buffer,HTTP_BUFFER);
    while (nRead==HTTP_BUFFER)
    {
      pHttpFile->Write(buffer, nRead);
      nRead =m_pLocalFile->Read(buffer, HTTP_BUFFER);
    }
    pHttpFile->Write(buffer, nRead);
    pHttpFile->EndRequest();

    //如果需要读取返回的结果,在这里调用 CHttpFile::Read 函数

    //释放资源
    pHttpFile->Close();
    pHttpConn->Close();
  }
  catch (CInternetException * pEx)
  {
    pEx->Delete();
    if (pHttpFile!=NULL)
    {
      pHttpFile->Close();
    }
    if (pHttpConn!=NULL)
    {
      pHttpConn->Close();
    }
  }
在上面的代码中,我们将本地文件上传到服务器中,由于 PUT 方法的消息体只能传送文件内容,所以,如果需要传输附加的参数,可以调用 CHttpFile::AddRequestHeaders 函数,具体使用方法请参考 MSDN 。
在 WEB 应用程序中,如果服务器端使用 ASP.NET ,可以通过 HttpRequest.InputStream 属性得到 Stream对象,从中读出二进制数据;如果服务器端使用 Java Servlet ,可以通过 HttpServletRequest.getInputStream 方法得到 ServletInputStream 对象,从中读出二进制数据。