<?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/"
	>

<channel>
	<title>vifix.cn &#187; Coding</title>
	<atom:link href="http://vifix.cn/blog/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://vifix.cn/blog</link>
	<description>compile the dream, compile tomorrow</description>
	<lastBuildDate>Sat, 04 Feb 2012 03:15:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SimpleSnake &#8211; Hello, Android World</title>
		<link>http://vifix.cn/blog/simplesnake-hello-android-world.html</link>
		<comments>http://vifix.cn/blog/simplesnake-hello-android-world.html#comments</comments>
		<pubDate>Fri, 20 Jan 2012 06:39:13 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2229</guid>
		<description><![CDATA[年末了，相对来说工作已经比较清闲，于是趁着机会研究了一下Android的游戏开发，花了一个下午写了这个贪吃蛇的应用。 使用的游戏引擎是libgdx，虽然目前看起来文档比较缺少，但是，最大的好处是可以在Winodows/OSX/Linux上运行，android上则只需要额外几行代码就可以运行，极大的方便了调试和跨平台的工作。 下载apk请点击此处 &#8211; simplesnake （必须要800&#215;480的分辨率才可以正常运行，如果大于这个分辨率仍然可以运行但按钮将错位，低于这个分辨率则可能出现奇怪的问题并且按钮缺失，因为只是hello, world，所以也不打算进一步优化各个分辨率了） 另外推荐下libgdx原作者的博客badlogic，以及他写的书：google book，豆瓣，像我这样的游戏开发初学者看看挺不错的。 一篇国产PC/Android游戏引擎LGame作者cping1982同学的介绍libgx的科普文章也很值得一看：http://blog.csdn.net/cping1982/article/details/6176191]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2012/01/simple-snake.png" rel="shadowbox[sbpost-2229];player=img;"><img class="alignnone size-medium wp-image-2230" src="http://vifix.cn/blog/wp-content/uploads/2012/01/simple-snake-300x276.png" alt="" width="300" height="276" /></a></p>
<p>年末了，相对来说工作已经比较清闲，于是趁着机会研究了一下Android的游戏开发，花了一个下午写了这个贪吃蛇的应用。</p>
<p>使用的游戏引擎是<a href="http://code.google.com/p/libgdx/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/libgdx/?referer=');">libgdx</a>，虽然目前看起来文档比较缺少，但是，最大的好处是可以在Winodows/OSX/Linux上运行，android上则只需要额外几行代码就可以运行，极大的方便了调试和跨平台的工作。</p>
<p>下载apk请点击此处 &#8211; <a href="http://vifix.cn/blog/wp-content/uploads/2012/01/simplesnake.zip">simplesnake</a> （必须要800&#215;480的分辨率才可以正常运行，如果大于这个分辨率仍然可以运行但按钮将错位，低于这个分辨率则可能出现奇怪的问题并且按钮缺失，因为只是hello, world，所以也不打算进一步优化各个分辨率了）</p>
<p>另外推荐下libgdx原作者的博客<a href="http://badlogicgames.com/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/badlogicgames.com/?referer=');">badlogic</a>，以及他写的书：<a href="http://books.google.com.hk/books?id=NetBrvVEe3cC&amp;printsec=frontcover&amp;dq=beginning+android+game&amp;hl=en&amp;sa=X&amp;ei=HAsZT_2IJM2ciQf6ronWCw&amp;redir_esc=y&amp;hl=zh-CN&amp;sourceid=cndr#v=onepage&amp;q&amp;f=false" target="_blank" onclick="pageTracker._trackPageview('/outgoing/books.google.com.hk/books?id=NetBrvVEe3cC_amp_printsec=frontcover_amp_dq=beginning+android+game_amp_hl=en_amp_sa=X_amp_ei=HAsZT_2IJM2ciQf6ronWCw_amp_redir_esc=y_amp_hl=zh-CN_amp_sourceid=cndr_v=onepage_amp_q_amp_f=false&amp;referer=');">google book</a>，<a href="http://book.douban.com/subject/4753615/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/book.douban.com/subject/4753615/?referer=');">豆瓣</a>，像我这样的游戏开发初学者看看挺不错的。</p>
<p>一篇国产PC/Android游戏引擎LGame作者cping1982同学的介绍libgx的科普文章也很值得一看：<a href="http://blog.csdn.net/cping1982/article/details/6176191" target="_blank" onclick="pageTracker._trackPageview('/outgoing/blog.csdn.net/cping1982/article/details/6176191?referer=');">http://blog.csdn.net/cping1982/article/details/6176191</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/simplesnake-hello-android-world.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven 添加一个本地jar包</title>
		<link>http://vifix.cn/blog/maven-add-local-private-jar.html</link>
		<comments>http://vifix.cn/blog/maven-add-local-private-jar.html#comments</comments>
		<pubDate>Thu, 15 Dec 2011 09:08:33 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2186</guid>
		<description><![CDATA[在pom.xml添加： &#60;dependency&#62; &#60;groupId&#62;cn.vifix&#60;/groupId&#62; &#60;artifactId&#62;maven-test&#60;/artifactId&#62; &#60;version&#62;0.0.1&#60;/version&#62; &#60;systemPath&#62;${basedir}/lib/mt.jar&#60;/systemPath&#62; &#60;scope&#62;system&#60;/scope&#62; &#60;/dependency&#62; 即可达成目标。 不过这是一种临时性质的方案，maven进行编译时会警告未来这种方式可能会过期，更好的方式还是搭建一下自己的本地仓库来解决本地jar包的问题。 2011-11-15补充 发现这种方式确实不是很好的一种方式，在进行maven的package打包操作的时候，这种system scope的包是不会被打包进去的，还是老老实实的用本地仓库吧]]></description>
			<content:encoded><![CDATA[<p>在pom.xml添加：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cn.vifix<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.0.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;systemPath<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/lib/mt.jar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/systemPath<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>system<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>即可达成目标。</p>
<p>不过这是一种临时性质的方案，maven进行编译时会警告未来这种方式可能会过期，更好的方式还是搭建一下自己的本地仓库来解决本地jar包的问题。</p>
<h3>2011-11-15补充</h3>
<p>发现这种方式确实不是很好的一种方式，在进行maven的package打包操作的时候，这种system scope的包是不会被打包进去的，还是老老实实的用本地仓库吧</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/maven-add-local-private-jar.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>convmv &#8211; Linux下修改文件名编码</title>
		<link>http://vifix.cn/blog/convmv-linux-convert-filename-encoding.html</link>
		<comments>http://vifix.cn/blog/convmv-linux-convert-filename-encoding.html#comments</comments>
		<pubDate>Wed, 19 Oct 2011 09:01:28 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2173</guid>
		<description><![CDATA[今天在公司tar打包一些编码为GBK的中文文件名的文件时打包碰到的问题。我自己的locale是en_US.UTF8，那台主机的环境是zh_CN.GBK，因此tar不管怎么打包，都会使文件名出现问题。而如果采用7z打包，虽然可以解决乱码问题（7z会记录下文件名的编码），但会丢失文件属性，所以不打算采用。 google了下发现可以通过convmv来进行解决： convmv -f GBK -t UTF8 -r --notest target 其中-f是源编码，-t是目标编码，-r是递归处理目录，&#8211;notest是不移动，实际上对文件进行改名（actually do rename the files），target是目标目录。其余参数可以参考man或者-h。 另外一个方案是google到了一个python脚本，通过python的tarfile包解决问题，感兴趣的可以看看这个link: http://superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem]]></description>
			<content:encoded><![CDATA[<p>今天在公司tar打包一些编码为GBK的中文文件名的文件时打包碰到的问题。我自己的locale是en_US.UTF8，那台主机的环境是zh_CN.GBK，因此tar不管怎么打包，都会使文件名出现问题。而如果采用7z打包，虽然可以解决乱码问题（7z会记录下文件名的编码），但会丢失文件属性，所以不打算采用。</p>
<p>google了下发现可以通过convmv来进行解决：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">convmv <span style="color: #660033;">-f</span> GBK <span style="color: #660033;">-t</span> UTF8 <span style="color: #660033;">-r</span> <span style="color: #660033;">--notest</span> target</pre></div></div>

<p>其中-f是源编码，-t是目标编码，-r是递归处理目录，&#8211;notest是不移动，实际上对文件进行改名（actually do rename the files），target是目标目录。其余参数可以参考man或者-h。</p>
<p>另外一个方案是google到了一个python脚本，通过python的tarfile包解决问题，感兴趣的可以看看这个link: <a href="http://superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem" target="_blank" onclick="pageTracker._trackPageview('/outgoing/superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem?referer=');">http://superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/convmv-linux-convert-filename-encoding.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>To Dennis Ritchie</title>
		<link>http://vifix.cn/blog/to-dennis-ritchie.html</link>
		<comments>http://vifix.cn/blog/to-dennis-ritchie.html#comments</comments>
		<pubDate>Sat, 15 Oct 2011 08:32:00 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2163</guid>
		<description><![CDATA[#include &#60;stdio.h&#62; &#160; int main&#40;&#41;&#123; printf&#40;&#34;goodbye, world!\n&#34;&#41;; return 0; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;goodbye, world!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/to-dennis-ritchie.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DoubanFM-CLI</title>
		<link>http://vifix.cn/blog/doubanfm-cli.html</link>
		<comments>http://vifix.cn/blog/doubanfm-cli.html#comments</comments>
		<pubDate>Wed, 12 Oct 2011 09:14:36 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2158</guid>
		<description><![CDATA[嗯……一直想在Linux下面搞个好使的豆瓣FM客户端好在工作时听听（不然要专门开个浏览器），于是google了下找到了这个，于是什么桌面客户端之类的弱爆了啊，这个才是Geeker听音乐的方式 = 。 = 东西是Python写的，代码短小精干，也可以自己研究下 github: https://github.com/zhendi/DoubanFM-CLI 作者豆瓣: http://www.douban.com/people/KaKa9527/]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2011/10/douban_cli.png" rel="shadowbox[sbpost-2158];player=img;" title="douban_cli"><img class="alignnone size-medium wp-image-2160" title="douban_cli" src="http://vifix.cn/blog/wp-content/uploads/2011/10/douban_cli-300x187.png" alt="" width="300" height="187" /></a></p>
<p>嗯……一直想在Linux下面搞个好使的豆瓣FM客户端好在工作时听听（不然要专门开个浏览器），于是google了下找到了这个，于是什么桌面客户端之类的弱爆了啊，这个才是Geeker听音乐的方式 = 。 =</p>
<p>东西是Python写的，代码短小精干，也可以自己研究下</p>
<p>github: <a href="https://github.com/zhendi/DoubanFM-CLI" target="_blank" onclick="pageTracker._trackPageview('/outgoing/github.com/zhendi/DoubanFM-CLI?referer=');">https://github.com/zhendi/DoubanFM-CLI</a></p>
<p>作者豆瓣: <a href="http://www.douban.com/people/KaKa9527/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.douban.com/people/KaKa9527/?referer=');">http://www.douban.com/people/KaKa9527/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/doubanfm-cli.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>推荐下mintty</title>
		<link>http://vifix.cn/blog/mintty.html</link>
		<comments>http://vifix.cn/blog/mintty.html#comments</comments>
		<pubDate>Sat, 25 Jun 2011 10:10:14 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2086</guid>
		<description><![CDATA[没啥好说的，cmd.exe太挫了，找到了这个mintty用来替换之，非常不错，对于CLI一直很薄弱的windows来说已经觉得很满意了。 项目似乎是基于putty的，推荐给那些整天Unix世界（Linux/BSD/OSX）和Windows世界来回奔波的geeker们（伤不起啊有木有！！！）]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2011/06/mintty.png" rel="shadowbox[sbpost-2086];player=img;" title="mintty"><img class="alignnone size-medium wp-image-2087" title="mintty" src="http://vifix.cn/blog/wp-content/uploads/2011/06/mintty-300x240.png" alt="" width="300" height="240" /></a></p>
<p>没啥好说的，cmd.exe太挫了，找到了这个mintty用来替换之，非常不错，对于CLI一直很薄弱的windows来说已经觉得很满意了。</p>
<p>项目似乎是基于putty的，推荐给那些整天Unix世界（Linux/BSD/OSX）和Windows世界来回奔波的geeker们（伤不起啊有木有！！！）</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/mintty.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Hello xcode world and happy chinese new year!</title>
		<link>http://vifix.cn/blog/hello-xcode-world-and-happy-chinese-new-year-2011.html</link>
		<comments>http://vifix.cn/blog/hello-xcode-world-and-happy-chinese-new-year-2011.html#comments</comments>
		<pubDate>Wed, 02 Feb 2011 16:00:15 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Undefined]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=1862</guid>
		<description><![CDATA[正所谓年三十默默打开xcode写hello world的寂寞，谁懂。TVTbbb 好吧，各位就不要吐嘈为什么只有printf了，因为咱其实就只会那么几句C…… 至于cocoa的hello world神马的，就再说吧……]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2011/02/happy-chinese-new-year-2011-with-xcode-and-c-helloworld.jpg" rel="shadowbox[sbpost-1862];player=img;" title="happy-chinese-new-year-2011-with-xcode-and-c-helloworld"><img class="alignnone size-medium wp-image-1863" title="happy-chinese-new-year-2011-with-xcode-and-c-helloworld" src="http://vifix.cn/blog/wp-content/uploads/2011/02/happy-chinese-new-year-2011-with-xcode-and-c-helloworld-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>正所谓年三十默默打开xcode写hello world的寂寞，谁懂。TVTbbb</p>
<p>好吧，各位就不要吐嘈为什么只有printf了，因为咱其实就只会那么几句C……</p>
<p>至于cocoa的hello world神马的，就再说吧……</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/hello-xcode-world-and-happy-chinese-new-year-2011.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>用jQuery写了两个图片幻灯切换效果</title>
		<link>http://vifix.cn/blog/jquery-simple-images-slidershow.html</link>
		<comments>http://vifix.cn/blog/jquery-simple-images-slidershow.html#comments</comments>
		<pubDate>Fri, 19 Nov 2010 14:35:27 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=1744</guid>
		<description><![CDATA[周二受委托给公司的美工们讲了一下简单的jQuery用法，于是就简单的写了两个例子给他们看，虽然并不是什么大不了的东西，想了想还是放上网也就当自己博客更新找点题材吧（实在是没话好说……orz），希望能对搜索引擎查询jQuery幻灯切换什么的关键词找到这里的同学有点帮助 :) 例子一号 例子二号 本质上这两个东西是一样的，只是二号做的相对来说效果上更多了一点罢了 两个例子打包下载 PS: 话说投影仪上的Cube Desktop看上去实在是太给力了！ （公司我用的桌面环境为KDE 4.5，然后跑了个compiz ）]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2010/11/jquery-image-slidehow.jpg" rel="shadowbox[sbpost-1744];player=img;" title="jquery-image-slidehow"><img class="alignnone size-medium wp-image-1747" title="jquery-image-slidehow" src="http://vifix.cn/blog/wp-content/uploads/2010/11/jquery-image-slidehow-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>周二受委托给公司的美工们讲了一下简单的jQuery用法，于是就简单的写了两个例子给他们看，虽然并不是什么大不了的东西，想了想还是放上网也就当自己博客更新找点题材吧（实在是没话好说……orz），希望能对搜索引擎查询jQuery幻灯切换什么的关键词找到这里的同学有点帮助 :)</p>
<p><a href="http://vifix.cn/atelier/demos/jQueryImageSlider/slider1.html" target="_blank">例子一号</a></p>
<p><a href="http://vifix.cn/atelier/demos/jQueryImageSlider/slider2.html" target="_blank">例子二号</a></p>
<p>本质上这两个东西是一样的，只是二号做的相对来说效果上更多了一点罢了</p>
<p><a href="http://vifix.cn/blog/wp-content/uploads/2010/11/jquery-image-slidehow.zip">两个例子打包下载</a></p>
<p>PS: 话说投影仪上的Cube Desktop看上去实在是太给力了！ （公司我用的桌面环境为KDE 4.5，然后跑了个compiz ）</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/jquery-simple-images-slidershow.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python S60蓝牙终端与PC交互</title>
		<link>http://vifix.cn/blog/python-s60-bluetooth-console-with-xp-hyper-terminal.html</link>
		<comments>http://vifix.cn/blog/python-s60-bluetooth-console-with-xp-hyper-terminal.html#comments</comments>
		<pubDate>Tue, 15 Jun 2010 16:00:28 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[S60]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=1468</guid>
		<description><![CDATA[嘛……Python S60的一个比较Geeker的玩法。通过蓝牙串口通信连接到PC的串口通信的终端软件（已经差不多都快被遗忘了吧，这类软件），从而在PC上使用实际上运行在手机中的Python Shell并达到控制手机的目的。 在Windows XP中，可以使用XP内建的“超级终端”（HyperTerminal）来进行串口的点对点通信。 首先要在PC上开启一个蓝牙串口，我用的是蓝牙驱动程序是BlueSoleil，安装后就已经默认打开了COM6和COM8两个端口，我这里使用的是COM6。 然后启动超级终端，然后建立一个串口的连接，修改其属性和使用的端口为需要使用的COM6分端口。接下去开启手机的Python Shell，启用它的Bluetooth Console，然后选择PC和对应的端口即可完成连接。 接下去PC上的超级终端内就已经是那个熟悉的Python Shell了，可以输入print(&#8220;hello, world&#8221;)试试和世界打个招呼，当然也可以使用其它所有的Python S60提供的API，正如上面第一张截图的： import audio audio.say&#40;&#34;hello, master&#34;&#41; 手机当场会以它特有的电子音说出上面这句话来和它的主人问候 囧 另外也可以实现在终端里面发送短信，代码： import scriptext messaging_handle = scriptext.load&#40;'Service.Messaging', 'IMessaging'&#41; messaging_handle.call&#40;'Send', &#123;'MessageType': u'SMS', 'To': u'12345678', 'BodyText': u'Here is a message from python s60 shell.'&#125;&#41; 除此之外还有许多好玩的东西，可以去docs里面慢慢挖掘。 总体来说Python S60可用性真的非常高，基本上手机能支持的功能它都有API提供了，接下去可以好好在这方面研究一下。]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2010/06/hyper-terminal.jpg" rel="shadowbox[sbpost-1468];player=img;" title="hyper-terminal"><img class="alignnone size-medium wp-image-1470" title="hyper-terminal" src="http://vifix.cn/blog/wp-content/uploads/2010/06/hyper-terminal-300x197.jpg" alt="" width="300" height="197" /></a></p>
<p>嘛……Python S60的一个比较Geeker的玩法。通过蓝牙串口通信连接到PC的串口通信的终端软件（已经差不多都快被遗忘了吧，这类软件），从而在PC上使用实际上运行在手机中的Python Shell并达到控制手机的目的。</p>
<p><span id="more-1468"></span>在Windows XP中，可以使用XP内建的“超级终端”（HyperTerminal）来进行串口的点对点通信。</p>
<p>首先要在PC上开启一个蓝牙串口，我用的是蓝牙驱动程序是BlueSoleil，安装后就已经默认打开了COM6和COM8两个端口，我这里使用的是COM6。</p>
<p><a href="http://vifix.cn/blog/wp-content/uploads/2010/06/bluesoleil.jpg" rel="shadowbox[sbpost-1468];player=img;" title="bluesoleil"><img class="alignnone size-medium wp-image-1472" title="bluesoleil" src="http://vifix.cn/blog/wp-content/uploads/2010/06/bluesoleil-300x255.jpg" alt="" width="300" height="255" /></a></p>
<p>然后启动超级终端，然后建立一个串口的连接，修改其属性和使用的端口为需要使用的COM6分端口。接下去开启手机的Python Shell，启用它的Bluetooth Console，然后选择PC和对应的端口即可完成连接。</p>
<p><a href="http://vifix.cn/blog/wp-content/uploads/2010/06/Screenshot0007.jpg" rel="shadowbox[sbpost-1468];player=img;" title="Screenshot0007"><img class="alignnone size-medium wp-image-1471" title="Screenshot0007" src="http://vifix.cn/blog/wp-content/uploads/2010/06/Screenshot0007-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>接下去PC上的超级终端内就已经是那个熟悉的Python Shell了，可以输入print(&#8220;hello, world&#8221;)试试和世界打个招呼，当然也可以使用其它所有的Python S60提供的API，正如上面第一张截图的：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> audio
audio.<span style="color: black;">say</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;hello, master&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>手机当场会以它特有的电子音说出上面这句话来和它的主人问候 囧<br />
另外也可以实现在终端里面发送短信，代码：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> scriptext
messaging_handle = scriptext.<span style="color: black;">load</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Service.Messaging'</span>, <span style="color: #483d8b;">'IMessaging'</span><span style="color: black;">&#41;</span>
messaging_handle.<span style="color: black;">call</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Send'</span>, <span style="color: black;">&#123;</span><span style="color: #483d8b;">'MessageType'</span>: u<span style="color: #483d8b;">'SMS'</span>, <span style="color: #483d8b;">'To'</span>: u<span style="color: #483d8b;">'12345678'</span>, <span style="color: #483d8b;">'BodyText'</span>: u<span style="color: #483d8b;">'Here is a message from python s60 shell.'</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>除此之外还有许多好玩的东西，可以去docs里面慢慢挖掘。<br />
总体来说Python S60可用性真的非常高，基本上手机能支持的功能它都有API提供了，接下去可以好好在这方面研究一下。</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/python-s60-bluetooth-console-with-xp-hyper-terminal.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Rhino: Javascript for Java</title>
		<link>http://vifix.cn/blog/rhino-javascript-for-java.html</link>
		<comments>http://vifix.cn/blog/rhino-javascript-for-java.html#comments</comments>
		<pubDate>Sun, 21 Jun 2009 15:44:34 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=950</guid>
		<description><![CDATA[好几天没更新了，过去的一周里忙着补作业（一个学期根本没上课，自然作业也就……），半夜送室友去120（室友哮喘发作），下周则要开始考试，整个人也有点疲劳也没时间顾及这儿 orz 那么今次要介绍的东西是Mozilla旗下的一个名为Rhino的项目，纯Java实现的Javascript解释器，很适合希望在自己的Java程序中内嵌Scripting功能的同学。当然了，也可以用它在J2EE中实现用Javascript作为后台语言的功能。 官方网站为：http://www.mozilla.org/rhino/ PS: Mozilla旗下还有一个更知名的C写的Spider Monkey，被广泛应用于Mozilla的产品中，比如Firefox的Javascript引擎就是它，官方网站为：http://www.mozilla.org/js/spidermonkey/ 下面是一个简单的执行js文件的示例代码。 import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; &#160; public class RhinoTest &#123; public static void main&#40;String&#91;&#93; args&#41; &#123; /* 创建一个Javascript的上下文环境，用来存储Javascript的环境信息 */ Context cx = Context.enter&#40;&#41;; try &#123; /* 初始化Javascript标准对象（例如Object, Function, Array等） */ Scriptable scope = cx.initStandardObjects&#40;&#41;; &#160; /* 读取一个.js文件 */ String script = &#34;&#34;; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2009/06/rhino50.jpg" rel="shadowbox[sbpost-950];player=img;" title="rhino50"><img class="alignnone size-medium wp-image-951" title="rhino50" src="http://vifix.cn/blog/wp-content/uploads/2009/06/rhino50-300x150.jpg" alt="rhino50" width="300" height="150" /></a></p>
<p>好几天没更新了，过去的一周里忙着补作业（一个学期根本没上课，自然作业也就……），半夜送室友去120（室友哮喘发作），下周则要开始考试，整个人也有点疲劳也没时间顾及这儿 orz</p>
<p>那么今次要介绍的东西是Mozilla旗下的一个名为Rhino的项目，纯Java实现的Javascript解释器，很适合希望在自己的Java程序中内嵌Scripting功能的同学。当然了，也可以用它在J2EE中实现用Javascript作为后台语言的功能。</p>
<p>官方网站为：<a href="http://www.mozilla.org/rhino/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.mozilla.org/rhino/?referer=');">http://www.mozilla.org/rhino/</a></p>
<p>PS: Mozilla旗下还有一个更知名的C写的Spider Monkey，被广泛应用于Mozilla的产品中，比如Firefox的Javascript引擎就是它，官方网站为：<a href="http://www.mozilla.org/js/spidermonkey/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.mozilla.org/js/spidermonkey/?referer=');">http://www.mozilla.org/js/spidermonkey/</a></p>
<p>下面是一个简单的执行js文件的示例代码。</p>
<p><span id="more-950"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mozilla.javascript.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mozilla.javascript.Scriptable</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RhinoTest
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/* 创建一个Javascript的上下文环境，用来存储Javascript的环境信息 */</span>
        <span style="color: #003399;">Context</span> cx <span style="color: #339933;">=</span> <span style="color: #003399;">Context</span>.<span style="color: #006633;">enter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">/* 初始化Javascript标准对象（例如Object, Function, Array等） */</span>
            Scriptable scope <span style="color: #339933;">=</span> cx.<span style="color: #006633;">initStandardObjects</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">/* 读取一个.js文件 */</span>
            <span style="color: #003399;">String</span> script <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">File</span> file <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>args.<span style="color: #006633;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                file <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// 如果有参数，则读入第一个参数中指定的js文件</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">else</span>
            <span style="color: #009900;">&#123;</span>
                file <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;script.js&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 如果没有参数，则读入script.js</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span><span style="color: #009900;">&#40;</span>file<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> s <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>s <span style="color: #339933;">=</span> in.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                script <span style="color: #339933;">+=</span> s <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">/* 执行代码 */</span>
            cx.<span style="color: #006633;">evaluateString</span><span style="color: #009900;">&#40;</span>scope, script, <span style="color: #0000ff;">&quot;[&quot;</span> <span style="color: #339933;">+</span> file.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;]&quot;</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">finally</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">Context</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>测试用的script.js文件：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> lang <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> JavaImporter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
lang.<span style="color: #660066;">importPackage</span><span style="color: #009900;">&#40;</span>java.<span style="color: #660066;">lang</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
lang.<span style="color: #660066;">System</span>.<span style="color: #660066;">out</span>.<span style="color: #660066;">println</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Hello, World!~&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> swing <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> JavaImporter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
swing.<span style="color: #660066;">importPackage</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #660066;">swing</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">with</span><span style="color: #009900;">&#40;</span>swing<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> frame <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> JFrame<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Swing Application&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	frame.<span style="color: #660066;">setDefaultCloseOperation</span><span style="color: #009900;">&#40;</span>JFrame.<span style="color: #660066;">EXIT_ON_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> button <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> JButton<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Hello, Rhino!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	button.<span style="color: #660066;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		lang.<span style="color: #660066;">System</span>.<span style="color: #660066;">out</span>.<span style="color: #660066;">println</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;This is a text from swing button&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	frame.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>button<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	frame.<span style="color: #660066;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	frame.<span style="color: #660066;">setResizable</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	frame.<span style="color: #660066;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/rhino-javascript-for-java.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

