A python quiz

2 Oct

Python 2.5 is relatively recent and not supported everywhere yet, so it’s important to understand the behavior of both Python 2.5 and earlier versions.

This quiz is cited from here.

  1. (a) What number does the following code print?
    adders = []
    for i in range(0, 100):
        adders.append(lambda x: x+i)
    
    print adders[17](42)

    (b) What about the following similar-looking code?

    adders = [lambda x: x+i for i in range(0, 100)]
    print adders[17](42)
  2. (pre-Python 2.5 only) What does the following code print? Partial credit for approximately correct answers. (Hint: the function that exits a program is called sys.exit.)
    try:
        exit(0)
    except Exception, e:
        print e
  3. What number does the following code print?
    units = [1, 2]
    tens = [10, 20]
    nums = (a + b for a in units for b in tens)
    units = [3, 4]
    tens = [30, 40]
    print nums.next()
  4. Which of these lines produce the same output?
    print "word" in [] == False
    print ("word" in []) == False
    print "word" in ([] == False)

    Continue reading 

C++ essentials for OpenGL

15 May

The tutorial includes the topics below:

  • Pointers
  • Arrays and strings
  • Parameter passing
  • Class basics
  • Constructors & destructors
  • Class Hierarchy
  • Virtual Functions
  • Coding tips
  • Advanced topics

c++ tutorial for opengl

A few highlights from Google I/O 2011 (Photos)

11 May

OpenGL glut bundle for download

9 May

I’ve been looking for some missing header file from glut for ages, and finally have all of them, just in case I’d like make a copy on my webiste, you also can download, that’s all you need to do opengl programming.

The package is tested with Visual Studio 2010, any other version should be working!

opengl_glut

程序员看母亲节

8 May

母亲节(Mother’s Day),作为一个感谢母亲的节日,最早出现在古希腊,时间是每年的1月8日,而在中国、美国、加拿大和一些其他国家,则是每年5月的第2个星期天,其他一些国家的日期也并不相同。

母亲们在这一天通常会收到礼物。康乃馨被视为献给母亲的花,中国的母亲花是萱草花,也称忘忧草。作为一个特殊的群体——程序员,我们的表述方式自然也 会有些特色。我们这一辈程序员的父母(至少是绝大部分父母),别说这下面的编程语言,有些甚至都还不知道如何操作电脑。虽然也许母亲们会看不懂,但这种表 述你我都能领会。或许几十年后,等我们自己的儿女用这种方式来表达他们对父母的爱,你我绝对不会陌生。

Continue reading 

几个极棒的CSS3动画Example

5 May

thumb

Css3 动画演示

你是否曾经对使用CSS3创建视频感到不可思议?但通常来说,通过使用CSS3的动画特性,这并不是难事。 虽然CSS3当前还没有完全成熟,但对于一般的用户,这里面很多都可能显得很惊奇。而且,它已经被大部分现代浏览器支持。Naomi, Andy等一些外国艺术家和设计者为国际委员会准备了一个网站,它强有力的展示了CSS动画特性。

示例网站入口

img1

目前,这个项目还在开发中。但是从视频中我么可以看到,界面十分复杂,并且可以重新对界面进行组装和布局。但是动画看上去还是非常有意思(至少从他们提供的视频演示中)。

另外一个网站Madmanimation demo只能在基于Webkit类的浏览器或者平台中运行。 包括(Chrome, Safari, Android, BlackBerry, iOS 和WebOS) 其他浏览器无法显示。

img2

Continue reading 

Tags: ,

Baidu released the OS market statistics in mainland China

4 May

Baidu statistics yesterday have released a report that describes the the operation system market share within mainland China. The data shows that Microsoft Windows, Apple Mac OS, and Linux are mostly used by Chinese netizens. The detailed data are indicated below.

VendorOperating SystemRate
MicrosoftWindows XP86.38%
Windows 710.78%
Windows Vista1.62%
Windows 20030.43%
Windows 20000.09%
Other0.01%
AppleMac OS0.52%
LinuxLinux0.17%

The Windows OS from Microsoft however still keeping strong and have been adopted by most of Chinese net users, the net share has reached 99.31% while Windows XP has a 86.38% installation rate among the overall market, which won the champion of this race. The well spoken of Windows 7 have a 10.78% of the market share, but seems not likely to be able to replace Windows XP in a short term. The Mac OS is being adopted by more Chinese users, the market share is increasing slightly(0.52%).

There Chinese OS market has major differences compare with the OS market in well developed countries, which needs IT developers’ attention.

招聘官和应聘者的经典对白

30 Apr

面试官:知道什么叫类么
应聘者:我这人实在,工作努力,不知道什么叫累
面试官:知道什么是包?
应聘者:我这人实在 平常不带包 也不用公司准备了
面试官:知道什么是接口吗?
应聘者:我这个人工作认真。从来不找借口偷懒
面试官:知道什么是继承么
应聘者:我是孤儿没什么可以继承的
面试官:知道什么叫对象么?
应聘者:知道,不过我工作努力,上进心强,暂时还没有打算找对象。
面试官:知道多态么?
应聘者:知道,我很保守的。我认为让心爱的女人为了自已一时的快乐去堕胎是不道德的行为!请问这和c#有 什么关系??

 

Looking for help with replacing laptop keyboard

28 Apr

UPDATE: Problem has been solved!

 

Hi, I’m using a ASUS laptop, and the “enter” key fell off, I have purchased a new original keyboard, but don’t know how to change it Anybody in Sydney who can help please contact, it’s a paid job.

我是否应该升级到Django1.3呢?

28 Apr

我是否应该升级到Django1.3呢? 这里我们主要分析 升级与不升级的几个利弊,其他请根据环境不同,自由定夺。

优点:

  • 新特性 – 虽然网站能用,但是开发者可能对新特性有兴趣去尝试。 但它必须对应用的开发有真正的好处才行。
  • 速度提升 – 平台供应商和主机商们通常会因为性能提升而进行升级。 这是一个很常见的升级理由。
  • 避免老化 – 在这点上尤其适用于Web开发,因为它变化得非常快。 Django可能随时停止对老版本的支持。

安全性 – 这一点对Web开发也十分重要。 每天都有人在研究更新的攻击方法。一个Web框架的安全性提升对于一个网站的安全来说十分要紧。

缺点:

  • 花费 – 要花钱和时间,对外国企业更是(按小时付工资)
  • 不兼容 – 你的项目可能已经用到很多第三方的组件, 如果它们没有及时针对新版本进行升级,它可能无法正常工作,这种情况时有发生。因为那些第三方组件的开发者很可能已经不再对它进行支持了。这也是升级最大的一个顾虑。

django1.3 的一些新特性

Logging, ChearableFileInput, improved list_filter, class based views, unittest2.