摘要: 参看原帖,简单翻译此帖的内容method 1:从PEP318看到singleton的实现def singleton(cls): instances = {} def get_instance(): if cls not in instances: instances[cls] = cls() return instances[cls] return get_instance@singletonclass MyClass: pass如果直接通过类似m=MyClass()这样生成对象,那么就是singleton对象,但如果通过n.__class__()这样生成的,就不... 阅读全文
posted @ 2011-10-15 16:31 kebo 阅读(1133) 评论(0) 推荐(0) 编辑
摘要: 卸载rar,unrar包安装p7zip-full,p7zip-rar包apt-get remove rar unrarapt-get install p7zip-full p7zip-rar 阅读全文
posted @ 2011-10-15 16:01 kebo 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 解析blackberry的设备应用文件alx,格式是xml的,但文件没有标明编码,也没有<?xml version="1.0" ?>类似的标注。文件的编码,尤其是要读取未知编码的文件,是比较痛苦的事。在linux下,可以通过file命令来获取文件的编码file -i BlackBerry.alx会得到类似下边的结果,可以看出其编码iso-8859-1BlackBerry.alx: text/plain; charset=iso-8859-1详细了解file命令查看这里可以看到alx文件的编码是iso-8859-1它的一个别名是Latin-1# 读取文件内容,并转 阅读全文
posted @ 2011-10-09 23:42 kebo 阅读(508) 评论(0) 推荐(0) 编辑
摘要: 为使用google maps for android的api而申请其apikey时,需要填入一个认证指纹,这个认证指纹从哪里获取呢?从android的数字签名证书中获取。1.找到数字签名证书的位置,如“/path/to/digital/signature/certificate"2.使用keytool获取其认证指纹keytool -list -keystore /path/to/digital/signature/certificate -keypass 证书密码3.将获得的认证指纹填入即可 阅读全文
posted @ 2011-09-23 17:31 kebo 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 列出几个android常用的分辨率,更多详细的可以看这儿VGA(640*480):Video Graphics Array之后的分辨率都是以VGA为基准的QVGA(320*240):Quarter VGA, 四分之一的VGAHVGA(480*320):Half-size VGA,一半的VGAWVGA(800*480):Wide VGASVGA(800*600):Super VGA 阅读全文
posted @ 2011-09-22 11:21 kebo 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 在ubuntu11.04上安装gnome3.0.2,会发现中文输入法会和gnome terminal,gedit等软件冲突,原因见这儿。暂时的解决方法是使用ibus,并将环境变量GTK_IM_MODULE设置为ibus在~/.profile文件尾添加export GTK_IM_MODULE="ibus" 阅读全文
posted @ 2011-08-07 13:12 kebo 阅读(477) 评论(0) 推荐(0) 编辑
摘要: 在GAE下,用webapp框架,希望通过weibopy这个weibo的python SDK进行oauth认证。贴上代码#coding=utf-8import osfrom google.appengine.ext import webappfrom google.appengine.ext.webapp.util import run_wsgi_appfrom google.appengine.ext.webapp import templatefrom weibopy.auth import OAuthHandlerfrom weibopy.api import APIfrom gaeses 阅读全文
posted @ 2011-07-27 10:42 kebo 阅读(508) 评论(0) 推荐(0) 编辑
摘要: 一、配置python1.当前的GAE还只支持python2.5,一个变通的方法是修改google_appengine下的dev_appengine.py文件,将开头的#!/usr/bin/env python 改为#!/usr/bin/env python2.62.如果要安装python2.5,则需注意直接在11.04下编译python2.5会出错,详细可参考Building Python2.5 for Ubuntu 11.04 ,说明一下,1)安装需要的包apt-get install libssl-dev libsqlite3-dev2)修改python2.5源码包中Modules/Set 阅读全文
posted @ 2011-07-27 10:22 kebo 阅读(633) 评论(0) 推荐(0) 编辑