Archive for March, 2006

Spring Break 2006

It’s Spring Break for my first-grader. He is having this week off. So tomorrow I will bring him to Dallas, Texas to see my brother’s family and my nieces. We will stay there for a few days and fly back to Chicago on Saturday.

The season change is subtle and gradual, with even a few setbacks along the way. Here is a picture of a snowy day when we visited Brookfield Zoo. The snow melted away soon afterwards.

Snow on the way out of Brookfield Zoo

Days are definitely longer now. When it is sunny, it feels really nice to be outside. My son and I have been out and playing in the last few weekends. Here are a few pictures of him playing in Scoville Park:

Seesaw
Seesaw at Scoville Park

Swing
Swinging at Scoville Park

Yesterday we went to Shedd Aquarium. We took the train to downtown first, and then took No. 14 bus to the museum campus. I take trains like this to work every weekday. We sat on the upper-level, my son’s favorite level:

Metra train to Chicago

This is a shot of Lake Michigan and Navy Pier from the museum campus.

View of the lake and Navy Pier from the Museum Campus

We saw an Australian lungfish at the aquarium, see picture below, who came to the aquarium in 1933. So it is at least 73 years old and was appropriately named Granddad. I never thought it could live that long. That is pretty amazing.

Australian lungfish at Shedd

Visiting the aquarium is always a great experience. It is so nice to see different and interesting animals from all over the world, and appreciate the diversity nature provides. Here are a few more pictures.

Knifefish from the Nile
Knifefish from the Nile at Shedd

Paddlefish
Paddlefish at Shedd

Comments (1)

胡适与胡适之

我正在读团结出版社于1996年编版的《胡适自叙》。用该书的话来说,胡适(1891-1962),“是中国现代有影响的学者和思想家,是传统中国向现代中国发展过程中继往开来的一位启蒙人物”。从我有限的阅读和其他我所尊敬的作者对胡适的态度来看,对这位启蒙人士的评价,是很难说过头的。我个人对于他的“多研究些问题,少谈些主义”的观点非常赞同。

在国内读书的时候,我读到的东西都一直称他为胡适。也可能我当时不在意忽略了。但在我最近读的林语堂、季羡林和李敖的文章里,不少提及他的地方,有的称其为胡适,有的称其为胡适之。我对此一直搞不明白。现在我把《胡适自叙》读了一大半,才明白了原因。

胡适原名嗣糜,学名洪骍。在1906年左右,胡适在上海上学。当时严复的《天演论》及社会达尔文主义非常流行。一天他请二哥代想一个表字。他二哥就说出了“物竞天择适者生存”的适字。他很欣赏。胡适的二哥和三哥的字分别为绍之与振之。所以他就为胡适之。他与1910年赴京考赴美留学。在另一文中,他写道:“我怕考不取为朋友所笑,所以临时改用胡适的名字。从此以后,我就叫胡适了”。胡适的率直自此可见一斑。(见该书第77页及114页)

在我看来,出版、介绍胡适、蔡元培、林语堂、梁实秋、周作人等其他很多人的文章与传记是非常有意义的事情。这些人大都是新文化运动的领导者与推动者。他们中很多人亲历过中西文化,生活在不稳定的政治、经济和社会环境里。当时国内有很多挑战,国际形势也不稳定。而他们在那种大环境下,尽其所能,写出了不少比较客观的分析与评论,引进了不少新的观点和思维方式。这些文字,今天读来,仍有不少感想和共鸣。

我最近读的这些人的选集与传记,都是后人选编的。这倒无可厚非。读过之后,我感觉有以下方面可以提高。但暇不掩玉,总的来说,这些书对我都非常有启发:

一、所选的文章,都应标明初始的出版或写作年代。如可能的话,写作地点也会有帮助;
二、对原文和题目,不要作删改或调整。还是原汁原味最地道。

Comments (2)

Script to set default data and log file folder in SQL Server 2005

Hopefully your server has separate spindles for your database’s data and log files. Here is the script to define the default directory / folder for database data and log files in Microsoft SQL Server 2005:

USE [master]
GO
EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’DefaultData’, REG_SZ, N’ChangeThisToDefaultDataDrive:\data’
GO
EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’DefaultLog’, REG_SZ, N’ChangeThisToDefaultLogDrive:\log’
GO

Comments

My WordPress backup and restore process

