Go4Pro.org Go for Programming, Go for Professionals, Be a Professional!

26Jun/101

Go4Pro.org迁移成功

Go4Pro.org站点已经正式迁移,原来的文章可以通过http://legacy.go4pro.org继续访问。

新的Go4pro.org站点将运行于Linode VPS主机上,基于Python和TG2构造,由TR@SOE、ch.linghu、raptor共同创建。

Filed under: (Default) 1 Comment
4Apr/100

An Android application with map

I had read a few tutorials on how to develop an Android appication with map display. Today I had actually built one. I would like to summarize the key points/steps in making this application work.

1. First of all, get an Android Map API Key from Google.

This actually involves two steps.

Firstly, you will have to create a key store to sign your Android application. This is quite easy and straightforward.

Secondly, apply an Android Map Key from Google: http://code.google.com/intl/zh-CN/android/maps-api-signup.html. To make this work, you have to know where is your key store file is located (as created in the above step) and also have the JDK tool named keytool. From the command line, type:

   keytool -list -keystore the-path-to-your-key-store-file

It will prompt you to enter the password to the key store and will generate a MD5 finger print for this particular key store file. Copy this MD5 finger print to the above URI and Google will give you the Android Map API Key immediately. It is strongly suggested to save this Key information.

2. Create an Android application.

Note: It must be created with target set to: "Google APIs". You should not set the application target to "Android x.x" or it will not be running properly.

Note: The target of the AVD that runs the map application must also be set to "Google APIs".

The coding of the application is actually quite simple. There are only two points to be highlighted:

1. The application must be granted ACCESS_FINE_LOCATION and ACCESS_INTERNET permissions;

2. The mapview controll used in the view must provided with the API key generated in Step 1. It will look something like this:


With these settings, the map application can eventually run successfully. However, in my implementation, the map shown in my AVD is only grids, no actuall maps at all. But in real machine (mine is Nexus One), the application is running correctly.

Tagged as: , , , , No Comments
26Mar/100

CodeIgniter和Flex的结合

BT话痨群的后台中有一个彩蛋,只有资深BT才知道。

这个彩蛋是肾上开发的,目的是测试CI和Flex(Flash)的结合。

12Oct/090

TurboGears 2.0 使用 routes

狗屎皮的设计上碰到了一个URL的问题。根据需求,/article/[id]显示指定ID的文章,而/article/recent显示最新文章列表。从URL设计来说,我个人感觉问题也不大,逻辑还是挺清楚的。但是因为TG2用的是原来CherryPy风格的url mapping,也就是用@expose的方法名直接对应url,要实现这种功能就不太方便了。当然你也可以这样写:

def article(self, id):
    if id=='recent':
         return self.article_recent()
   else:
        return self.article_id(id)
27Sep/090

用unittest测试web2py应用中的非页面部分

虽然web2py提供了用doctest进行测试的方式,但是这个只能在controller层直接对页面交互进行测试。虽然这样的测试覆盖很全面,但是测试粒度太大,对我来说测得不够细。

1Sep/092

xpath在HTML解析中的应用(更新加强版)

前一阵参加了一个Python的活动,其间老董的讲座是讨论网页爬虫技术的。其中提到了一下关于页面解析的问题,他推荐了三种技术。其中有用到libxml2里的xpath来处理,我就跟令狐谈到我曾经也用过这个东东。令狐建议我把这个东东说一下,于是我就写了这一篇。

4Aug/090

Cygwin 1.7版 中文问题的解决(99%)

Linux玩久了之后,在Windows下用不了很多优秀的命令行工具,就会感觉特别不爽。因此我一般都会在电脑上安装一套GNU utils for windows。最开始的时候,我用的是minGW里的utils,但是它附带的工具不全,虽然有一部分其他工具可以在其他地方google到,毕竟比较费神费力。

后来好好玩了一下Cygwin,开始喜欢上这个玩意儿了。以前一直以为cygwin就是开始菜单里启动的那个bash界面,后来发现其实不是,cygwin实际上是通过一个cygwin1.dll实现了几乎全部的UNIX函数,因此只要链接到这个dll,就可以很方便的port各种UNIX工具了。port出来的工具,也可以在DOS命令行下正常执行。

因为Cygwin的安装是集中式的,有点类似于apt机制,这很方便,不需要到处找各种各样的port了,只要从registry里安装就行。

12Jul/091

试了一把PCRE

虽然我在C++里用正则表达式已经有一些年头了,不过一直都是用的boost里那个库。坦白说,不是很好用。虽然我很早就知道PCRE,但一直都以为这是一个为PHP开发的库。实在是火星人啊。囧

前两天在推土上提起这事时,火炬向我推荐说PCRE比boost里那个正则库好用,于是试了一下,结果可耻滴发现BCB自带了PCRE,只不过没有在文档里提到罢了。

12Jul/090

用RTTI处理程序配置信息

一般来说,程序多少都会有一些自己的配置信息要保存,不论是通常用的保存到INI还是注册表,或者是XML甚至YAML,总归是要写不少代码处理的。

问题的麻烦在于,程序中实现操作配置信息通常并不需要关注它是保存在什么地方,以什么格式保存,但是传统的方法不论是调用TIniFile还是TRegistry或者是DOM,都是需要开发者花一些时间精力浪费在这上面。

10May/090

【jQuery】示例5:一个简单的投票系统

今天抽空完成了jQuery的示例5:一个简单的投票系统

本例没有什么特殊的地方。只有一点。投票系统至少需要两个参数:一个是投票项目的id,一个是投票的方向(支持还是反对),所以我这样构造一个a元素:

'>

我用class来确定投票方向,而用id来确定投票项目。

最后,我用jQuery中的replaceWith来替代掉被点击的a元素的内容为:

$(this).replaceWith(""+count+"");

大功告成!