Archive for August, 2006

Connecting to Sql Server from Unix or Linux with FreeTDS

To connect to Sql Server from *nix environment, you can use JDBC (Java), Perl’s DBI and DBD packages, unixODBC, etc. You can also use another open source tool called FreeTDS.

TDS stands for Tabular Data Stream. It is a protocol that defines how data is transmitted between computers. Both Sybase and Sql Server implement TDS. The detailed implementation may be different now for Sybase and Microsoft, but I don’t think the basic principal has changed much over the years. FreeTDS is a tool that is written on the TDS protocol. It works both with Sql Server 2000 and Sql Server 2005. It also works with Sybase.

A few years ago I helped out a LAMP (Linux, Apache, MySql, PHP) project. The web application was working fine. Later on there was a need to generate web reports based on data from Sql Server 2000. So I helped setting up FreeTDS on RedHat Linux to solve that problem.

Ever since Sql Server 2005 came out, I’ve been meaning to test it to see if it works with Sql Server 2005. I finally did it today. I am happy to report that it does work. Here is my procedure on Cygwin:

1. wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
(Note: the link to the tar file may be different)
2. tar -xvf freetds-stable.tgz (Note: your file name maybe different)
3. cd freetds-0.6.4 (Note: your folder name maybe different)
4. ./configure --with-tdsver=8.0 (Note: it is important to have this tdsver=8.0 option)
5. make
6. make install

To verify you did it successfully, launch tsql on the command line. tsql is a command line utility that comes with FreeTDS. It does not have a lot of command line switches. The few it has are very similar to osql and sqlcmd.

For example, you can try:

tsql -S MySqlServer -U sa

and you will be prompted for password.

Once you are in, issue some command. For example, you can try

select name from sysdatabases (on Sql Server 2000) or

select name from sys.databases (on Sql Server 2005)

and see if you get results back.

Comments (5)

教孩子中文的一些信息

我七岁的儿子上周开始读中文学校。尽管他刚成为二年级的学生,但他从中文一年级读起。他的情况比较特殊:我讲英语和汉语,而妈妈讲瑞典语和英语,所以我们在家里讲英语。儿子三岁时到一家日文学校读幼儿园和学前班。升入小学后,下午三点放学后每天还会到这家日文学校。之所以去日文学校,是因为当时在我家附近没有好的中文学校。

我想在他的年龄段,他的日文应当没问题。日文学校的一个好处是他接触了汉字的书写,并且字意也差不到哪里去。所以他在汉语书写上有少许基础。汉语口语方面,我们一起看过BBC的Muzzy中文视听教程,一起玩过WawaYaya的游戏软件,我随之引进更多的汉语说话。绝大多数情况下,他不会用汉语回应我们的对话,但他倒是可以听懂一些。他的汉语听力和口头表达能力是跟不上同龄的在家讲汉语的孩子的。我跟他讲汉语时还要讲究策略,否则只会造成孩子的反感和抵触。

中文学校是周末授课,每周只是两个小时。有家庭作业。学校用的是马立平为海外中文学校编写的教材。这个教材的几个特点是先直接识字,三四年级才学拼音和强调读字能力等。我们刚开始用这本教材,所以不好妄加评论。

无论如何,这儿是我搜集的一些链接。我的目的是抛砖引玉。希望能听到家长和读者的评论或电邮,以达到互相切磋、共同提高的效果。

山菊花的中文教材评论
欣华中文的材料

Comments

Psychic connection

I pass this business every day on my way to work. It is on the south side of Roosevelt Road in Lombard, a suburb of Chicago.

Psychic Connection

This actually reminds me that Raymond Chen, programming guru at Microsoft, is known for his psychic debugging skills. According to wikipedia, he is also known for pithy comments and his custom of wearing suits at work. Let me tell you, the guy’s IQ is orders of magnitude bigger than mine.

If the business pictured above also practices astrology, I wonder if the recent demotion of Pluto affects its predictions. I heard a pretty funny interview on NPR the other day. An astrologist interviewed said that any of his peers who used Pluto for his/her clients should be liable of malpractice.

Comments

How do you get on your bike

Raymond Chen has an interesting post titled the cultural anthropology of getting on a bicycle. I left a comment there. It is fairly long so I decided to cross post it here.

