8 Jul 2008

Smart Kun Fu Panda

往往在逃避命运的路上,却与之不期而遇

One meets its destiny on the road he takes to avoid it

你的思想就如同水,我的朋友,当水波摇曳时,很难看清,不过当它平静下来,答案就清澈见底了。

Your mind is like this water, my friend , when it is agitated ,it becomes difficult to see ,but if you allow it to settle , the answer becomes clear.

昨天是历史,明天是谜团,只有今天是天赐的礼物。

Yesterday is history, Tomorrow is a mystery. But today is a gift, That is why it’s called the present (the gift)

从来没有什么意外

There are no accidents.

师傅:但有些事情我们可以控制,我可以控制果实何时坠落,我还可以控制在何处播种。

But there are things we can control

I can control when the fruit will fall

... And I can control

What time to seed

乌龟:是啊 不过无论你做了什么,那个种子还是会长成桃树,你可能想要苹果或桔子,可你只能得到桃子,那个种子还是会长成桃树。

Yes, but no matter what you do,

That seed will grow to be a peach tree

You may wish for an Apple or an orange

But you will get a peach

师傅:可桃子不能打败豺狼

But peache can not defeate Tai Long

乌龟:也许它可以的 ,如果你愿意引导它、滋养它、相信它。

Maybe it can if you are willing to guide it , to nuture it , to believe in it.

我私家汤的绝密食材,就是……什么都没有。

The secret ingredient of my secret ingredient soup is...nothing.

认为它特别,它就特别了。

To make something special ,you just have to believe it’s special.

benchmark Python algorithms

there are several useful methods in the python library module 'time'
we can use them to benchmark our code segements or the algorithms.
the typical uses like:

>>> import time
>>> t=time.clock()
>>> t
4.4698418374402335e-006

>>> t=time.clock()
>>> time.clock()-t
6.635907915670856

>>> t=time.time()
>>> time.time()-t
5.0940001010894775
>>>

As we know from the code segemets posted above, we can use both clock() and time() methods to measure the time slice. However, there are still some differences between them, following is copied from the official documents:
clock( )
On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of ``processor time'', depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms.

On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond.


and for the time():
time( )
Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls.

If we just read the definitions of these two method, we would think that the clock()'s precision is better than time()'s. But if you run the code offered above, you will found that time() has more usefull number than clock(). I don't know why at these moment.

For more details, please read:
http://docs.python.org/lib/module-time.html

7 Jul 2008

google金山合作推出翻译软件

昨天才看到这个发布了几个月重量级的新闻
这对中意免费软件的我来说,是莫大的一个利好消息
金山在翻译领域的资历加上google强大无比的搜索能力
必将开拓在线本地结合搜索领域的一个新局面
下载试用后,感觉也不错,
这个版本的屏幕取词功能尤其强
我原来的2007龙卷风版并不支持firefox
但是这个版竟然完美表现
直接让我的ff扩展qtl下课走人.

下面是链接,去试试吧.
http://www.google.cn/rebang/product/dictionary/dictionary.html

5 Jul 2008

random module in Python

>>> import random

>>> # 0.0 <= float < 1
>>> random.random()
0.41360177662769904

>>> # 10.0 <= float < 20
>>> random.uniform(10,20)
15.743669918803288

>>> # 10 <= int <= 20 (can be 20)
>>> random.randint(10,20)
10

>>> # 10 <= int < 20 (only even number, step=2)
>>> random.randrange(10,20,2)
16

>>> # choose from a list
>>> random.choice([1, 2, 3, 5, 9])
2

>>> # make a list into random order
>>> cards = range(52)
>>> random.shuffle(cards) # order is random now
>>> cards[:5] # get 5 cards
[37, 14, 42, 44, 6]

2 Jul 2008

通过邮件地址找到space地址

Belem便利用其做了一个通过Email地址找出Space地址的小工具:MailtoSpace 。

mailtospace

输入你想查询的MSN帐号地址,点击“获取共享空间链接”稍等片刻系统便会算出该帐号对应的Space地址。

需要注意,如果这个帐号没有创建空间,及创建的Live Space中没有档案文件(个人信息)模块,那么就无法算出其对应的空间地址了。


最后补一句,你可以直接通过这样URL访问其Live Spaces:http://spaces.live.com/profile.aspx?mem=gerry@live.com,管他是否在其Live Space里添加没添加档案文件模块。。。(别丢鸡蛋、青菜的,直接扔个鸡蛋煎饼过来,省事…)

1 Jul 2008

PyScripter: win下完美的python IDE

今天无聊到处找python的IDE, 由于习惯了endnote, 只好放弃论文阶段ubuntu活命的策略,
继续转战回win, 安装好python2.5之后就开始寻找合适的IDE,虽然自带的IDLE还好,
但是keyword complete确实差强人意,而且PSpad只是highlights keyword,并不能自动完成.
找来找去,找到了PyScripter,哈哈,合适我用.
唯一可惜的界面字体太小了.但是其它功能无人可敌,
尤其值得一提的是document view source code的功能,可以自动生成HTML文档,嘿嘿
只要coding的时候有格式,生成的文档还真是优美哎
赞一个!