一周开源项目集锦(2011/11/01)

QualityBots
A tool for automated comparison of website layouts across multiple Chrome versions.
http://code.google.com/p/qualitybots/

Test Analytics
Test Analytics is a web application that allows rapid generation of a project’s ACC model — an alterative to a test plan that is faster to create and of more practical value.
http://code.google.com/p/test-analytics/

Script Cover
Javascript code coverage detector for web pages in Chrome
http://code.google.com/p/script-cover/

Google Tasks Porter
http://code.google.com/p/google-tasks-porter/
Demo https://google-tasks-porter.appspot.com/

Google APIs Client Library for Objective-C
http://code.google.com/p/google-api-objectivec-client/

Bootstrap
Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.
It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
http://twitter.github.com/bootstrap/

heatmap.js
JavaScript Library for HTML5 canvas based heatmaps
http://www.patrick-wied.at/static/heatmapjs/

Google JS Test
Google JS Test is a fast javascript unit testing framework that runs on the V8 engine, without needing to launch a full browser.
http://code.google.com/p/google-js-test/

Media Temple ProDev API

Media Temple也耐不住寂寞出API了,这年头不提供API的服务不是好服务。既然有API那就试试吧。登录帐号,获取api key以后便可以开始编程了。
需要注意的是尽管文档里有提全局的HTTP 请求headers里包含Authorization为api key用以访问api。但我发现使用header的形式并不能访问成功,实际的api key还是需要在URL里以参数的形式携带(API Query parameters)。
以下示例用以访问Get all service details接口。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# encoding: utf-8
"""
mtapi.py
 
Created by 枯藤昏鸦 on 2011-05-14.
Copyright (c) 2011 IoIo.NaMe. All rights reserved.
"""
import urllib,httplib
 
def main():
url = 'api.mediatemple.net'
apikey = 'your api key'
urls = '/api/v1/services.json?apikey='+apikey
form_fields = {}
params = urllib.urlencode(form_fields)
headers = {}
conn = httplib.HTTPSConnection(url)
conn.request(method='GET', url=urls, body=params, headers=headers)
response = conn.getresponse()
res = response.read()
h = response.getheaders()
print 'Response Status:',response.status
print 'Response Header:'
for i in h:
print i[0],':',i[1]
print 'Response Content:',res
conn.close()
 
if __name__ == '__main__':
main()

记得是使用https链接(httplib.HTTPSConnection)。
相关资料:API文档(PDF)
-EOF-

腾讯/新浪/搜狐IP地址API

腾讯的IP地址API接口地址:http://fw.qq.com/ipaddress
返回的是数据格式为:

1
var IPData = new Array(“58.218.198.205″,",”江苏省”,”徐州市”);

使用JS代码进行调取:

1
2
<script language="javascript" type="text/javascript" src="http://fw.qq.com/ipaddress" charset="GB2312"></script>
<script>document.write("你的IP是:"+IPData[0]+",来自:"+IPData[2]);</script>

新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
新浪多地域测试方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=12.130.132.30
搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson
搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8
搜狐另外的IP地址查询接口:http://txt.go.sohu.com/ip/soip
-EOF-

Win32API之GetProcessTimes范例


API都会调用,放这个例子上来是想说一下程序运行时间,内核时间以及用户时间是怎么一回事。
部分关键的代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser);
 
timeCreation = ftCreation;
 
strData.Format("Created at %02d:%02d:%02d", timeCreation.GetHour(), 
timeCreation.GetMinute(), timeCreation.GetSecond());
 
timeDiff = timeNow - timeCreation;
strData.Format("Elapsed time = %ud %uh %um %us", timeDiff.GetDays(), 
timeDiff.GetHours(), timeDiff.GetMinutes(), 
timeDiff.GetSeconds());
 
FileTimeToSystemTime(&ftKernel, &stKernel);
strData.Format("Time in kernel mode = %uh %um %us", stKernel.wHour,
stKernel.wMinute, stKernel.wSecond);

下载 [download id=”17″]
via codeproject.com
-EOF-