2005-04-26

让我们把google玩出更多新花样吧

GUESS-the-GOOGLE! flash的猜词小游戏,还有高分榜的哦。

更新:刚玩了一局,得了254分。似乎都是常用的单词,只要认真玩肯定能得不少分的 :)

2005-04-22

IE真的很烦

找到我的blog在IE里显示白板一块的原因了,原来是我utf8编码的blog名称造成IE水土不服。只要我的html代码里还有“<title>举头望明月</title>”,IE就不能正常显示。只好改名了。恼火的是,在firefox里显示很好的css布局,原来在IE里也会不太正常。唉,有时间再改吧。
Tags:

2005-04-19

纪念爱因斯坦

今年,验证引力波的Einstein@Home工程启动了;今天(4月19日),为了纪念爱因斯坦,全球范围的“光传递”活动也已经开始。

不管人们如何评判爱因斯坦,他对现代物理与现代社会的影响都是无以伦比的;就让“物理照亮世界”吧。

2005-04-18

又一个测试

还是那个16人格的测试,不过是另外一种测法。多测试一些,就多了解自己一些 :)
您的人格类型是: ISTJ (内向,感觉,思维,判断)

您的工作中的优势:
  ◆ 办事精确,希望第一次就能把工作做好
  ◆ 乐意遵循确定的日常安排和传统的方针政策
  ◆ 每次都能十分专注地把注意力集中在一个项目或者任务上
  ◆ 能够独立工作
  ◆ 灵敏地组织能力
  ◆ 一丝不苟,认真专注地对待具体问题,事实和细节
  ◆ 相信传统地可取之处,并且能够遵循传统模式
  ◆ 非常强的责任意识,别人可以信任你实现自己的诺言
  ◆ 明白清晰的工作伦理,认为高效率和多成果是很重要的
  ◆ 对实现目标有毅力和决心
  ◆ 通情达理,视角现实

您工作中可能存在的不足:
  ◆ 不愿意尝试新的、没有经过考验的观点和想法
  ◆ 对变动感到不安,排斥变革
  ◆ 对需要很长时间才能完成的项目和任务缺乏耐心
  ◆ 有时会因为近期目标而忽略长远需要
  ◆ 办事死板,必要的时候难以事情新情况
  ◆ 难以看到问题的整体以及行为的长远影响
  ◆ 对于方针或者决定对别人造成的影响缺乏敏感性
  ◆ 需要的时候不愿意改变努力的方向或者调整投入的多少
  ◆ 不愿意促成必要的改变,也不愿意支持经过仔细考虑的风险行为

Tags:

2005-04-10

控制台下,python的自动完成功能

继承unix like系统的优良传统,python也拥有强劲的readline模块(只在UNIX类系统中才能使用),可以很轻松的实现自动完成的功能。下面是我的一些设置:
0$ env | grep python
PYTHONSTARTUP=/home/xyb/.pythonstartup.py
PYTHONPATH=/home/xyb/.python:/home/xyb/py:./
0$ cat ~/.pythonstartup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last modified: 2004年11月11日 星期四 10时50分39秒 [xyb]

import sys
import LazyPython
sys.excepthook = LazyPython.LazyPython()
del sys, LazyPython

# Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it: "export PYTHONSTARTUP=/max/home/itamar/.pystartup" in bash.
#
# Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
# full path to your home directory.

import atexit
import os
import readline
import rlcompleter

readline.parse_and_bind('tab: complete')

historyPath = os.path.expanduser("~/.pyhistory")

def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)

if os.path.exists(historyPath):
readline.read_history_file(historyPath)

atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath


首先,要有PYTHONSTARTUP环境变量,它会帮助python找到启动时要自动运行的脚本。如果你和我一样使用bash,可以把它直接放到bash的启动脚本.bashrc中:
export PYTHONSTARTUP=~/.pythonstartup.py


其次,要把readline的相关功能放到python启动脚本中,上面的脚本中readline.parse_and_bind('tab: complete')这一句就就是做的这个工作。另外,脚本还加载了其它一些有用的功能,大家可以自己查资料。这个启动脚本也可以从这里下载,请大家按照自己的需要进行修改。

有了这些设置,我们就可以按Tab键来让readline帮我们自动完成了。如果连按两次Tab键,则会把所有匹配的自动列出来:
0$ python
Python 2.3.5 (#2, Mar 26 2005, 17:32:32)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Welcome to Lazy Python. Type "help LazyPython" for help.
>>> import types
>>> types.
types.BooleanType types.ObjectType
types.BufferType types.SliceType
types.BuiltinFunctionType types.StringType
types.BuiltinMethodType types.StringTypes
types.ClassType types.TracebackType
types.CodeType types.TupleType
types.ComplexType types.TypeType
types.DictProxyType types.UnboundMethodType
types.DictType types.UnicodeType
types.DictionaryType types.XRangeType
types.EllipsisType types.__class__
types.FileType types.__delattr__
types.FloatType types.__dict__
types.FrameType types.__doc__
types.FunctionType types.__file__
types.GeneratorType types.__getattribute__
types.InstanceType types.__hash__
types.IntType types.__init__
types.LambdaType types.__name__
types.ListType types.__new__
types.LongType types.__reduce__
types.MethodType types.__reduce_ex__
types.ModuleType types.__repr__
types.NoneType types.__setattr__
types.NotImplementedType types.__str__
>>> types.F
types.FileType types.FrameType
types.FloatType types.FunctionType
>>> types.F