<?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>蓝色的华</title>
	<atom:link href="http://bluehua.org/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Wed, 23 Nov 2011 08:43:10 +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>LUPlayer &#8211; mac os下的网络视频播放器</title>
		<link>http://bluehua.org/2011/11/14/1742.html</link>
		<comments>http://bluehua.org/2011/11/14/1742.html#comments</comments>
		<pubDate>Mon, 14 Nov 2011 11:23:53 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[LUPlayer]]></category>
		<category><![CDATA[mac os]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1742</guid>
		<description><![CDATA[周末的时候想写点代码把一个没有完成的想法继续下去，但又不想太无聊，想在youku上找个片看着。这时碰到了个小问题，视频不能弹出，或者即用浏览器插件弹出，应该也不能置顶。于是先解决了一下这个小问题，然后有了这个播放器。播放器使用起来很简单，只要把视频的地址贴到地址栏，然后点播放即可，现在只支持有ipad支持的视频网站（youku，qiyi，sohu，５６都可以)。当然，这还是个非常简陋的播放器，如果不考虑放出来的话，进度条都懒的加了。 有以下优点: 窗口置顶 不用flash，省cpu 没广告 截屏: 下载:LUPlayer_1_0.dmg]]></description>
			<content:encoded><![CDATA[<p>周末的时候想写点代码把一个没有完成的想法继续下去，但又不想太无聊，想在youku上找个片看着。这时碰到了个小问题，视频不能弹出，或者即用浏览器插件弹出，应该也不能置顶。于是先解决了一下这个小问题，然后有了这个播放器。播放器使用起来很简单，只要把视频的地址贴到地址栏，然后点播放即可，现在只支持有ipad支持的视频网站（youku，qiyi，sohu，５６都可以)。当然，这还是个非常简陋的播放器，如果不考虑放出来的话，进度条都懒的加了。</p>
<p>有以下优点:</p>
<ul>
<li>窗口置顶</li>
<li>不用flash，省cpu</li>
<li>没广告</li>
</ul>
<p>截屏:<br />
<a href="http://bluehua.org/wp-content/uploads/2011/11/LUPlayer.jpg"><img src="http://bluehua.org/wp-content/uploads/2011/11/LUPlayer.jpg" alt="" title="LUPlayer" width="428" height="272" class="alignnone size-full wp-image-1743" /></a><br />
<a href="http://bluehua.org/wp-content/uploads/2011/11/LUPlayer2.jpg"><img src="http://bluehua.org/wp-content/uploads/2011/11/LUPlayer2.jpg" alt="" title="LUPlayer2" width="607" height="351" class="alignnone size-full wp-image-1744" /></a></p>
<p>下载:<a href='http://bluehua.org/wp-content/uploads/2011/11/LUPlayer_1_0.dmg_.zip'>LUPlayer_1_0.dmg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/11/14/1742.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>postfix出错一则</title>
		<link>http://bluehua.org/2011/11/05/1734.html</link>
		<comments>http://bluehua.org/2011/11/05/1734.html#comments</comments>
		<pubDate>Sat, 05 Nov 2011 09:12:42 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1734</guid>
		<description><![CDATA[能收到邮件但是发不出去 错误日志如下 Nov 4 20:32:21 localhost postfix/cleanup[4853]: warning: 51CCA2E129: virtual_alias_maps map lookup probl em for xxxx@gmail.com Nov 4 20:33:21 localhost postfix/pickup[4851]: 587A12F5F5: uid=0 from= Nov 4 20:33:21 localhost postfix/cleanup[4853]: warning: connect to mysql server localhost: Can't connec t to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 原因是之前配置了基于mysql的地址映射 virtual_alias_maps = mysql:/etc/postfix/mysql-alias.cf 当一些在chroot环境中运行的postfix组建试图通过/var/run/mysqld/mysqld.sock连接数据库时就报错了，在master.cf里禁用smtp,rewrite,cleanup的chroot即可 smtp inet n - [...]]]></description>
			<content:encoded><![CDATA[<p>能收到邮件但是发不出去</p>
<p>错误日志如下</p>
<pre>
Nov  4 20:32:21 localhost postfix/cleanup[4853]: warning: 51CCA2E129: virtual_alias_maps map lookup probl         em for xxxx@gmail.com
Nov  4 20:33:21 localhost postfix/pickup[4851]: 587A12F5F5: uid=0 from=<root>
Nov  4 20:33:21 localhost postfix/cleanup[4853]: warning: connect to mysql server localhost: Can't connec         t to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
</pre>
<p>原因是之前配置了基于mysql的地址映射</p>
<pre>
virtual_alias_maps = mysql:/etc/postfix/mysql-alias.cf
</pre>
<p>当一些在chroot环境中运行的postfix组建试图通过/var/run/mysqld/mysqld.sock连接数据库时就报错了，在master.cf里禁用smtp,rewrite,cleanup的chroot即可</p>
<pre>
smtp      inet  n       -       n       -       -       smtpd
rewrite   unix  -       -       n       -       -       trivial-rewrite
cleanup   unix  n       -       n       -       0       cleanup
</pre>
<p>#这是一种不安全的fix方法，另一种解决方法是修改my.conf同过3306端口访问mysql，也可以解决问题。</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/11/05/1734.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>打理一下IOS项目中的图片资源</title>
		<link>http://bluehua.org/2011/10/24/1722.html</link>
		<comments>http://bluehua.org/2011/10/24/1722.html#comments</comments>
		<pubDate>Mon, 24 Oct 2011 04:56:59 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1722</guid>
		<description><![CDATA[项目经历过大的变动之后会留下一些不再需要的图片文件，写了一个脚本跑了一下，找到150张未用到的图片，给力~ 下面的脚本使用的时候需要根据自己的项目指定图片目录和代码目录 找出不再需要的图片 #如果没有找包含@&#34;imageName&#34;或@&#34;imageName.png&#34;的.h.m文件,则认为项目里不再需要这个图片 find ./Resources -name &#34;*.png&#34; \ &#124;grep -v @ \ &#124;while read line;do iname=$&#40;basename &#34;$line&#34;&#124;sed -e &#34;s/\.png//&#34;&#41;; &#91; -z &#34;`find ./ \( -name &#34;*.m&#34; -or -name &#34;*.h&#34; \)&#124;xargs grep -E &#34;@\\\&#34;${iname}(\\\.png)?\\\&#34;&#34;`&#34; &#93; &#38;&#38; echo $line &#38;&#38; img2x=&#34;`echo &#34;$line&#34;&#124;sed -e &#34;s/\.png/@2x\.png/&#34;`&#34; &#38;&#38; &#91; -e &#34;$img2x&#34; &#93; &#38;&#38; echo $img2x; done 还有一个用来找出只有单倍或双倍的图片 find ./Resources [...]]]></description>
			<content:encoded><![CDATA[<p>项目经历过大的变动之后会留下一些不再需要的图片文件，写了一个脚本跑了一下，找到150张未用到的图片，给力~</p>
<p>下面的脚本使用的时候需要根据自己的项目指定图片目录和代码目录</p>
<p>找出不再需要的图片</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#如果没有找包含@&quot;imageName&quot;或@&quot;imageName.png&quot;的.h.m文件,则认为项目里不再需要这个图片</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span>Resources <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.png&quot;</span> \
    <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #000000; font-weight: bold;">@</span> \
    <span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line;<span style="color: #000000; font-weight: bold;">do</span> 
    <span style="color: #007800;">iname</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/\.png//&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
    <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`find ./ \( -name &quot;*.m&quot; -or -name &quot;*.h&quot; \)|xargs grep -E &quot;@\\\&quot;${iname}(\\\.png)?\\\&quot;&quot;`</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$line</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">img2x</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`echo &quot;$line&quot;|sed -e &quot;s/\.png/@2x\.png/&quot;`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$img2x</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$img2x</span>;
    <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>还有一个用来找出只有单倍或双倍的图片</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span>Resources <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.png&quot;</span> \
    <span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line;<span style="color: #000000; font-weight: bold;">do</span> 
    <span style="color: #007800;">iname</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/\.png//&quot;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/@2x//&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
    <span style="color: #007800;">dname</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(dirname &quot;$line&quot;)</span>/&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${dname}</span><span style="color: #007800;">${iname}</span>.png&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span> 缺少单倍图片&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${dname}</span><span style="color: #007800;">${iname}</span>@2x.png&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span> 缺少2倍图片&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>直接下载脚本:<a href='http://bluehua.org/wp-content/uploads/2011/10/XcodeImageManageTool.zip'>XcodeImageManageTool.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/10/24/1722.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>bash拼音补齐靠谱版本</title>
		<link>http://bluehua.org/2011/09/28/1705.html</link>
		<comments>http://bluehua.org/2011/09/28/1705.html#comments</comments>
		<pubDate>Wed, 28 Sep 2011 09:11:32 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1705</guid>
		<description><![CDATA[之前玩ubuntu的时候写过一个，功能和代码都较丑，用的拼音库也很烂。正好为项目抓了一个靠谱的拼音库，顺便把这个bash补齐又重新实现了下，Mac上也可以用了～ 项目:http://code.google.com/p/bash-pinyin-completion/ ==特性== * 支持拼音首字母匹配和完全匹配 * 支持多音字匹配 安装 ubuntu 支持10.04,10.10,11.04版本从ppa安装，如果之前安装过那个chs-completion先卸载之。 sudo add-apt-repository ppa:emptyhua/toolbox sudo apt-get update sudo apt-get install bash-pinyin-completion 然后新开一个终端，就可以使用拼音补齐了 Mac OS X 对于mac需要先安装 bash-completion sudo port install bash-completion 然后编辑~/.bash_profile,把下面的代码贴进去 if [ -f /opt/local/etc/bash_completion ]; then . /opt/local/etc/bash_completion fi 下载源码包http://code.google.com/p/bash-pinyin-completion/downloads/list unzip bash-pinyin-completion-xxx.zip cd bash-pinyin* make sudo make install 然后新开一个终端，就可以使用拼音补齐了]]></description>
			<content:encoded><![CDATA[<p>之前玩ubuntu的时候<a href="http://forum.ubuntu.org.cn/viewtopic.php?f=21&#038;t=302712&#038;start=0">写过一个</a>，功能和代码都较丑，用的拼音库也很烂。正好为项目抓了一个靠谱的拼音库，顺便把这个bash补齐又重新实现了下，Mac上也可以用了～</p>
<p>项目:<a href="http://code.google.com/p/bash-pinyin-completion/">http://code.google.com/p/bash-pinyin-completion/</a></p>
<p>==特性==<br />
  * 支持拼音首字母匹配和完全匹配<br />
  * 支持多音字匹配</p>
<h3>安装</h3>
<h4>ubuntu</h4>
<p>支持10.04,10.10,11.04版本从ppa安装，<strong>如果之前安装过那个chs-completion先卸载之</strong>。</p>
<pre>
sudo add-apt-repository ppa:emptyhua/toolbox
sudo apt-get update
sudo apt-get install bash-pinyin-completion
</pre>
<p>然后新开一个终端，就可以使用拼音补齐了</p>
<h4>Mac OS X</h4>
<p>对于mac需要先安装 bash-completion</p>
<pre>
sudo port install bash-completion
</pre>
<p>然后编辑~/.bash_profile,把下面的代码贴进去</p>
<pre>
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
</pre>
<p>下载源码包<a href="http://code.google.com/p/bash-pinyin-completion/downloads/list">http://code.google.com/p/bash-pinyin-completion/downloads/list</a></p>
<pre>
unzip bash-pinyin-completion-xxx.zip
cd bash-pinyin*
make
sudo make install
</pre>
<p>然后新开一个终端，就可以使用拼音补齐了</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/09/28/1705.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>linux中tty设备名的由来</title>
		<link>http://bluehua.org/2011/09/20/1696.html</link>
		<comments>http://bluehua.org/2011/09/20/1696.html#comments</comments>
		<pubDate>Tue, 20 Sep 2011 10:51:19 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[tty]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1696</guid>
		<description><![CDATA[tty是teletypewriter（电传打字机）的简称，电传打字机是一种老式的通信工具，类似于传真，它有一个用于输入的键盘和用于输出接收信息的纸带打印设备。当按下按键后，电传机会把对应的键码编码成电流脉冲发送给接收方。对方收到脉冲后解码，并将对应的字符打印到纸带上。 早期的一些计算机便使用电传机来做输入输出设备。用户通过电传机向计算机输入指令，并通过纸带打印计算机的反馈结果,这便是最原始的command line interface(命令行交互)。 unix系统会为所有设备在/dev目录下生成对应的文件，电传机便被命名为/dev/tty#(#代表数字序号)。虽然现在的计算机早已经不再使用电传机做IO设备，但是tty的命名依然沿用至今。 links: http://www.linfo.org/teletype.html http://baike.baidu.com/view/1773688.htm]]></description>
			<content:encoded><![CDATA[<p>tty是teletypewriter（电传打字机）的简称，电传打字机是一种老式的通信工具，类似于传真，它有一个用于输入的键盘和用于输出接收信息的纸带打印设备。当按下按键后，电传机会把对应的键码编码成电流脉冲发送给接收方。对方收到脉冲后解码，并将对应的字符打印到纸带上。</p>
<p><a href="http://bluehua.org/wp-content/uploads/2011/09/电传打字机.jpg"><img class="alignnone size-full wp-image-1701" title="电传打字机" src="http://bluehua.org/wp-content/uploads/2011/09/电传打字机.jpg" alt="" width="200" height="150" /></a></p>
<p>早期的一些计算机便使用电传机来做输入输出设备。用户通过电传机向计算机输入指令，并通过纸带打印计算机的反馈结果,这便是最原始的command line interface(命令行交互)。</p>
<p>unix系统会为所有设备在/dev目录下生成对应的文件，电传机便被命名为/dev/tty#(#代表数字序号)。虽然现在的计算机早已经不再使用电传机做IO设备，但是tty的命名依然沿用至今。</p>
<p>links:<br />
<a href="http://www.linfo.org/teletype.html">http://www.linfo.org/teletype.html</a><br />
<a href="http://baike.baidu.com/view/1773688.htm">http://baike.baidu.com/view/1773688.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/09/20/1696.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用phantomjs抓取ITC和android market的安装统计数据</title>
		<link>http://bluehua.org/2011/09/14/1682.html</link>
		<comments>http://bluehua.org/2011/09/14/1682.html#comments</comments>
		<pubDate>Wed, 14 Sep 2011 06:57:44 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[phantomjs]]></category>
		<category><![CDATA[pyqt4]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1682</guid>
		<description><![CDATA[同事用python抓各大andriod市场的页面分析软件下载量，发现andriod　market的数据是通过ajax加载的，而且貌似加密过了，没法直接解析。后来俺发现了phantomjs这个命令行的webkit,在可以在命令行渲染网页，这样不论数据怎么加载，怎么加密，对于标准的浏览器都无能为力了。软件的原理跟以前介绍的一个命令行web截图工具一样,内嵌一个qt4的webkit，然后渲染到xvfb虚拟出的xserver上。不同是这个提供了js的api，用起来方便，可以用来做爬虫，站点监控，服务端截图。 使用方法： 第一步,安装phantomjs Mac os &#038; windows: 直接下载.dmg或.exe安装包即可:http://code.google.com/p/phantomjs/downloads/list mac下安装完闭，可执行文件的路径:/Applications/phantomjs.app/Contents/MacOS/phantomjs ubuntu: sudo add-apt-repository ppa:jerome-etienne/neoip sudo apt-get update sudo apt-get install phantomjs centos 5.3: 折腾开始了。。由于phantomjs的linux版本是通过pyqt4实现的，所以装起来比较麻烦 首先我们需要安装qt4.7.而yum默认安装的是4.1 rpm -ivh http://software.freivald.com/centos/software.freivald.com-1.0.0-1.noarch.rpm yum update fontconfig fontconfig-devel yum install qt4 qt4-devel #如果已经安装过qt4则执行 yum update qt4 qt4-devel 安装Xvfb yum install xorg-x11-server-Xvfb xorg-x11-server-Xorg xorg-x11-fonts* 安装python 2.7,自带的为2.4，没法用 wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2 tar jxvf Python-2.7.2.tar.bz2 cd Python-2.7.2 [...]]]></description>
			<content:encoded><![CDATA[<p>同事用python抓各大andriod市场的页面分析软件下载量，发现andriod　market的数据是通过ajax加载的，而且貌似加密过了，没法直接解析。后来俺发现了phantomjs这个命令行的webkit,在可以在命令行渲染网页，这样不论数据怎么加载，怎么加密，对于标准的浏览器都无能为力了。软件的原理跟以前介绍的一个<a href="http://bluehua.org/2010/07/23/1397.html">命令行web截图工具</a>一样,内嵌一个qt4的webkit，然后渲染到xvfb虚拟出的xserver上。不同是这个提供了js的api，用起来方便，可以用来做爬虫，站点监控，服务端截图。</p>
<p>使用方法：<br />
第一步,安装phantomjs<br />
Mac os &#038; windows:<br />
直接下载.dmg或.exe安装包即可:<a href="http://code.google.com/p/phantomjs/downloads/list">http://code.google.com/p/phantomjs/downloads/list</a><br />
mac下安装完闭，可执行文件的路径:/Applications/phantomjs.app/Contents/MacOS/phantomjs<br />
ubuntu:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> add-apt-repository ppa:jerome-etienne<span style="color: #000000; font-weight: bold;">/</span>neoip
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> phantomjs</pre></div></div>

<p>centos 5.3:<br />
折腾开始了。。由于phantomjs的linux版本是通过pyqt4实现的，所以装起来比较麻烦<br />
首先我们需要安装qt4.7.而yum默认安装的是4.1</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-ivh</span> http:<span style="color: #000000; font-weight: bold;">//</span>software.freivald.com<span style="color: #000000; font-weight: bold;">/</span>centos<span style="color: #000000; font-weight: bold;">/</span>software.freivald.com-1.0.0-1.noarch.rpm
yum update fontconfig fontconfig-devel
yum <span style="color: #c20cb9; font-weight: bold;">install</span> qt4 qt4-devel
<span style="color: #666666; font-style: italic;">#如果已经安装过qt4则执行 yum update qt4 qt4-devel</span></pre></div></div>

<p>安装Xvfb</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> xorg-x11-server-Xvfb xorg-x11-server-Xorg xorg-x11-fonts<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>安装python 2.7,自带的为2.4，没法用</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>python.org<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>python<span style="color: #000000; font-weight: bold;">/</span>2.7.2<span style="color: #000000; font-weight: bold;">/</span>Python-2.7.2.tar.bz2
<span style="color: #c20cb9; font-weight: bold;">tar</span> jxvf Python-2.7.2.tar.bz2
<span style="color: #7a0874; font-weight: bold;">cd</span> Python-2.7.2
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..</pre></div></div>

<p>安装setup tools</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>pypi.python.org<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>s<span style="color: #000000; font-weight: bold;">/</span>setuptools<span style="color: #000000; font-weight: bold;">/</span>setuptools-0.6c11.tar.gz<span style="color: #666666; font-style: italic;">#md5=7df2a529a074f613b509fb44feefe74e</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf setuptools-0.6c11.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> setuptools-0.6c11
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..</pre></div></div>

<p>安装sip</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.riverbankcomputing.com<span style="color: #000000; font-weight: bold;">/</span>static<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>sip4<span style="color: #000000; font-weight: bold;">/</span>sip-4.12.4.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf sip-4.12.4.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> sip-4.12.4
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python configure.py
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..</pre></div></div>

<p>安装pyqt4</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.riverbankcomputing.com<span style="color: #000000; font-weight: bold;">/</span>static<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>PyQt4<span style="color: #000000; font-weight: bold;">/</span>PyQt-x11-gpl-4.8.5.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf PyQt-x11-gpl-4.8.5.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> PyQt-x11-gpl-4.8.5
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python configure.py <span style="color: #660033;">-q</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>qt4<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>qmake
<span style="color: #666666; font-style: italic;">#对于64位系统</span>
<span style="color: #666666; font-style: italic;">#/opt/python27/bin/python configure.py -q /usr/lib64/qt4/bin/qmake</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> 
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..</pre></div></div>

<p>最后安装pyphantomjs</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> pyphantomjs
<span style="color: #7a0874; font-weight: bold;">cd</span> pyphantomjs
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>phantomjs.googlecode.com<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>pyphantomjs-1.2.0-source.zip
<span style="color: #c20cb9; font-weight: bold;">unzip</span> pyphantomjs-1.2.0-source.zip
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>折腾到这里，pyphantomjs已经安装到了/opt/python27/bin/pyphantomjs<br />
直接执行/opt/python27/bin/pyphantomjs &#8211;help,会发现报错</p>
<pre>
sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1
</pre>
<p>解决方法<br />
编辑/opt/python27/bin/pyphantomjs,在开始追加几句</p>

<div class="wp_syntax"><div class="code overflow"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/opt/python27/bin/python</span>
<span style="color: #808080; font-style: italic;"># EASY-INSTALL-ENTRY-SCRIPT: 'PyPhantomJS==1.2.0','console_scripts','pyphantomjs'</span>
<span style="color: #808080; font-style: italic;">#fix start</span>
<span style="color: #ff7700;font-weight:bold;">import</span> sip
sip.<span style="color: black;">setapi</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'QString'</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
sip.<span style="color: black;">setapi</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'QVariant'</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;">#fix end</span>
__requires__ = <span style="color: #483d8b;">'PyPhantomJS==1.2.0'</span></pre></div></div>

<p>第二步：<br />
下载我们用来解析数据的js脚本:<a href='http://bluehua.org/wp-content/uploads/2011/09/android_itc_daliy_report.zip'>android_itc_daliy_report</a></p>
<p>修改里面的变量:</p>
<pre>
TIMEOUT = 120;//脚本执行超时时间
ACCOUNT = '';//登陆账号
PASSWORD = '';//密码
</pre>
<p>第三步:执行抓取脚本<br />
对于Mac os:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#抓取andriod market的安装总量</span>
<span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>phantomjs.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>phantomjs <span style="color: #660033;">--load-images</span>=no AndroidMarketDailyReport.js
<span style="color: #666666; font-style: italic;">#抓取ITC的每天的安装量,需要制定日期，而且日期必须是web页面里的日期选择框里有的日期</span>
<span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>phantomjs.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>phantomjs <span style="color: #660033;">--load-images</span>=no ITCDailyReport.js 09<span style="color: #000000; font-weight: bold;">/</span>06<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2011</span></pre></div></div>

<p>对于Centos:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#首先保证Xvfb已经启动</span>
Xvfb :<span style="color: #000000;">0</span> <span style="color: #660033;">-screen</span> <span style="color: #000000;">0</span> 1024x768x24 <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #666666; font-style: italic;">#抓取andriod market的安装量</span>
<span style="color: #007800;">DISPLAY</span>=:<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pyphantomjs <span style="color: #660033;">--load-images</span>=no <span style="color: #660033;">--ignore-ssl-errors</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span> AndroidMarketDailyReport.js
<span style="color: #666666; font-style: italic;">#抓取ITC的每天的安装量,需要制定日期，而且日期必须是web页面里的日期选择框里有的日期</span>
<span style="color: #007800;">DISPLAY</span>=:<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python27<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pyphantomjs <span style="color: #660033;">--load-images</span>=no <span style="color: #660033;">--ignore-ssl-errors</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span> ITCDailyReport.js 09<span style="color: #000000; font-weight: bold;">/</span>06<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2011</span></pre></div></div>

<p>获取输出结果,以Mac os为例:</p>
<p>/Applications/phantomjs.app/Contents/MacOS/phantomjs &#8211;load-images=no ITCDailyReport.js 09/06/2011|grep REPORT<br />
REPORT:	soft_name	0000<br />
REPORT:	soft_name	0000</p>
<p>/Applications/phantomjs.app/Contents/MacOS/phantomjs &#8211;load-images=no AndroidMarketDailyReport.js |grep REPORT<br />
REPORT:	total	0000<br />
REPORT:	real	0000</p>
<p>如果没有输出结果，则说明有异常，账号错误，超时，等等。。</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/09/14/1682.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lua&amp;ios dev</title>
		<link>http://bluehua.org/2011/08/13/1674.html</link>
		<comments>http://bluehua.org/2011/08/13/1674.html#comments</comments>
		<pubDate>Sat, 13 Aug 2011 06:49:31 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[lua]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1674</guid>
		<description><![CDATA[又一个与同事分享的ppt，关于lua的一点皮毛，满足大家的好奇心。关于lua本身，我也只能分享这点皮毛了。合适的地方用合适的语言，如此而已。 Lua&#38;ios dev View more presentations from emptyhua]]></description>
			<content:encoded><![CDATA[<p>又一个与同事分享的ppt，关于lua的一点皮毛，满足大家的好奇心。关于lua本身，我也只能分享这点皮毛了。合适的地方用合适的语言，如此而已。</p>
<div style="width:425px" id="__ss_8841041"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/emptyhua/luaios-dev" title="Lua&amp;ios dev" target="_blank">Lua&amp;ios dev</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8841041" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/" target="_blank">presentations</a> from <a href="http://www.slideshare.net/emptyhua" target="_blank">emptyhua</a> </div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/08/13/1674.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello lua</title>
		<link>http://bluehua.org/2011/06/23/1650.html</link>
		<comments>http://bluehua.org/2011/06/23/1650.html#comments</comments>
		<pubDate>Thu, 23 Jun 2011 13:31:33 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1650</guid>
		<description><![CDATA[lua将作为下一门新语言学习。如果按照一年学习一门新语言的标准来说，我算超勤快的了。lua被发明的目的便是嵌入C或C++程序，给程序带来编译语言不及的灵活性。 google了一下lua，发现大部分都是做游戏开发的C++程序员的文章，看来不只是魔兽世界在用。 lua做嵌入的优势： 1 . 小，整个解释器不到200K 实际测试: 编译一个空的IOS项目 205K 嵌入Lua后的IOS项目 414K 2 . 运行速度快 实际测试: 做了三个测试程序，分别内嵌lua(静态链接)，javascript(动态链接JavascriptCore,链接库6.4M),python(动态链接python2.6,链接库2.0M) 三个程序都做相同的事情，初始化一个脚本运行环境，打印一个字符串，销毁 比如lua,其他JS和python类似，只不过调用的api不一样: static int lua_printf&#40;lua_State *L&#41; &#123; const char *cmsg = luaL_checkstring&#40;L, 1&#41;; printf&#40;&#34;%s\n&#34;, cmsg&#41;; return 0; &#125; &#160; static void eval_lua&#40;NSString *code&#41; &#123; lua_State *L; L = lua_open&#40;&#41;; luaopen_base&#40;L&#41;; lua_register&#40;L, &#34;printf&#34;, lua_printf&#41;; luaL_loadstring&#40;L, &#91;code cStringUsingEncoding:NSUTF8StringEncoding&#93;&#41;; lua_pcall&#40;L, 0, LUA_MULTRET, [...]]]></description>
			<content:encoded><![CDATA[<p>lua将作为下一门新语言学习。如果按照一年学习一门新语言的标准来说，我算超勤快的了。lua被发明的目的便是嵌入C或C++程序，给程序带来编译语言不及的灵活性。<br />
google了一下lua，发现大部分都是做游戏开发的C++程序员的文章，看来不只是魔兽世界在用。</p>
<p>lua做嵌入的优势：<br />
1 . 小，整个解释器不到200K<br />
实际测试:<br />
编译一个空的IOS项目 205K<br />
嵌入Lua后的IOS项目 414K<br />
2 . 运行速度快<br />
实际测试:<br />
做了三个测试程序，分别内嵌lua(静态链接)，javascript(动态链接JavascriptCore,链接库6.4M),python(动态链接python2.6,链接库2.0M)<br />
三个程序都做相同的事情，初始化一个脚本运行环境，打印一个字符串，销毁<br />
比如lua,其他JS和python类似，只不过调用的api不一样:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">static</span> <span style="color: #a61390;">int</span> lua_printf<span style="color: #002200;">&#40;</span>lua_State <span style="color: #002200;">*</span>L<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">const</span> <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>cmsg <span style="color: #002200;">=</span> luaL_checkstring<span style="color: #002200;">&#40;</span>L, <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">printf</span><span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;%s<span style="color: #2400d9;">\n</span>&quot;</span>, cmsg<span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">static</span> <span style="color: #a61390;">void</span> eval_lua<span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>code<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
    lua_State <span style="color: #002200;">*</span>L;
    L <span style="color: #002200;">=</span> lua_open<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
    luaopen_base<span style="color: #002200;">&#40;</span>L<span style="color: #002200;">&#41;</span>;
    lua_register<span style="color: #002200;">&#40;</span>L, <span style="color: #bf1d1a;">&quot;printf&quot;</span>, lua_printf<span style="color: #002200;">&#41;</span>;
    luaL_loadstring<span style="color: #002200;">&#40;</span>L, <span style="color: #002200;">&#91;</span>code cStringUsingEncoding<span style="color: #002200;">:</span>NSUTF8StringEncoding<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
    lua_pcall<span style="color: #002200;">&#40;</span>L, <span style="color: #2400d9;">0</span>, LUA_MULTRET, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;
    lua_close<span style="color: #002200;">&#40;</span>L<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">int</span> main <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> argc, <span style="color: #a61390;">const</span> <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span> argv<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
    <span style="color: #400080;">NSAutoreleasePool</span> <span style="color: #002200;">*</span>pool <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSAutoreleasePool</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
    NSTimeInterval start <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDate</span> timeIntervalSinceReferenceDate<span style="color: #002200;">&#93;</span>;
    eval_lua<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;printf(<span style="color: #2400d9;">\&quot;</span>你好 lua<span style="color: #2400d9;">\&quot;</span>)&quot;</span><span style="color: #002200;">&#41;</span>;
    NSTimeInterval duration <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDate</span> timeIntervalSinceReferenceDate<span style="color: #002200;">&#93;</span> <span style="color: #002200;">-</span> start;
    <span style="color: #a61390;">printf</span><span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;total time:%.5f<span style="color: #2400d9;">\n</span>&quot;</span>, duration<span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span>pool release<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>PK结果</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> <span style="color: #000000; font-weight: bold;">*</span>_test
<span style="color: #660033;">-rwxr-xr-x</span>  <span style="color: #000000;">1</span> hualu  staff    10K  <span style="color: #000000;">6</span> <span style="color: #000000;">23</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">32</span> js_test
<span style="color: #660033;">-rwxr-xr-x</span>  <span style="color: #000000;">1</span> hualu  staff   136K  <span style="color: #000000;">6</span> <span style="color: #000000;">23</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">37</span> lua_test
<span style="color: #660033;">-rwxr-xr-x</span>  <span style="color: #000000;">1</span> hualu  staff   9.4K  <span style="color: #000000;">6</span> <span style="color: #000000;">23</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">32</span> py_test
$ .<span style="color: #000000; font-weight: bold;">/</span>lua_test
你好 lua
total <span style="color: #000000; font-weight: bold;">time</span>:<span style="color: #000000;">0.00018</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>js_test
你好 Javascript
total <span style="color: #000000; font-weight: bold;">time</span>:<span style="color: #000000;">0.00557</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>py_test
你好 Python
total <span style="color: #000000; font-weight: bold;">time</span>:<span style="color: #000000;">0.01311</span></pre></div></div>

<p>3.  lua支持多线程，每个线程可以配置独立的解释器（没有亲测，道听途说)<br />
4. 语法简单，其实这个可以算优点，比JS要简单易懂的多。。。</p>
<p>lua这么小巧的身躯太适合嵌入手机软件了。可以动态的从server上加载一些lua脚本来运行，免去劳烦用户更新软件的烦恼～.就目前所知，愤怒的小鸟是一个混合编程的好例子，关卡的设置均由lua控制。</p>
<p>其实已经有geek为前面三门语言做了Objc的Bridge，项目分别是:<br />
对于lua有<a href="https://github.com/beetlebugorg/wax">wax</a><br />
对于js有<a href="http://code.google.com/p/jscocoa/">jscocoa</a><br />
对于python有<a href="http://pyobjc.sourceforge.net/documentation/index.html">PyObjc</a></p>
<p>而且他们的目的已经不是简单的嵌入Objectivc了，而是代替objc作为MAC或IOS应用的开发语言。。。当然我并不是很赞同这种偷懒的方法，脚本要适度使用。</p>
<p>最后，看的一些资料:<br />
<a href="http://www.codingnow.com/2000/download/lua_manual.html">Lua 5.1 参考手册</a><br />
<a href="http://www.grzmobile.com/blog/2009/11/13/integrating-lua-into-an-iphone-app.html">xcode中添加静态链接库</a><br />
<a href="http://bbs.luaer.cn/read-Lua-tid-83-fpage-2.html">lua和python谁更适用于嵌入MMORPG？</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/06/23/1650.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>three20的TTURLRequest的两点</title>
		<link>http://bluehua.org/2011/06/20/1643.html</link>
		<comments>http://bluehua.org/2011/06/20/1643.html#comments</comments>
		<pubDate>Mon, 20 Jun 2011 03:57:24 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[three20]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1643</guid>
		<description><![CDATA[1. 即使发异步请求，请求也不是并发的，而是通过TTURLRequestQueue排队顺序完成。 2. view在滚动，或者使用特效切换view时会暂停掉TTURLRequestQueue - &#40;void&#41;scrollViewWillBeginDragging:&#40;UIScrollView *&#41;scrollView &#123; //开始拖拽滚屏的时候暂停请求 //这揍是为啥拖动的时候TTImageView都不会加载的原因 &#91;TTURLRequestQueue mainQueue&#93;.suspended = YES; &#160; &#91;_controller didBeginDragging&#93;; &#160; if &#40;&#91;scrollView isKindOfClass:&#91;TTTableView class&#93;&#93;&#41; &#123; TTTableView* tableView = &#40;TTTableView*&#41;scrollView; tableView.highlightedLabel.highlightedNode = nil; tableView.highlightedLabel = nil; &#125; &#125;]]></description>
			<content:encoded><![CDATA[<p>1. 即使发异步请求，请求也不是并发的，而是通过TTURLRequestQueue排队顺序完成。</p>
<p>2. view在滚动，或者使用特效切换view时会暂停掉TTURLRequestQueue</p>

<div class="wp_syntax"><div class="code overflow"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>scrollViewWillBeginDragging<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIScrollView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>scrollView <span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">//开始拖拽滚屏的时候暂停请求</span>
  <span style="color: #11740a; font-style: italic;">//这揍是为啥拖动的时候TTImageView都不会加载的原因</span>
  <span style="color: #002200;">&#91;</span>TTURLRequestQueue mainQueue<span style="color: #002200;">&#93;</span>.suspended <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
&nbsp;
  <span style="color: #002200;">&#91;</span>_controller didBeginDragging<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>scrollView isKindOfClass<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>TTTableView class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
      TTTableView<span style="color: #002200;">*</span> tableView <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>TTTableView<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>scrollView;
      tableView.highlightedLabel.highlightedNode <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
      tableView.highlightedLabel <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
    <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/06/20/1643.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个未成形的富文本编辑器</title>
		<link>http://bluehua.org/2011/06/18/1642.html</link>
		<comments>http://bluehua.org/2011/06/18/1642.html#comments</comments>
		<pubDate>Sat, 18 Jun 2011 15:22:11 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://bluehua.org/2011/06/18/1642.html</guid>
		<description><![CDATA[作为一个IOS开发者，我决定贡献一点html代码。。。 最近打算用html+js做一个简单的富文本编辑器给IOS和andriod客户端用，不用任何第三方的框架，简简单单，一个纯洁的编辑器。 写的差不多有点样子，便拿到模拟器上试试，结果悲剧了：IOS上的safari是个太监，根本不支持contentEditable这个东西。 把写半截的代码贡献出来，safari和chrome可以用，对想了解富文本编辑器的同学绝对有帮助。 http://bluehua.org/demo/mobile_editor.html &#8212;&#8212;&#8212;&#8211; vim->email->wordpress]]></description>
			<content:encoded><![CDATA[<p><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">作为一个IOS开发者，我决定贡献一点html代码。。。
<div></div>
<div>最近打算用html+js做一个简单的富文本编辑器给IOS和andriod客户端用，不用任何第三方的框架，简简单单，一个纯洁的编辑器。</div>
<div>写的差不多有点样子，便拿到模拟器上试试，结果悲剧了：IOS上的safari是个太监，根本不支持contentEditable这个东西。</div>
<div></div>
<div>把写半截的代码贡献出来，safari和chrome可以用，对想了解富文本编辑器的同学绝对有帮助。</div>
<div></div>
<div><a href="http://bluehua.org/demo/mobile_editor.html">http://bluehua.org/demo/mobile_editor.html</a></div>
<p></body><br />
&#8212;&#8212;&#8212;&#8211;<br />
vim->email->wordpress</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/06/18/1642.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.965 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-04 16:25:52 -->

