Ubuntu仓库里有个weather-util包,可以用来查看天气信息。weather工具从weather.noaa.gov网站获得天气信息,对美国的城市可以直接用名字查询,其他国家只能使用id查询。id的规则和weather.com不太相同。
中国的天气站点id可以在这个页面上查到。比如南京ZSNJ,上海浦东ZSPD。使用weather工具查询:
weather -i ZSNJ
Current conditions at China (ZSNJ) 32-00N 118-48E 12M (ZSNJ)
Last updated Feb 18, 2010 – 08:00 AM EST / 2010.02.18 1300 UTC
Temperature: 35 F (2 C)
Relative Humidity: 59%
Wind: from the SSW (210 degrees) at 4 MPH (4 KT)
简化操作,可以在$HOME下创建.weatherrc文件,形如
1 2 3 4 | [default] ID = ZSPD [nj] ID = ZSNJ |
就可以直接使用
weather
Current conditions at China (ZSPD) 31-07N 121-46E (ZSPD)
Last updated Feb 18, 2010 – 08:00 AM EST / 2010.02.18 1300 UTC
Temperature: 35 F (2 C)
Relative Humidity: 47%
Wind: from the NE (050 degrees) at 7 MPH (6 KT) (direction variable)
和
weather nj
Current conditions at China (ZSNJ) 32-00N 118-48E 12M (ZSNJ)
Last updated Feb 18, 2010 – 08:00 AM EST / 2010.02.18 1300 UTC
Temperature: 35 F (2 C)
Relative Humidity: 59%
Wind: from the SSW (210 degrees) at 4 MPH (4 KT)
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
大年初一翻旧物,找到一些让人颇有感触的旧物件。2004年买的RH9,2005年夏天买的Fedora 4。前者至今还安装在我家最旧的电脑里,虽然我都忘了它的样子了。
这个代理商里仁软件似乎已经倒闭了。
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
Very glad to announce another daily-coding work: an extension for gnome deskbar applet to search and launch virtual machine. There is a plugin for gnome-do that does the same job. That’s what I create the the plugin for. I switched to deskbar because gnome-do’s Do.exe reminds me nightmares when I was a M$ Windows user. The deskbar applet has been a great replacement, however, the virtualbox plugin in Do is really impressive while deskbar doesn’t provide me the same functionality.
You can ignore words above and just take a look at the screenshot:

Download
Download the extension from (the highlighted one):
http://bitbucket.org/sunng/daily-coding/downloads/?highlight=5137
You can also trace the development at bitbucket project. However, the repository is mixed with other small code snippets. Currently, mercurial doesn’t support subdirectory pull. So there is no way to grab the deskbar-applet individually.
Installation
copy this file to /usr/lib/deskbar-applet/deskbar-applet/modules-2.20-compatible/ (Ubuntu installation for example) with super user privilege. Right click desktbar applet, select Preference, Searchers tab, hit “Reload” button, then check the Virtualbox Deskbar Module.

Issue
Feel free the report issues on bitbucket:
http://bitbucket.org/sunng/daily-coding/issues/
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
I’m sorry for the long title. Due to lack of documentation, it’s not easy to use python xpcom api from virtualbox sdk. The code below is just a sample that lists your installed virtual machines. It works on linux with VirtualBox OSE 2.0.8. Hope useful to you.
1 2 3 4 5 6 7 | import vboxapi vmsg = vboxapi.VirtualBoxManager(None, None) vbox = vmsg.vbox vmsg.mgr.getSessionObject(vbox) machs = vbox.getMachines() names = map(lambda x: (x.name,x.id), machs) print names |
Output:
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
Glad to announce my works this morning: A simple heatmap API based on HTML5 canvas.

The programming interface is rather simple now. To create such a heatmap, you just new a heatmap object by:
<canvas width="300" height="215" id="canv"></canvas>
heatmap = new HeatMap("canv");
Then read your dataset and push data into the heatmap:
heatmap.push(x, y, value);
At last, spread the data and get the canvas rendered:
heatmap.spread(); heatmap.render();
Now you got it.
For advanced usage, you can specify the resolution of heatmap by px:
heatmap = new HeatMap("canv", 2);
Large value will gain performance with low image quality.
Also, you can specify a value to define the attenuation value of each px.
heatmap.spread(5);
Finally, there is an option to use your own color schema for heatmap generation.
heatmap.render(function(value, maxValue){
var light = value / maxValue * 100;
return "hsl(20, 75%, "+light+"%)";
});
The parameters passed in are current pixel value and max value in whole context.
That’s all the toolkit. More functionality and options might be added in future. Grab it from my bitbucket page:
http://bitbucket.org/sunng/daily-coding/src/tip/canvas-heatmap/
There is a demo page which you can test the api by clicking canvas:

then click heatmap button!

This is the new year gift for my readers and my dear friends !
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.




















on