As I am writing and publishing more and more blog entries, it becomes important that I have good and reliable backups. I know that if something happens and I cannot recover my entries and comments, I would be terribly upset. So I want to share my process here. Please feel free to share your backup methods by commenting. Hopefully somebody will find it useful.

Backup comprises two parts:

1. File backup

On a Linux machine with Apache, the default web files and directories reside in /var/www/html. Yours may be different. This include all php files and sub-directories like wp-content, wp-include, etc.

The easiest way to do it is to use tar command with -z to compress them. My post here gives you a pointer on tar.

These files are fairly static, so you do not need to back them up too often. You want to do file backup after you tried a new theme, installed a new plugin, etc. You should transfer this backup to a different box, in case the web host dies.

2. Database backup

For mysql database backup, you can use mysqldump, a utility that comes with mysql. mysqldump will iterate through all tables within the database, get their ddl, and dump all data in the form of insert statements. Below is the code to dump everything out and compress them using gzip:

mysqldump -q -e -hlocalhost -uLogin -pPassword MyBlogDb | gzip - > ./BlogDbBackup.sql.gz

Once again, gzip can shrink the size down pretty substantially. So do use it, especially if you have space issues.

There is a database backup plugin that comes with WordPress 2, which is the method I use. However, you do need to run chmod 777 on your database backup directory. If not, you will see the warning message of not enough privilege on your WordPress manage page. And you should be able to find out the backup directory name from that page, so you can run chmod.

In addition to the backup plugin, I also installed the wp-cron plugin. With wp-cron, I can schedule daily database backup and send it to an email address I defined. If I have a choice, I’d rather put everything in a shell script that backs everything up, compress them, and email the file to me. I then use cron to schedule it. However, since I am not root on my web host, I have had troubles setting up a smtp client for email, as documented here.

Now backup is done. The next step is to make sure my backup files work. I set up a standalone LAMP (Linux, Apache, MySql, PHP) box, extracted php files, restored the database by running:

mysql -hlocalhost -uLogin -p MyBlogDb < BlogDbBackup.sql

I then modified wp-config.php file. And behold, it worked. Even my Chinese entries displayed properly.

In a future post, I will share with you some of the lessons I learned in the process. Stay tuned…

Comments (1)

Tunneling http traffic through ssh

James Strassburg gave a great tutorial on tunneling http(s) traffic through ssh with your Linksys WRT-54GL router.

Actually, if you have a server that you can ssh to that has web access, like your web host, you can tunnel all your http(s) traffic through that server from your Windows workstation. It is pretty simple to do:
1. Ignore James’ discussion on how to setup Linksys, unless that is what you want;
2. Download PuTTY client for Windows. PuTTY is a stand-alone Win32 executable. As such, it has no registry change, separate directory creation, and all other garbage associated with a typical Windows application. Get PuTTY.exe and it just works;
3. Follow the rest of James’ instruction on creating a SOCKS proxy (here entering the IP address of your web host), changing your connection setting in Firefox. And you are all set.

I found this to be extremely valuable. Thanks a lot James.

PS. I normally don’t look at calendars at home. But today I happened to look at our Swedish calendar, and noticed tomorrow, 2006/03/15 is the name day for Kristoffer. So happy name day to my Swedish friend Christoffer Hedgate. Somehow picture of tranorna kommer till Hornborgasjön, Västergötland on the calendar caught my attention.

Comments (1)

I want to lawyer him

Children’s language is always interesting. It can be cute, innocent, confusing, and funny at the same time.

We played at Scoville Park next to the library yesterday. I was sitting on the bench supervising. Benjamin stopped and walked over. He told me that he was still on the slide when another kid came down and crashed into him. He told me he wanted to “lawyer him”, with all seriousness on his face.

In the last couple of months, Benjamin has been using “besides” a lot. A lot of sentences would start with a “Besides”.

A few years ago, when he was between 2 and 3, he would call a restaurant an “eat store”, as opposed to “toy store”, I guess.

I love my boy!

Comments (1)

地道的美式英语

我是初一开始在镇上的市立中学学英语的。那时初高中的英语我感觉都是英国式的英语。进入厦大后,由于口语老师都是从美国来的,有一门经济学课也是美国的富布莱特基金教授来教,所以美式英语的影响就较多。再加上大三和大四时考托福,所以自然也是练美式听力。记得当时班上有很多人用短波收音机来收听美国之音的英语节目,我也包括在内。

