<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss">

<channel>
	<title>Here comes the Sun &#187; foss</title>
	<atom:link href="http://sunng.info/blog/tag/foss/feed/" rel="self" type="application/rss+xml" />
	<link>http://sunng.info/blog</link>
	<description>Life ramblings</description>
	<lastBuildDate>Thu, 02 Sep 2010 12:29:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>beanstalkd</title>
		<link>http://sunng.info/blog/2010/08/beanstalkd/</link>
		<comments>http://sunng.info/blog/2010/08/beanstalkd/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 14:40:54 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2010/08/beanstalkd/</guid>
		<description><![CDATA[beanstalkd是一个极轻量级的消息队列服务，作者的说法叫做Work Queue。 概念 Beanstalkd里包含以下几个概念： Producer Worker Job Tube Producer 与传统的消息队列服务中的概念类似，是Job的生产者。这个角色通过put命令来创建Job。 Worker 即消费者，worker通过reserve / release / bury / delete 等命令操作job的生命周期。 Job 是beanstalkd中的基本单元，一个job包含id和body，从属于一个tube。Job的生命周期是beanstalkd中的核心概念，它包含DELAYED / READY / RESERVED / BURIED / DELETED等状态。beanstalkd文档中的这个图对Job的声明周期进行了说明： http://github.com/kr/beanstalkd/blob/master/doc/protocol.txt#L81 Tube 是类似namespace的概念，Producer在生产Job前通过use指定相应的Tube。而Worker通过watch / Ignore命令来决定从哪些Tube中获得Job。 安装 Beanstalkd 可以通过很多Linux发行版的包管理器直接安装。依赖libevent 1.4.1 以上版本。 通过以下命令启动即可 beanstalkd -d -p &#60;PORT&#62; 协议 Beanstalkd在各方面都继承memcached的风格，协议也与memcached类似，同样是基于文本的： 命令 参数 [参数...] [命令体字节数]\r\n [命令体]\r\n beanstalkd很多命令的返回是yaml格式，但是系统对命令体的格式并没有限制。 客户端 Beanstalkd协议见简单，有各种语言的客户端实现。python有一个非常简单的beanstalkc，可以通过easy_install安装。不过，这个客户端缺少断线重连机制，正式发布的0.2.0版本也有一些严重的bug。可以从github上下载源代码安装，并在使用时控制重连。 The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://kr.github.com/beanstalkd/">beanstalkd</a>是一个极轻量级的消息队列服务，作者的说法叫做Work Queue。</p>
<h3>概念</h3>
<p>Beanstalkd里包含以下几个概念：</p>
<ul>
<li>Producer</li>
<li>Worker</li>
<li>Job</li>
<li>Tube</li>
</ul>
<p>Producer 与传统的消息队列服务中的概念类似，是Job的生产者。这个角色通过put命令来创建Job。</p>
<p>Worker 即消费者，worker通过reserve / release / bury / delete 等命令操作job的生命周期。</p>
<p>Job 是beanstalkd中的基本单元，一个job包含id和body，从属于一个tube。Job的生命周期是beanstalkd中的核心概念，它包含DELAYED / READY / RESERVED / BURIED / DELETED等状态。beanstalkd文档中的这个图对Job的声明周期进行了说明：<br />
<a href="http://github.com/kr/beanstalkd/blob/master/doc/protocol.txt#L81">http://github.com/kr/beanstalkd/blob/master/doc/protocol.txt#L81</a></p>
<p>Tube 是类似namespace的概念，Producer在生产Job前通过use指定相应的Tube。而Worker通过watch / Ignore命令来决定从哪些Tube中获得Job。</p>
<h3>安装</h3>
<p>Beanstalkd 可以通过很多Linux发行版的包管理器直接安装。依赖libevent 1.4.1 以上版本。<br />
通过以下命令启动即可</p>
<p><i>beanstalkd -d -p &lt;PORT&gt;</i></p>
<h3>协议</h3>
<p>Beanstalkd在各方面都继承memcached的风格，协议也与memcached类似，同样是基于文本的：</p>
<p>命令 参数 [参数...] [命令体字节数]\r\n<br />
[命令体]\r\n</p>
<p>beanstalkd很多命令的返回是yaml格式，但是系统对命令体的格式并没有限制。</p>
<h3>客户端</h3>
<p>Beanstalkd协议见简单，有各种语言的客户端实现。python有一个非常简单的beanstalkc，可以通过easy_install安装。不过，这个客户端缺少断线重连机制，正式发布的0.2.0版本也有一些严重的bug。可以从github上下载源代码安装，并在使用时控制重连。	</p>
<p>The post is brought to you by <a href="http://fedorahosted.org/lekhonee">lekhonee</a> v0.7</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/08/beanstalkd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用markdown书写文档</title>
		<link>http://sunng.info/blog/2010/07/%e7%94%a8markdown%e4%b9%a6%e5%86%99%e6%96%87%e6%a1%a3/</link>
		<comments>http://sunng.info/blog/2010/07/%e7%94%a8markdown%e4%b9%a6%e5%86%99%e6%96%87%e6%a1%a3/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 11:36:54 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2010/07/%e7%94%a8markdown%e4%b9%a6%e5%86%99%e6%96%87%e6%a1%a3/</guid>
		<description><![CDATA[写文档是头疼事，没人愿意写文档。在word里写文档，时间长了都怀疑自己是不是搞技术的。我阅历有限，在我的印象里就没有用word格式看过什么有价值的东西。只要一打开word想到的就是连篇累牍的废话、码字。word最重要的功能是什么？保存。其次呢？字数统计。我所写过的word文档绝大多数都是“只写”的，通常作为流程里的一个附件，没有人真正去看。 以上是人身攻击，接下来比较实际的问题，word文档不是符合unix哲学的东西。格式不开放，你就没有办法进行diff操作，把word文档放到svn里，只能使用最基本的版本控制，没法查看changeset，只知道改了，不知道改了什么。 为了改变这种情况，我试过用docbook格式。docbook用xml书写，定义了一套复杂的Schema，详细到作者的email都有定义。docbook还有丰富的工具集，可以通过xsl把docbook转换成所有你知道的文档格式。Maven: the Definitive Guide就是用docbook写成的。不过用docbook也存在一些问题，docbook太复杂了，用纯文本编辑器很难处理，作者的学习曲线也比较高，需要所见即所得的编辑器支持。与docbook相类似的DITA，也存在这样的问题，它们是重量级的格式。 轻量级的Wiki格式不错，但是Wiki格式很让人头疼就是没有统一的规范。举例，dokuwiki里顶级标题是6个=，而moinmoin里顶级标题恰恰相反是一个=，不portable，文档维护起来就非常麻烦。 铺垫了这么多，委屈以上格式了，该markdown出场了。markdown是简单的html原型，用来生成html，它的设计目标就是为了KISS，兼容html。看看一些必要的格式吧：（或者直接看Wikipedia） 标题 # 标题 ## 二级标题 &#8230; ###### 六级标题 对于一级标题还可以这么写 headline ======== 二级标题可以 headline &#8212;&#8212;&#8211; 这个怎么输入呢，我想起来前几天看vim hacks里的一组快捷键 yypoVr= yypoVr- 谁用谁知道 段落： 一段文本以两个换行结束。 换行： 一行文本行末两个空格。 图片 ![alternative text](image-url &#8220;image-title&#8221;) 用markdown，图片的alt你不写都不行。 链接 [Linktext](link &#8220;linktitle&#8221;) 列表 ul 无序列表 * * ol 有序列表 1. 2. 以上就是主要的格式支持。用标题来划分文档层次，没有多余的格式，没有机会让你五颜六色。 在linux上可以安装markdown的处理脚本： apt-get install markdown 安装vim的语法文件： http://www.vim.org/scripts/script.php?script_id=1242 [...]]]></description>
			<content:encoded><![CDATA[<p>写文档是头疼事，没人愿意写文档。在word里写文档，时间长了都怀疑自己是不是搞技术的。我阅历有限，在我的印象里就没有用word格式看过什么有价值的东西。只要一打开word想到的就是连篇累牍的废话、码字。word最重要的功能是什么？保存。其次呢？字数统计。我所写过的word文档绝大多数都是“只写”的，通常作为流程里的一个附件，没有人真正去看。</p>
<p>以上是人身攻击，接下来比较实际的问题，word文档不是符合unix哲学的东西。格式不开放，你就没有办法进行diff操作，把word文档放到svn里，只能使用最基本的版本控制，没法查看changeset，只知道改了，不知道改了什么。</p>
<p>为了改变这种情况，我试过用<a href="http://www.docbook.org/">docbook</a>格式。docbook用xml书写，定义了一套复杂的Schema，详细到作者的email都有定义。docbook还有丰富的工具集，可以通过xsl把docbook转换成所有你知道的文档格式。<a href="http://www.sonatype.com/products/maven/documentation/book-defguide">Maven: the Definitive Guide</a>就是用docbook写成的。不过用docbook也存在一些问题，docbook太复杂了，用纯文本编辑器很难处理，作者的学习曲线也比较高，需要所见即所得的编辑器支持。与docbook相类似的DITA，也存在这样的问题，它们是重量级的格式。</p>
<p>轻量级的Wiki格式不错，但是Wiki格式很让人头疼就是没有统一的规范。举例，dokuwiki里顶级标题是6个=，而moinmoin里顶级标题恰恰相反是一个=，不portable，文档维护起来就非常麻烦。</p>
<p>铺垫了这么多，委屈以上格式了，该<a href="http://daringfireball.net/projects/markdown/">markdown</a>出场了。markdown是简单的html原型，用来生成html，它的设计目标就是为了KISS，兼容html。看看一些必要的格式吧：（或者直接看<a href="http://en.wikipedia.org/wiki/Markdown">Wikipedia</a>）<br />
标题<br />
# 标题<br />
## 二级标题<br />
&#8230;<br />
###### 六级标题</p>
<p>对于一级标题还可以这么写<br />
headline<br />
========<br />
二级标题可以<br />
headline<br />
&#8212;&#8212;&#8211;<br />
这个怎么输入呢，我想起来前几天看vim hacks里的一组快捷键<br />
yypoVr=<br />
yypoVr-<br />
谁用谁知道</p>
<p>段落：<br />
一段文本以两个换行结束。<br />
换行：<br />
一行文本行末两个空格。</p>
<p>图片<br />
![alternative text](image-url &#8220;image-title&#8221;)<br />
用markdown，图片的alt你不写都不行。</p>
<p>链接<br />
[Linktext](link &#8220;linktitle&#8221;)</p>
<p>列表<br />
ul 无序列表<br />
*<br />
*<br />
ol 有序列表<br />
1.<br />
2.</p>
<p>以上就是主要的格式支持。用标题来划分文档层次，没有多余的格式，没有机会让你五颜六色。</p>
<p>在linux上可以安装markdown的处理脚本：<br />
apt-get install markdown<br />
安装vim的语法文件：</p>
<p>http://www.vim.org/scripts/script.php?script_id=1242</p>
<p>这里是一个简单的例子：</p>
<p>http://github.com/sunng87/exaile-doubanfm-plugin/blob/master/README.mkd</p>
<p>The post is brought to you by <a href="http://fedorahosted.org/lekhonee">lekhonee</a> v0.7</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/07/%e7%94%a8markdown%e4%b9%a6%e5%86%99%e6%96%87%e6%a1%a3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Exaile-doubanfm-plugin 0.0.2</title>
		<link>http://sunng.info/blog/2010/07/exaile-doubanfm-plugin-0-0-2/</link>
		<comments>http://sunng.info/blog/2010/07/exaile-doubanfm-plugin-0-0-2/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 14:17:53 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[广告]]></category>
		<category><![CDATA[Douban]]></category>
		<category><![CDATA[exaile]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2010/07/exaile-doubanfm-plugin-0-0-2/</guid>
		<description><![CDATA[Exaile doubanfm plugin 0.0.2 预览版，目标是在Linux桌面提供豆瓣电台的完整体验。 目前插件只能运行在Exaile 0.3.1版本上。 0.0.2增加了豆瓣电台专用的视图： 相比第一版通过rating来实现豆瓣电台喜欢、跳过和删除的功能，在专用视图上有专门的按钮来操作。 其他细节更新： 当剩余曲目超过15首时不再增加播放列表 当播放到最后一首歌曲取新播放列表时增加重试机制 修正libdbfm跳过曲目bug一个 安装： 打开Exaile Preference，Plugin页，点击按钮Install Plugin，选择doubanfm.exz即可。如果存在问题，可以执行以下命令： mv doubanfm.exz douban.tar.gz tar xf doubanfm.tar.gz mv doubanfm ~/.local/share/exaile/plugins/ 转到doubanfm设置页面，填写用户名密码重启Exaile。 打开File菜单，选择豆瓣电台频道 选择曲目就可以开始播放了，选择视图中豆瓣电台视图可以切换到豆瓣电台视图。 项目地址： http://github.com/sunng87/exaile-doubanfm-plugin 下载： http://github.com/sunng87/exaile-doubanfm-plugin/downloads 另外，doubancovers插件也有一个针对豆瓣电台的更新可以快速获取豆瓣电台音乐的封面： http://bitbucket.org/sunng/exailedoubancovers/downloads?highlight=9265 The post is brought to you by lekhonee v0.7]]></description>
			<content:encoded><![CDATA[<p>Exaile doubanfm plugin 0.0.2 预览版，目标是在Linux桌面提供豆瓣电台的完整体验。</p>
<p><strong>目前插件只能运行在Exaile 0.3.1版本上。</strong></p>
<p>0.0.2增加了豆瓣电台专用的视图：<br />
<a href="http://www.flickr.com/photos/40741608@N08/4760493886/" title="screenshot_001 by 贝小塔, on Flickr"><img src="http://farm5.static.flickr.com/4075/4760493886_5e334726cf.jpg" width="408" height="156" alt="screenshot_001" /></a></p>
<p>相比第一版通过rating来实现豆瓣电台喜欢、跳过和删除的功能，在专用视图上有专门的按钮来操作。</p>
<p>其他细节更新：</p>
<ul>
<li>当剩余曲目超过15首时不再增加播放列表</li>
<li>当播放到最后一首歌曲取新播放列表时增加重试机制</li>
<li>修正libdbfm跳过曲目bug一个</li>
</ul>
<p>安装：<br />
打开Exaile Preference，Plugin页，点击按钮Install Plugin，选择doubanfm.exz即可。如果存在问题，可以执行以下命令：<br />
mv doubanfm.exz douban.tar.gz<br />
tar xf doubanfm.tar.gz<br />
mv doubanfm ~/.local/share/exaile/plugins/</p>
<p>转到doubanfm设置页面，填写用户名密码重启Exaile。<br />
<a href="http://www.flickr.com/photos/40741608@N08/4754666940/" title="screenshot_002 by 贝小塔, on Flickr"><img src="http://farm5.static.flickr.com/4141/4754666940_b998d99c4b.jpg" width="500" height="412" alt="screenshot_002" /></a></p>
<p>打开File菜单，选择豆瓣电台频道<br />
<a href="http://www.flickr.com/photos/40741608@N08/4754619030/" title="screenshot_001 by 贝小塔, on Flickr"><img src="http://farm5.static.flickr.com/4094/4754619030_933e00fcfa.jpg" width="500" height="359" alt="screenshot_001" /></a></p>
<p>选择曲目就可以开始播放了，选择视图中豆瓣电台视图可以切换到豆瓣电台视图。</p>
<p>项目地址：<br />
<a href="http://github.com/sunng87/exaile-doubanfm-plugin">http://github.com/sunng87/exaile-doubanfm-plugin</a></p>
<p>下载：<br />
<a href="http://github.com/sunng87/exaile-doubanfm-plugin/downloads">http://github.com/sunng87/exaile-doubanfm-plugin/downloads</a></p>
<p>另外，doubancovers插件也有一个针对豆瓣电台的更新可以快速获取豆瓣电台音乐的封面：<br />
<a href="http://bitbucket.org/sunng/exailedoubancovers/downloads?highlight=9265">http://bitbucket.org/sunng/exailedoubancovers/downloads?highlight=9265</a></p>
<p>The post is brought to you by <a href="http://fedorahosted.org/lekhonee">lekhonee</a> v0.7</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/07/exaile-doubanfm-plugin-0-0-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>交通游戏OpenTTD</title>
		<link>http://sunng.info/blog/2010/05/openttd/</link>
		<comments>http://sunng.info/blog/2010/05/openttd/#comments</comments>
		<pubDate>Sun, 02 May 2010 15:12:28 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[把戏]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=566</guid>
		<description><![CDATA[我总是对这种城市建设、交通规划一类的游戏欲罢不能，以前在Linux上一直只是玩Lincity，后来发现了纯交通类的simutrans，最近升级到Ubuntu10.04以后，终于可以玩这个六年磨一剑，精雕细琢的OpenTTD了。 可以建造各种客运货运的汽车站、火车站，机场，码头等等，可以建设道路、铁路，可以购买公交车、卡车、火车头、火车车厢等等。可惜我玩了大半天还不知道怎么盈利。。。]]></description>
			<content:encoded><![CDATA[<p>我总是对这种城市建设、交通规划一类的游戏欲罢不能，以前在Linux上一直只是玩<a href="http://lincity-ng.berlios.de/">Lincity</a>，后来发现了纯交通类的<a href="http://www.simutrans.com/">simutrans</a>，最近升级到Ubuntu10.04以后，终于可以玩这个六年磨一剑，精雕细琢的<a href="http://openttd.org">OpenTTD</a>了。</p>
<p><a href="http://www.flickr.com/photos/40741608@N08/4571371260/" title="Chindhattan Springs Transport, 19th Dec 1953 by 贝小塔, on Flickr"><img src="http://farm4.static.flickr.com/3521/4571371260_ce28e57779.jpg" width="500" height="284" alt="Chindhattan Springs Transport, 19th Dec 1953" /></a></p>
<p>可以建造各种客运货运的汽车站、火车站，机场，码头等等，可以建设道路、铁路，可以购买公交车、卡车、火车头、火车车厢等等。可惜我玩了大半天还不知道怎么盈利。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/05/openttd/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>Douban provider for Alexandria</title>
		<link>http://sunng.info/blog/2010/04/douban-provider-for-alexandria/</link>
		<comments>http://sunng.info/blog/2010/04/douban-provider-for-alexandria/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 11:25:33 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[广告]]></category>
		<category><![CDATA[Douban]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=559</guid>
		<description><![CDATA[Alexandra is a desktop book collection manager on gnome written in ruby. With an extensible architecture, Alexandria uses different sources to retrieve book&#8217;s data, including Amazon and many local sites. Douban.com is considered to be most applicable data source for books published in Chinese. So I write this provider according to Alexandria&#8217;s SPI. Now it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://alexandria.rubyforge.org/">Alexandra</a> is a desktop book collection manager on gnome written in ruby. With an extensible architecture, Alexandria uses different sources to retrieve book&#8217;s data, including Amazon and many local sites.</p>
<p>Douban.com is considered to be most applicable data source for books published in Chinese. So I write this provider according to Alexandria&#8217;s SPI. Now it&#8217;s possible to add Chinese books and manage reading lists.</p>
<p><a href="http://www.flickr.com/photos/40741608@N08/4564768299/" title="alexandria by 贝小塔, on Flickr"><img src="http://farm5.static.flickr.com/4046/4564768299_f424dc2be9.jpg" width="500" height="388" alt="alexandria" /></a></p>
<p>Now the code can be found in Alexandria&#8217;s bug tracker:<br />
<a href="http://rubyforge.org/tracker/index.php?func=detail&#038;aid=28160&#038;group_id=205&#038;atid=865">http://rubyforge.org/tracker/index.php?func=detail&#038;aid=28160&#038;group_id=205&#038;atid=865</a></p>
<p>However, the patch file of book_providers.rb in that list is for svn trunk head version only. To use it with currently stable version of Ubuntu, first, make sure you have Alexandria version <strong>0.6.5-0ubuntu1</strong> and <strong>libjson-ruby1.8</strong> installed.</p>
<p>Download douban.rb from rubyforge:<br />
<a href="http://rubyforge.org/tracker/download.php/205/865/28160/4923/douban.rb">http://rubyforge.org/tracker/download.php/205/865/28160/4923/douban.rb</a><br />
Copy the file to /usr/lib/ruby/1.8/alexandria/book_providers/ with super user privileges.<br />
Use this patch to /usr/lib/ruby/1.8/alexandria/book_providers.rb</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">310a311,<span style="color:#006666;">323</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">begin</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">begin</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json'</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json'</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'alexandria/book_providers/douban'</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span> =<span style="color:#006600; font-weight:bold;">&lt;</span> ex<br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; log.<span style="color:#9900CC;">error</span><span style="color:#006600; font-weight:bold;">&#123;</span>ex<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; &nbsp; log.<span style="color:#9900CC;">warn</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'Fail to load douban as provider'</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span> &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#006600; font-weight:bold;">&lt;</span></div></div>
<p>Feel free to report issue here.</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/04/douban-provider-for-alexandria/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>搞定gwibber</title>
		<link>http://sunng.info/blog/2010/03/%e6%90%9e%e5%ae%9agwibber/</link>
		<comments>http://sunng.info/blog/2010/03/%e6%90%9e%e5%ae%9agwibber/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 04:48:31 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[把戏]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gwibber]]></category>
		<category><![CDATA[pycurl]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=522</guid>
		<description><![CDATA[升级10.04之后，gwibber2.29开始使用pycurl来处理IO。结果一条更新都拿不下来，为此搜到很多相关、不相关的bug。最后终于自己找到问题，原来是pycurl.setopt方法传入字符串如果是unicode就会报typeerror。而通过gwibber配置界面输入的所有字符都是unicode编码，于是问题也就简单了。做个处理，在 /usr/lib/python2.6/dist-packages/gwibber/microblog/network.py 第18到21行： &#160; &#160; self.curl.setopt&#40;pycurl.URL, str&#40;url&#41;.encode&#40;'ascii'&#41;&#41; &#160; &#160; if username and password: &#160; &#160; &#160; self.curl.setopt&#40;pycurl.USERPWD, &#40;&#34;%s:%s&#34; % &#40;username, password&#41;&#41;.encode&#40;'ascii'&#41;&#41; 另外，使用StatusNet的Twitter兼容API来做Twitter API代理，需要把代理的目录名设置为api，因为/api这个路径是写死在gwibber代码里的。通过界面输入的，只是代理的domain。 说实在的gwibber还是挺烂的。 https://bugs.launchpad.net/bugs/542501 https://bugs.launchpad.net/bugs/543860]]></description>
			<content:encoded><![CDATA[<p>升级10.04之后，gwibber2.29开始使用pycurl来处理IO。结果一条更新都拿不下来，为此搜到很多相关、不相关的bug。最后终于自己找到问题，<strong>原来是pycurl.setopt方法传入字符串如果是unicode就会报typeerror</strong>。而通过gwibber配置界面输入的所有字符都是unicode编码，于是问题也就简单了。做个处理，在 <em>/usr/lib/python2.6/dist-packages/gwibber/microblog/network.py</em> 第18到21行：</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">curl</span>.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">URL</span>, <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ascii'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> username <span style="color: #ff7700;font-weight:bold;">and</span> password:<br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">curl</span>.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">USERPWD</span>, <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s:%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>username, password<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ascii'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></div>
<p>另外，使用StatusNet的Twitter兼容API来做Twitter API代理，需要把代理的目录名设置为api，因为/api这个路径是写死在gwibber代码里的。通过界面输入的，只是代理的domain。</p>
<p>说实在的gwibber还是挺烂的。</p>
<p>https://bugs.launchpad.net/bugs/542501</p>
<p>https://bugs.launchpad.net/bugs/543860</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/03/%e6%90%9e%e5%ae%9agwibber/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>I ♥ Free and Open Source Software</title>
		<link>http://sunng.info/blog/2010/02/i-%e2%99%a5-free-and-open-source-software/</link>
		<comments>http://sunng.info/blog/2010/02/i-%e2%99%a5-free-and-open-source-software/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 13:43:22 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[foss]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=485</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://fsfe.org/campaigns/valentine-2010/valentine-2010.html"><img src="http://fsfe.org/campaigns/valentine-2010/vd-i-love-fs-358x60.png" style="border: 0 !important;" alt="I love Free Software!"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/02/i-%e2%99%a5-free-and-open-source-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<georss:point>32.0183376666 118.811044693</georss:point>	</item>
		<item>
		<title>使用gnome-dictionary和dictd</title>
		<link>http://sunng.info/blog/2010/02/%e4%bd%bf%e7%94%a8gnome-dictionary%e5%92%8cdictd/</link>
		<comments>http://sunng.info/blog/2010/02/%e4%bd%bf%e7%94%a8gnome-dictionary%e5%92%8cdictd/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 10:57:20 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[dictd]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=447</guid>
		<description><![CDATA[最近琢磨字典多一些，以前一直不知道gnome自带的gnome-dictionary如何使用，因为默认的字典源里都没有中文字典，而且离线更是无法使用。其实不然，字典服务可以自架，并且可以使用自己的字典。 在自己的机器上架设dictionary server，以ubuntu为例： 安装dictd / dict sudo apt-get install dictd dict 前者是字典服务器，后者是字典服务客户端。还可以从仓库里安装已经打包好的字典，如 sudo apt-get install dict-stardic 是一个英汉字典 dictd安装好后会默认自启动，也可以通过 sudo service dictd start 来控制dictd的启动、重启和关闭。 通过dict测试服务的状况 dict -D 命令会列出可用的数据库（即字典） 在gnome-dictionary中添加字典源 Edit-&#62;Preference-&#62;Source-&#62;Add Name: 自定义的字典名 Transport: Dictionary Source Hostname: 127.0.0.1 Port: 2628 Close之后可以到主界面打开侧边栏，在Dictionary Source中双击选定此字典，在Aailable Dictionaries里双击选中目标字典，于是就可以在gnome-dictionary里使用本地的字典服务了。 接下来安装自己的字典。stardict的网站上有很多中文字典，上面也都标示了授权协议。要在dictd里使用这些字典，需要进行一个简单的格式转换。安装一个工具 sudo apt-get install dictconv 它的使用方法： dictconv -o OUTPUT_FILE INPUT_FILE 在input_file指定stardict的.ifo文件，在output_file指定要生成的dictd的.index文件。这个转换非常耗时，需要有足够的耐心。这个操作将会生成.index和.dict文件。对.dict文件进行压缩： dictzip OUT.dict 转换完成后，编辑/var/lib/dictd/db.list文件，在其中添加一个database定义 [...]]]></description>
			<content:encoded><![CDATA[<p>最近琢磨字典多一些，以前一直不知道gnome自带的gnome-dictionary如何使用，因为默认的字典源里都没有中文字典，而且离线更是无法使用。其实不然，字典服务可以自架，并且可以使用自己的字典。</p>
<p>在自己的机器上架设dictionary server，以ubuntu为例：</p>
<p>安装dictd / dict<br />
<em>sudo apt-get install dictd dict</em></p>
<p>前者是字典服务器，后者是字典服务客户端。还可以从仓库里安装已经打包好的字典，如<br />
<em>sudo apt-get install dict-stardic</em><br />
是一个英汉字典</p>
<p>dictd安装好后会默认自启动，也可以通过<br />
<em>sudo service dictd start</em><br />
来控制dictd的启动、重启和关闭。</p>
<p>通过dict测试服务的状况<br />
<em>dict -D</em><br />
命令会列出可用的数据库（即字典）</p>
<p>在gnome-dictionary中添加字典源 Edit-&gt;Preference-&gt;Source-&gt;Add<br />
Name: 自定义的字典名<br />
Transport: Dictionary Source<br />
Hostname: 127.0.0.1<br />
Port: 2628</p>
<p>Close之后可以到主界面打开侧边栏，在Dictionary Source中双击选定此字典，在Aailable Dictionaries里双击选中目标字典，于是就可以在gnome-dictionary里使用本地的字典服务了。</p>
<p>接下来安装自己的字典。stardict的<a href="http://stardict.sourceforge.net/Dictionaries_zh_CN.php">网站</a>上有很多中文字典，上面也都标示了授权协议。要在dictd里使用这些字典，需要进行一个简单的格式转换。安装一个工具<br />
<em>sudo apt-get install dictconv</em></p>
<p><em>它的使用方法：<br />
dictconv -o OUTPUT_FILE INPUT_FILE</em></p>
<p>在input_file指定stardict的.ifo文件，在output_file指定要生成的dictd的.index文件。这个转换非常耗时，需要有足够的耐心。这个操作将会生成.index和.dict文件。对.dict文件进行压缩：<br />
<em>dictzip OUT.dict</em></p>
<p>转换完成后，编辑<em>/var/lib/dictd/db.list</em>文件，在其中添加一个database定义<br />
<em>database YOUR_DB_NAME{<br />
data PATH_TO_DICT_DZ<br />
index PATH_TO_INDEX<br />
}</em></p>
<p>其中PATH_TO_DICT_DZ是上一步的.dz文件，PATH_TO_INDEX是到上一步生成的.index文件的路径。编辑完成后，重启dictd服务<br />
<em>sudo service dictd restart</em></p>
<p>使用dict -D可以查看启用的字典。</p>
<p>建议备份<em>/var/lib/dictd/db.list</em>文件，因为每次从apt-get安装字典后，这个文件都会被覆盖。</p>
<p>dictd服务也可以在fantasdic里访问。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/02/%e4%bd%bf%e7%94%a8gnome-dictionary%e5%92%8cdictd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>很山寨</title>
		<link>http://sunng.info/blog/2010/02/%e5%be%88%e5%b1%b1%e5%af%a8/</link>
		<comments>http://sunng.info/blog/2010/02/%e5%be%88%e5%b1%b1%e5%af%a8/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 14:03:10 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=443</guid>
		<description><![CDATA[经常访问GNU的网站你会发现一些很神奇的东西，比如gNewSense，又比如最新的： 怎么样，够震撼啊，GNUzilla套件里的第一个发布，IceCat。IceCat是嘛？你知道Firefox吧，那拉开冰箱门，把Firefox塞进去，带上冰箱门，嗯，那就是IceCat了。当然是开玩笑了，GNU IceCat is the GNU version of the Firefox browser. Its main advantage is an ethical one: it is entirely free software. 现在已经可以在Ubuntu中使用这个病猫，哦不，冰猫了： sudo add-apt-repository ppa:gnuzilla-team/ppa sudo apt-get update sudo apt-get install icecat]]></description>
			<content:encoded><![CDATA[<p>经常访问<a href="http://www.gnu.org" target="_blank">GNU</a>的网站你会发现一些很神奇的东西，比如<a href="http://http://www.gnewsense.org/" target="_blank">gNewSense</a>，又比如最新的：<br />
<a title="IceCat by 贝小塔, on Flickr" href="http://www.flickr.com/photos/40741608@N08/4326991719/"><img src="http://farm5.static.flickr.com/4009/4326991719_a5253581dc_o.png" alt="IceCat" width="306" height="482" /></a></p>
<p>怎么样，够震撼啊，<a href="http://www.gnu.org/software/gnuzilla/" target="_blank">GNUzilla</a>套件里的第一个发布，IceCat。IceCat是嘛？你知道Firefox吧，那拉开冰箱门，把Firefox塞进去，带上冰箱门，嗯，那就是IceCat了。当然是开玩笑了，GNU IceCat is the GNU version of the Firefox browser.  Its main advantage is an ethical one: it is entirely <a href="http://www.gnu.org/philosophy/free-sw.html">free software</a>.</p>
<p>现在已经可以在Ubuntu中使用这个病猫，哦不，冰猫了：</p>
<p><em>sudo add-apt-repository ppa:gnuzilla-team/ppa<br />
sudo apt-get update<br />
sudo apt-get install icecat</em></p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/02/%e5%be%88%e5%b1%b1%e5%af%a8/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>Patch for Fantasdic Google Source</title>
		<link>http://sunng.info/blog/2010/02/patch-for-fantadic-google-source/</link>
		<comments>http://sunng.info/blog/2010/02/patch-for-fantadic-google-source/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 14:15:40 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[广告]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/?p=439</guid>
		<description><![CDATA[I found fantasdic a great powerful dictionary tool with friendly UI and supports multiply sources. Unfortunately, this project seems to be no longer maintained. The latest version is 1.0-beta7. The google translate source was created in 2007. As the google translate service page changed, this module doesn&#8217;t work any more, so I just picked up [...]]]></description>
			<content:encoded><![CDATA[<p>I found fantasdic a great powerful dictionary tool with friendly UI and supports multiply sources. Unfortunately, this project seems to be no longer maintained. The latest version is 1.0-beta7.<br />
<a title="fantasdic-google by 贝小塔, on Flickr" href="http://www.flickr.com/photos/40741608@N08/4324570353/"><img src="http://farm5.static.flickr.com/4049/4324570353_c1f79ac6dc.jpg" alt="fantasdic-google" width="500" height="362" /></a></p>
<p>The google translate source was created in 2007. As the google translate service page changed, this module doesn&#8217;t work any more, so I just picked up my vim then created this patch for those still want to use it.</p>
<p>This patch has dependency with ruby&#8217;s json module, so before you apply it, run:<br />
<em>sudo gem install json</em><br />
or<br />
<em>sudo apt-get install libjson-ruby1.8</em></p>
<p>Download the patch at:<br />
<a href="https://bugzilla.gnome.org/attachment.cgi?id=152835">https://bugzilla.gnome.org/attachment.cgi?id=152835</a></p>
<p>Patch it (Ubuntu installation as example):<br />
<em>cd /usr/lib/ruby/1.8/fantasdic/sources/<br />
sudo patch google_translate.rb /home/sun/google_translate.rb.diff</em></p>
<p>Restart fantasdic, then your get it works! And this bug is tracked at:<br />
<a href="https://bugzilla.gnome.org/show_bug.cgi?id=605641">https://bugzilla.gnome.org/show_bug.cgi?id=605641</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2010/02/patch-for-fantadic-google-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
	</channel>
</rss>
