Edmonton Devonian Botanic Garden

August 23, 2008 – 2:30 pm

Installing Django on Ubuntu 8.04 (Hardy Heron)

July 15, 2008 – 12:01 am

Goal: install Django SVN release on Ubuntu 8.04, working with Apache2, mysql, and mod_python.

Step 1: Install apache, mysql, and mod_python

sudo apt-get install apache2 mysql-server libapache2-mod-python python-mysqldb

Step 2: create a new database “mysite” and a new user “django” with password “password” in mysql

$ mysql -u root -p
mysql> CREATE DATABASE mysite CHARACTER SET utf8;
mysql> create user django identified by ‘password’;
mysql> grant all privileges on mysite.* to django;

Step 3: Install django from SVN repo.

cd ~

svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk

ln -s `pwd`/django-trunk/django SITE-PACKAGES-DIR/django

(Note:

SITE-PACKAGES-DIR = python -c “from distutils.sysconfig import get_python_lib; print get_python_lib()”

)

ln -s `pwd`/django-trunk/django/bin/django-admin.py /usr/local/bin

Step 4: Create a new django project.

cd ~

django-admin.py startproject mysite

Step 5: Add the following entry into the /etc/hosts file:

127.0.0.1    mysite   # so that we can access the web site by “http://mysite/”

Step 6: Configure apache with named virtual host.

Edit /etc/apache2/apache2.conf. Append a line “NameVirtualHost *” to the end of the file.

Create a new file /etc/apache2/sites-available/mysite with the following contents.

<VirtualHost *>
ServerAlias mysite
DocumentRoot /var/www/mysite/htdocs
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory “/var/www/mysite/cgi-bin”>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/www/mysite/logs/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/www/mysite/logs/access.log combined
ServerSignature On

Alias /doc/ “/usr/share/doc/”
<Directory “/usr/share/doc/”>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

<Location “/”>
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonDebug On
PythonPath “['/home/haobin'] + sys.path”  # replace ‘home/haobin’ with your django proj path
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</Location>

</VirtualHost>

Add ‘mysite’ to the Apache’s enabled sites: /etc/apache2/sites-available$ sudo a2ensite mysite

Reload apache: sudo /etc/init.d/apache2 reload

Point the browser to http://mysite/ and you should see the “Welcome to Django” page.

GPS not qualified for visa extended warranty

June 8, 2008 – 1:02 am

My car’s portable GPS navigation system was damaged. I bought it from ebay less than two years ago using a visa card. Usually visa doubles the product’s manufacturer warranty, to a maximum of one year, for free. From CIBC’s website:

Get Purchase Security and Extended Protection* Insurance* on most of your purchases charged to your card. Increase the manufacturer’s original Canadian or U.S. warranty up to one additional year on most of your purchases.

I never take advantage of the extended warranty before, so I gave it a try this time. Unfortunately, I was told the automobile parts and accessories are not cover by extended warranty, and GPS is considered automobile accessory. Too bad!

Ottawa Tulip Festival Photos

May 31, 2008 – 1:16 pm

One of the photos I took during a recent visit to Ottawa is published by the newspaper Ottawa Citizen.

Automatically startup fvwm in Cygwin

April 20, 2008 – 1:28 am

I have been using poderosa to manage multiple cygwin windows. However, poderosa remaps the key bindings for some common tasks. For example, if you want to copy from a cygwin window within poderosa, you need to use Alt+C instead of Ctrl+C, which is not very convenient.

In the end, I find it easier to install X11 and fvwm window manager in cygwin so that all the terminal windows are within one single X-window, as shown by this screenshot.multiple xterms in fvwm under cygwin

To order to start fvwm when “start” is executed, you need to do the following configuration:

1. cd ~

2. echo “exec fvwm2″ > .xinitrc

3. echo “exec X :0 -clipboard” > .xserverrc

4. startx

By default, when you move the mouse pointer to the edge of the virtual desktop, it will scroll to an adjacent desktop. This annoys me every time when I try move the mouse to the Windows taskbar but accidently scroll to another X-windows desktop. To disable desktop scrolling, you need to the ~/.fvwm/.fvwm2rc file and change the delay to -1 for variable EdgeResistance. e.g. "EdgeResistance -1 0"

订酒店的省钱秘诀

April 17, 2008 – 12:08 am

现在很多人都在网上订酒店了,因为网上价格一般便宜而且有很多选择。不过如果你直接打电话到酒店去订,说不定会得到比网上更优惠的价格。我们5月准备去Ottawa和Montreal旅游,前几天在网上看中了某间酒店,价格在$110-$120左右。我记得以前看过一篇文章说很多酒店都有business discount,即使你不是出差都可以拿到,所以这次我也想试一下。电话打到酒店前台,我问有没有business discount,却被告知work for government才有,心马上凉了半截。我接着问了标间多少钱一晚,对方说130多,我想怎么比网上贵这么多,黑啊!我又说在网上看到你们的价钱是$97,能不能price match呀?($97是我临时捏造的magic number.)对方说他们价格不能少于$99了,问我$99能不能接受。我心中窃喜,当然能啦!就这样,几晚下来就省了几十元了。

My new LCD Monitor: 24-inch Soyo DYLM24D6

April 15, 2008 – 2:51 am

I got a 24-inch Soyo LCD monitor from Futureshop last night while it was on sale. The price is quite good. I have been thinking about buying a new LCD for a while, but the 17″ Benq I have been using for 3 years is still doing OK so I put off the purchase. But at the fire sale price of $269.99 I couldn’t resist any more.Soyo 24\" LCD Monitor DYLM24D6

What I like about the new toy:

  • The size. The monitor looks more like a flat-planel TV rather than a computer display on my desk.
  • 1920×1200 resolution and vivid color are simply “legendary”!
  • It’s cheap!

What I dislike are mostly ergonomic issues:

  • The port connectors at the back are VERY awkward to reach.
  • The control buttons at the right side of the panel is not intuitive at all.
  • The appearance needs some artistic touch.
  • The name “TOPAZ S” sounds weird (to me at least).

There are some negative reviews about this monitor on the web. I hope those issues won’t apply to me because dragging such a huge monitor back to the shop for refund/repair ain’t going to be fun.