当时,可能现在也是如此,报章上的关于在美国学有所成的人的报道,不少都说某人“操一口流利地道的美式英语”。那时对此人都会羡慕的要死,心想我若能达到这一地步,岂不快哉!

在美国居住了近11年之后,才知道那样的评论大部分都不可能属实。我想原因主要有以下两点:

1 什么是地道的美国英语?一般人的理解大多是好莱坞影片里的或是播音员的英语。那样的英语主要是加利福尼亚口音,并不能代表美国多样的口音及方言。

举例来说,美国南部的英语有浓重的口音,虽然在南部之内也会有地域的差异。像德克萨斯、密西西比州的不少人都会说得慢一些,音调长一些。而新英格兰(波士顿地区)、纽约、及中西部的口音也都有自己的特色。这里且不论各个族裔内的独有的口音及俚语;

2 即使我们把加利福尼亚英语作为地道的美国英语,对于中国出生、中国长大的人来说,能够说得标准到听不出口音的人,可以说是极少极少。实际上这对任何国家的人来说都是一样。因为人一超过十几岁的年龄,那种自然的接收语言的窗口已经逐渐关闭了。带一些口音是正常的。

换句话说,讲带口音的英语又有何坊?我个人有以下经验与读者分享:

1 讲英语时不要追求酷和潇洒,能说清楚、明白、简洁是最好的。在很多情况下,你要说慢一些才能达到这一目的;

2 你的口音是你个人的一部分。实际上不少人会认为外国口音有意思,甚或有魅力。施瓦辛格的演技那么差,美国不少人是冲着他的浓重的奥地利-德国口音去看他的电影的。当然也不要自以为某种口音特有魅力而刻意模仿,弄得不好,只会东施效颦,适得其反;

3 对交谈中的重要信息,不要囫囵吞枣,不懂装懂。对不明白的东西,可以问对方,或者换个角度说一说,尽量减少误解。

至于我自己,我的另一半说我的英语没有典型的中国口音。我们的好友苏珊也说我的口音很奇怪,单从语音上不好听出我从哪儿来。奇怪的是,不知为何,一杯小酒之后,我的英语和汉语都变得非常流利。

以下是在离我工作不太远的快餐店里拍的照片。挺有意思的。

Sign from Fast Track restaurant

Comments (7)

sqlcmd error handling

I did manage to work while in Barcelona last month, not just to visit. I delivered a session on sqlcmd, attended other sessions, and learned from others.

After the session, fellow PASS volunteer Thomas LaRock asked a great question regarding error handling. Pat Wright also talked about the same issue in this blog entry here. Pat, I tried to comment but couldn’t. Hopefully trackback will work at Sqljunkies’s blog site.

For example, take the code below (copy and paste the code into a .sql file, then run sqlcmd -i FileName.sql):

:On Error ignore

--Part 1
:connect ServerName1
select @@servername
go

--Part 2
:connect NonExistentServer
select @@servername
go

--Part 3
:connect ServerName2
select @@servername
go

The above code can be used to periodically check if Sql Server is online. The only trouble is, when it reaches Part 2 and connect to NonExistentServer, which does not exist or is down for whatever reason, the program will immediately terminate and Part 3 won’t be run. Why is that? Didn’t we specify to :On Error Ignore?

BOL (Book On Line) has this to say regarding :On Error:
Sets the action to be performed when an error occurs during script or batch execution.

:On Error only defines the behavior when you are running some scripts against a Sql Server instance, when you are connected to a server. In other words, it only governs the error conditions of t-sql statement, not commands for sqlcmd. It fails in the above example because the failure point is at the connection time, not when it is executing sql code.

Let’s look at another example:

:On Error ignore
:connect ServerName1

--Part 1
select @@VVservername
go

--Part 2
select @@servername
go

In the code above, Part 1 will error out, since @VVservername is invalid. However, Part 2 will run because that t-sql error will be ignored.

To solve the issue listed in the first example, consider put the following code in a batch file and run the batch file instead:

sqlcmd -S ServerName1 -Q "select @@servername"
sqlcmd -S NonExistentServer -Q "select @@servername"
sqlcmd -S ServerName2 -Q "select @@servername"

Comments

File type, directory size, free space, disk usage, and tar in Linux

A few quick notes for people who want to know how to do simple things in *nix. This is for Windows users who are making the transition or find themselves dealing with *nix from time to time.

