Monday, February 25, 2008

How to remove a file whose name starts with a - (minus)

use one of these commands:
rm -- -foo

rm ./-foo

Tuesday, February 19, 2008

How to lock screen in Ubuntu?

Ctrl + Alt + L

Thursday, February 14, 2008

Singleton in Python

We don't need Singleton in Python. We need singleton just because we need some static data and static functions. In Python we can simply use following code:

def InitStaticData(data):
pass

class Global(object):
""" A global class to store static data."""
__private_data = xxx
static_data = InitStaticData(__private_data) //assume it's a list.


def ReadStaticData(arg):
return Global.StaticData[arg]

The Global class itself will be initialized for one time. And we can define related static function in the module. The only thing we should do is: do not use __init__ of Global.

Keep in mind: in Python, each module is itself an object without having to define an explicit class.

Sunday, February 10, 2008

An abbreviation for Delivery

How about Dlvry?