There were no children’s bike when I was growing up in rural China in the 70’s. Since bike was such a valued possession of the household, and most family just had one, letting you learn to bike is a sort of milestone in your childhood. That means you are old enough and competent enough that your parents trust you can handle it with care.

The first step in the process is to learn to scoot on the bike, almost always on the left paddle. In Chinese, I call it 遛车子. At this point most likely you are not tall enough to even get on the seat by yourself yet. This step takes days or weeks, depending on the child.

The second step, as Geoffrey mentioned in his comment at Raymond’s site, is to stick your right foot through the frame, under the horizontal bar between the seat and the vertical bar below the handlebar in the front, and pedal away. This requires a lot of balancing skills and finesse, as your center of gravity is on the left side of the bike constantly, swinging up and down as you go forward. This is the only way to “ride” the bike at this point, as you are not tall enough to ride on the seat yet. We call it 掏腿骑. Remember there were no children’s bike then.

Usually when you are tall enough to be able to sit on the seat and still reach the pedal, your balancing skill is such that you can swing your right leg over the back to get on, or raise your right leg in front of your body and move it across the horizontal bar. In general, the later method is preferred by girls, as it can be considered ungraceful to spread and swing your leg over the back. That also depends on if you carry groceries or other things on the seat in the back. Sometimes people mount two baskets, one on each side, on the side of the back seat. That will force you to get on from the front.

A lot of times adult carry their small child on the bike. The child sits on the horizontal bar, holding his/her hands on the handlebar. You can buy an optional seat that can be mounted on the horizontal bar, close to the handle, to make the child feel more comfortable.

But that is not all. You can put a child in the front and still carry something or somebody in the back seat. If you carry a person in the back, the person has to run and hop on the seat after you are safely in motion. For a girl or woman on the back seat, she needs to sit sideways, as again it can be considered ungraceful to ride on the back seat with your legs spread on each side. Woman rides on a donkey the same way.

As kids getting bigger, sometimes they get on the bike the American way, as it has a certain kind of rugged and manly aura to it.

I am sure things are different now, but I wouldn’t be surprised if the traditional way is used in more remote or poor areas.

Comments (2)

View and kill processes in Linux and Solaris

On *nix system, the ps command is kind of like Windows task manager. It provides running processes information. Once you find the process ID, you can kill it using kill command.

On Linux machines, you can type

ps ux

to list all your own running processes. The second column, PID, is Process Identifier. By looking at the rightmost column, you can find the PID’s corresponding program. You can use the following command to kill a process:

kill -9 PIDHere

On Solaris, ps works a little differently. To find out your own running processes, type:

ps -au MyLoginName

The first column in the resultset is PID. The last column is the program name. Use the kill command above if you need to kill one of your processes.

This is more of note to myself as I am doing more work on Linux and Solaris environment. Hope you find it helpful. Let’s just say I have a long, long way to go before I reach Dannyman’s level.

Comments (2)

Cirque Shanghai At Navy Pier

Cirque Shanghai At Navy Pier

We saw Cirque Shanghai at Navy Pier a few days ago. It was a Chinese circus show with a lot of great acrobatic performances.

I enjoyed it. For my son, since he was a little tired, the performance was long to him. If I recall correctly, the show lasted for about 1 hour and half.

Growing up in rural Ji Village, once in a while, there would be travelling troupes performing kung fu and acrobatic stunts in the village. They would first beat gongs and drums to get villager’s attention. When a sizable crowd gathered, they would start performing, usually at the square in the middle of the village, with somebody collecting money from the audience during and after the show. I don’t think they earn much. Some kind villagers would offer the troupe a meal. I only remember one performance, where a small monkey was involved with some stunts. Not sure how old I was then, but I had a secret crush with a young girl about my age in the troupe for quite a while.

I also remember I saw a couple of puppet shows growing up. When the artists or troupes are here, all the children are excited. I think most adults are excited too. For adults, once in a while there are travelling story tellers in the village. Performance usually starts after dinner. The story tellers, sometimes a couple, do some singing with Er Hu (二胡) and/or Yang Qin (杨琴) first, then proceed with that night’s chapter of the story. The story is delivered in different ways: singing, speaking, accompanied by traditional music playing. You can get a very good glimpse of those travelling artists’ livies from one of my all-time favorite movies, To Live. It takes days, sometime weeks, to finish a story. I remember a blind couple story tellers who stayed in my village for at least a few weeks. The stories are mostly traditional Chinese classics, such as 水浒传 or 三国演义.