Use file FooBar to find out what kind of file FooBar is. This is helpful when you need to know what program is needed to open FooBar file.

To find out size of a directory, including the size of subdirectories, use du -ah.

To find file system disk usage, use df -h

Note on Solaris, based on my experience, -h won’t work. You will have to do -k, which to me is a pain.

Quick note on tar:
tar -cvf archive.tar FilesOrDirectoriesToBeArchived
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xvf archive.tar # Extract all files from archive.tar with verbose output message.

To archive and compress in one shot, add z, which uses gzip/gunzip for compression/decompression:
tar -czvf archive.tar FilesOrDirectoriesToBeArchived
tar -tzvf archive.tar # List all files in archive.tar verbosely.
tar -xzvf archive.tar # Extract all files from archive.tar.

Comments (1)

Barcelona, day 4, 5, and 6

I am back from Barcelona, currently recovering from a pretty bad flu and fever. In all, I had a great time attending the conference and visiting the city. Hopefully I can bring the whole family there some day. It’s a truly wonderful place.

I spent most of day 4 and 5 attending sessions, socializing with attendees and speakers, and just trying to have fun in general. It was great seeing my Swedish friend Chris Hedgate, his buddy and pair-programming partner Andrés Taylor. Congratulations to Chris and family on becoming parents soon!!!

It was also nice talking with Randy Dyess, Wayne Snyder, Kevin Kline, Marin Mamić, Rick Heiges, Rushabh Mehta, James Luetkehoelter, Tom LaRock, Greg Low, Bill Wunder, Bart Duncan, Joe Webb, Bill Graziano, Reed Jacobson, Haydn Richardson, and fellow co-author Darren Green, and a few others whose name I couldn’t remember at the moment. I have good excuse, though. The flu and fever knocked me out real good. Anyway, in my view, networking and learning from others is the biggest benefit of the conference, followed by attending sessions.

Marin suggested, an excellent idea I might add, we go to town Wednesday night and watch the football match between Barcelona and Chelsea in a bar/restaurant. We had a great time, although the main dish left a lot to be desired. I hadn’t seen a real football match (according to the rest of the world) in years, ever since I came to the US in 1995, so that was a nice change.

Thursday evening we went to Port Olimpic for dinner. The food was much better. Chris has been to Barcelona before. I was totally impressed by his accurate memory of places he’s been to. There are many restaurants in Port Olimpic. In front of each one, there is usually one person trying to talk you into eating at his/her place. That actually reminded me of restaurants in southern China during my travel to my university town, because the same practice was used.

Friday evening we saw a beautiful water show in front of the Museum of Contemporary Art. We then had pizza for dinner. The pizza looked and tasted the same as American pizza.

On Saturday Marin and I did a walking tour of the city. We took the Metro so we could get close to Parc Güell. From there we pretty much walked the whole day around the city. We walked to Sagrada Família, Casa Milà, La Rambla, the Cathedral, and finally back to the hotel. It was a great day. I assure you, you couldn’t find a better tour companion than the one and only Marin Mamić. We had a great time together, talking and learning from each other. We also had a memorable snack/lunch.

Water show in front of Contemporary Art Museum, Friday evening
20060224Barcelona 124

As hilly as San Fransisco? I’ve never been there.
20060228Barcelona 128

A nice house behind Parc Guell
20060228Barcelona 132

The famous bench in Parc Guell
20060228Barcelona 137

Inside Parc Guell
20060228Barcelona 151

The famous lizard/iguana. It’s hard to take a good shot because there are usually a lot of people here.
20060228Barcelona 161

Old and small BMW
20060228Barcelona 169

A carnivore’s heaven
20060228Barcelona 171

Our tapa lunch. Not sure what kind of bird it is (quail, pigeon?), but it sure is delicious.
20060228Barcelona 177

Our tapa lunch. Yummy.
20060228Barcelona 178

Outside of Casa Mila
20060228Barcelona 181

I guess bidet must be common in Spain. Inside one exhibit room in Casa Mila.
20060228Barcelona 195

Interesting sculptures on top of Casa Mila.
20060228Barcelona 206

The Gate of Triumph (I still have trouble pronouncing the word, after living in the US for so long.)
20060228Barcelona 214

IKEA on the way to Barcelona airport
20060228Barcelona 219

Comments (4)