2008年10月24日星期五

My Child Dream

For many years, I've forgotten my child dreams.

I mean, I can not remember them now.  I even doubt if I did have them.
But maybe, I had.

Here is some scratches:

* I want to have Noble Price.
* I want to be a scientist.
* I want to know the beauty of the universe.
* I want to write a book which is very humorous and interesting.
* I want to have a big house with a big library.

My dream has never changed.
--
有一种人,不知道是因为DNA的变异还是前世的夙缘,总是无法安稳下来。他们的生命之流如同咆哮奔涌的大河,没有一刻能够停顿下来。在寂静无人的深夜里,无梦相扰的安睡中,心中也有猛兽会随时醒来,躁动不安,永无宁日。

2008年10月11日星期六

A demo of "connection_pool" in soci.

Source File.

//soci.c
#include <soci.h>
#include <soci-postgresql.h>
#include <iostream>
#include <istream>
#include <ostream>
#include <string>
#include <exception>

using namespace soci;
using namespace std;


connection_pool *pool = NULL;

void create_pool()
{
pool = new connection_pool(5);
int pool_size = 5;
session *s[pool_size];
int i = 0;

//Open connection on every session in the pool
for(i = 0; i < pool_size; i ++)
{
s[i] = new session(*pool);
s[i]->open(postgresql, "user=postgres password=milk dbname=mydb host=localhost");
}

//Return every session to pool
for(i = 0; i < pool_size; i ++)
{
delete s[i];
}
}

bool getName(string &name)
{
cout << "Enter name: ";
return cin >> name;
}

int main()
{
try
{
create_pool();

session sql(*pool);

int count;
sql << "select count(*) from phonebook", into(count);

cout << "We have " << count << " entries in the phonebook.\n";

string name;
while (getName(name))
{
string phone;
indicator ind;
sql << "select phone from phonebook where name = :name",
into(phone, ind), use(name);

if (ind == i_ok)
{
cout << "The phone number is " << phone << '\n';
}
else
{
cout << "There is no phone for " << name << '\n';
}
}
}
catch (exception const &e)
{
cerr << "Error: " << e.what() << '\n';
}
}

Makefile:

all:
g++ -g -I/usr/include/postgresql -I/usr/local/include/soci -lsoci_postgresql -lsoci_core soci.c -o soci

--
有一种人,不知道是因为DNA的变异还是前世的夙缘,总是无法安稳下来。他们的生命之流如同咆哮奔涌的大河,没有一刻能够停顿下来。在寂静无人的深夜里,无梦相扰的安睡中,心中也有猛兽会随时醒来,躁动不安,永无宁日。

Fwd: 你们如何和固执的而缺少知识的同事打交道的呢?



---------- Forwarded message ----------
From: 一首诗 <newptcai@gmail.com>
Date: 2008/10/11
Subject: 你们如何和固执的而缺少知识的同事打交道的呢?
To: python-cn`CPyUG`华蟒用户组 <python-cn@googlegroups.com>


Hi

我们最近招了一位同事,主要考虑到他有2/3年的相关工作经验,所以没有仔细考察过。

来了之后发现有两个特点:

1. Very pushy.
2. 非常相信自己的经验,但是缺乏一些必要的知识,并且讨厌学习。

我有一次刚刚看完一点完成端口相关的文章,因为听他以前吹过说他很了解这个,就和他谈了一下,发现他只是用过,完全不清楚为什么这个东西背后原理。他告
诉我之所以完成端口比较快,是因为"后面用了线程"。

这样我和他争论问题的时候,我总感觉他因为缺少一些知识,所以沟通起来很费劲。他找不到说服大家的道理,但是他会很坚定的说"我这么多年的经验告诉
我……"

任何一个技术决策,都会有多方面的考虑,虽然我很多时候相信自己的选择是最优的,但是我不能否认也许我的方案是有负面因素的。

而且更重要的是,虽然我看东西的特别多,了解一些原理方面的东西,但我的开发经验,主要没有在这方面,所以是否实际中有什么问题我不清楚的会造成他说的
情况,我也不能肯定。

于是每次我有争论的时候,我不知不觉得会都让着他。其他同事和他争论的时候,因为没有他那么pushy,所以慢慢也会让着他。

如果你们遇到这种情况,你们会怎么做呢?

是相信他的经验呢,还是相信自己的分析?

反正,现在基本上,除了我觉得一定是有大问题的情况,一般都由着他做了。

呵呵,也许应该就事论事,对事不对人吧。



--
有一种人,不知道是因为DNA的变异还是前世的夙缘,总是无法安稳下来。他们的生命之流如同咆哮奔涌的大河,没有一刻能够停顿下来。在寂静无人的深夜里,无梦相扰的安睡中,心中也有猛兽会随时醒来,躁动不安,永无宁日。