Anyway, I recommend the show highly if you are interested. Here is the URL to Navy Pier, where you can find the link to Cirque Shanghai performance. The run will be over by the 3rd of September.

Here are a few more pictures. More pictures can be seen here.

Cirque Shanghai At Navy Pier

Cirque Shanghai At Navy Pier

Cirque Shanghai At Navy Pier

Comments (2)

Analyzing queries using DTA

I blogged about using Database Engine Tuning Advisor (DTA) to analyze your workload here.

Like Indexing Tuning Wizard, you can also use DTA to analyze your queries. However, the way to invoke that is not obvious, because you cannot do it directly from within DTA.

You need to have the query open in the Query Window of Sql Server Management Studio first. Go to the Query menu, then pick Analyze Query in Database Engine Tuning Advisor. This will open DTA. After connection, you will see Query radio button is selected in the Workload area. The Query Radio button is not visible if you open DTA directly from Start -> Programs.

Comments

支持我友杜朝运

朝运是我的大学同窗兼室友。我们在厦大时,总是住在芙蓉十靠角的一个房间里。因为房子稍大,所以住着九个弟兄。一般的房间基本上住八个人。以现在的角度来看,四张双人床,八套桌椅,八个年轻人,确实很难有个人的空间和隐私。但当时大家都是如此,倒真没感到有什么大不了的。

2004年回母校参加毕业十周年聚会,以我的观察,好像当时每个房间至多住四个人,也有不少的房间里只有两三个人。看来住宿情况好了很多。

朝运的成绩一直很好。大学时,他就有年轻人少有的乐观、豁达与成熟。毕业后,他留校继续攻读。之后曾到云南支贫一段时间,很让我敬佩和羡慕。他现在是我校金融系副主任,博士生导师。

他几个月前开始写博客。其文字感性,观察细腻,字里行间,不时有轻松的幽默,让人在莞尔一笑的同时获得一些启发。从他的随笔里,我不难看到其为人师表、爱惜学生之情。

但古今中外,总有一些小人,或穷极无聊,或心理失衡,总爱造谣蛊惑,甚至搞人身攻击。我因在朝运的博客上看到不少这样的评论,所以写下此篇,以示支持。

Comments

Sean不是Seen

外文这个东西,初学者对词的发音会按课本上的常规来。大部分情况下,这个准则不会错。但对于一些非常规的词,如果没有内行人-即以她为母语的人或过来人-的指点,就会把人弄得一头雾水,闹出一些笑话。而这些词都以名字居多。我就有不少这样的经历。

举例说来,影迷对肖恩-康纳利(Sean Connery)都不陌生。60和70年代的几部虚构的007英国间谍电影就是由他主演。很长一段时间,我都把他的名字读成Seen。刚才在网上搜一下,发现有一些地方把他的名字译成西恩-康纳利。看来这样的译者也和我犯了同样的错误。

Sean作为一个名字,他的发音应当是Shawn。从这个角度来看,肖恩-康纳利的翻译和原文更贴切。

再比如我最早接触到的欧美歌手之一是Paul Simon。Simon是一个比较常见的名字,可以做名,也可以做姓。很长一段时间里我把Simon里的I读成Sit里的I。其实它在这儿应当发它的字母音。

Michelle是另一个例子。开始时我把这个词里的CH读成Chair里的CH。但实际上它和Chicago里的CH是一个音。所以Michelle应读成mir’Shell。

有一个不太常见的人名Esther。我对这个词把握不准。我感觉这儿的H和Thomas的H一样,不发音,所以可读它为Ester。

我写这些倒不是要吓唬亲爱的读者,以至于不敢张口。每个语言都有自己的特例。不出一些小错误,怎能进步?且不可因噎废食。

先写到这儿。我还有其它词和你分享,且听下回分解。

后记:如你感兴趣,几个月前我在这儿写了一些我学英语的体会

Comments (3)