<?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>蓝色的华 &#187; python</title>
	<atom:link href="http://bluehua.org/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Fri, 27 Aug 2010 08:41:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>找到Flash Media Server的替代品~</title>
		<link>http://bluehua.org/2010/08/08/1412.html</link>
		<comments>http://bluehua.org/2010/08/08/1412.html#comments</comments>
		<pubDate>Sun, 08 Aug 2010 00:48:10 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[soft]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[FMS]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[record]]></category>
		<category><![CDATA[rtmp]]></category>
		<category><![CDATA[rtmplite]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/08/08/1412.html</guid>
		<description><![CDATA[很早之前就想实现一个在线录音的功能，无奈一直没有找到FMS的替代品。以前用&#8221;flash 录音&#8221;两个关键词，结果大多是FMS实现，还有个开源的Red5，java实现的，还是算了，vps上跑java。。偶尔换了个高级点的关键词&#8221;python rtmp&#8221;立刻找到我想要的:http://code.google.com/p/rtmplite/ 。rtmplite实现了一个简单的RTMP server,而且只用了3个python文件，(Red5都有三十几兆。。)

ls -lh amf.py multitask.py rtmp.py 
-rwxr-xr-x 1 lu lu 17K 2010-07-30 12:31 amf.py
-rwxr-xr-x 1 lu lu 41K 2010-06-29 07:28 multitask.py
-rwxr-xr-x 1 lu lu 51K 2010-07-30 09:42 rtmp.py

实现的在线录音功能:http://v.hua.lu
&#8212;&#8212;&#8212;&#8211;
post by gmail~
]]></description>
			<content:encoded><![CDATA[<p>很早之前就想实现一个在线录音的功能，无奈一直没有找到FMS的替代品。以前用&#8221;flash 录音&#8221;两个关键词，结果大多是FMS实现，还有个开源的Red5，java实现的，还是算了，vps上跑java。。偶尔换了个高级点的关键词&#8221;python rtmp&#8221;立刻找到我想要的:<a href="http://code.google.com/p/rtmplite/">http://code.google.com/p/rtmplite/</a> 。rtmplite实现了一个简单的RTMP server,而且只用了3个python文件，(Red5都有三十几兆。。)</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> amf.py multitask.py rtmp.py 
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> lu lu 17K <span style="color: #000000;">2010</span>-07-<span style="color: #000000;">30</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">31</span> amf.py
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> lu lu 41K <span style="color: #000000;">2010</span>-06-<span style="color: #000000;">29</span> 07:<span style="color: #000000;">28</span> multitask.py
<span style="color: #660033;">-rwxr-xr-x</span> <span style="color: #000000;">1</span> lu lu 51K <span style="color: #000000;">2010</span>-07-<span style="color: #000000;">30</span> 09:<span style="color: #000000;">42</span> rtmp.py</pre></div></div>

<p>实现的在线录音功能:<a href="http://v.hua.lu">http://v.hua.lu</a></p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/08/08/1412.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>相对完美的设计思路~</title>
		<link>http://bluehua.org/2010/07/22/1394.html</link>
		<comments>http://bluehua.org/2010/07/22/1394.html#comments</comments>
		<pubDate>Wed, 21 Jul 2010 16:27:31 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[all in one]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web.py]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/07/22/1394.html</guid>
		<description><![CDATA[有没有可能写一套代码适应以下三种情况:
1. 客户端没有开启javascript，或者使用ucweb一类的弱智浏览器访问时，功能没有影响
2. 客户端开启了javascript，每个页面都有单独加载的js,但是禁用ajax,只帮助用户交互
3. 客户端开启了javascript，为了提高载入速度，尽量使所有操作用ajax完成
略有所得: http://www.blogo2.com
源代码: http://code-of-emptyhua.googlecode.com/svn/trunk/blogo2
没有禁用js的时候，页面切换，表单提交（注册和登录没有用）尽量的使用ajax，而且部分操作会使用弹层(登录后的管理),禁用js之后，则所有操作换成普通表单提交在页面之间跳来跳去。。
还有一个功能没有开启，就是可以选择不用ajax，但是独立开的页面js依然有效。
有兴趣的同学可以check源代码，这种模式的实现:
1. 开发的时候禁用ajax，单个页面开发，而且要求禁用js时业务可以走通，页面内的js和css统一由模板引入。
2. 对需要开启ajax的链接增加hook，例如data-ajax=&#8221;dialog:{}&#8221;,则表明在开启ajax模式后，点击这个链接需要弹窗
3. ajax模式下只需要对单个页面更换特有的模板，动态加载需要的js和css即可。
这种设计的特点:
1. 尽量一个人包前后端。。
2. json不潮了，ajax返回html代码，优点是js不用套页面了，缺点是流量大
over，虽然没有完美的代码，但是我尽量~
&#8212;&#8212;&#8212;&#8211;
post by gmail~
]]></description>
			<content:encoded><![CDATA[<p>有没有可能写一套代码适应以下三种情况:<br />
1. 客户端没有开启javascript，或者使用ucweb一类的弱智浏览器访问时，功能没有影响<br />
2. 客户端开启了javascript，每个页面都有单独加载的js,但是禁用ajax,只帮助用户交互<br />
3. 客户端开启了javascript，为了提高载入速度，尽量使所有操作用ajax完成</p>
<p>略有所得: <a href="http://www.blogo2.com">http://www.blogo2.com</a><br />
源代码: <a href="http://code-of-emptyhua.googlecode.com/svn/trunk/blogo2">http://code-of-emptyhua.googlecode.com/svn/trunk/blogo2</a></p>
<p>没有禁用js的时候，页面切换，表单提交（注册和登录没有用）尽量的使用ajax，而且部分操作会使用弹层(登录后的管理),禁用js之后，则所有操作换成普通表单提交在页面之间跳来跳去。。</p>
<p>还有一个功能没有开启，就是可以选择不用ajax，但是独立开的页面js依然有效。</p>
<p>有兴趣的同学可以check源代码，这种模式的实现:<br />
1. 开发的时候禁用ajax，单个页面开发，而且要求禁用js时业务可以走通，页面内的js和css统一由模板引入。<br />
2. 对需要开启ajax的链接增加hook，例如data-ajax=&#8221;dialog:{}&#8221;,则表明在开启ajax模式后，点击这个链接需要弹窗<br />
3. ajax模式下只需要对单个页面更换特有的模板，动态加载需要的js和css即可。</p>
<p>这种设计的特点:<br />
1. 尽量一个人包前后端。。<br />
2. json不潮了，ajax返回html代码，优点是js不用套页面了，缺点是流量大</p>
<p>over，虽然没有完美的代码，但是我尽量~</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/07/22/1394.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个支持url变量的压力测试工具pywebbench</title>
		<link>http://bluehua.org/2010/07/13/1347.html</link>
		<comments>http://bluehua.org/2010/07/13/1347.html#comments</comments>
		<pubDate>Tue, 13 Jul 2010 15:09:39 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[soft]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pywebbench]]></category>
		<category><![CDATA[webbench]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1347</guid>
		<description><![CDATA[可能是我的本子配置不行,服务器上连接数可以上1000

./pywebbench.py -c 1000 -t 10 http://172.16.0.38/test.php
&#160;
1000 clients, running 10 sec, timeout setting 2.
Requests: 7387 total ,7385 susceed, average 99%.
2 fail:
timeout:1
connect refused:1
not 2xx status:0

&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
2010.7.14更新 可以输出更多信息，svn版本7

100 clients, running 10 sec, timeout setting 2.
Requests: 1361 total ,1027 susceed, average 75%.
334 fail:
timeout:254
connect refused:80
not 2xx status:0

&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
测试需要，特别是测试缓存，逮住一个url压没什么用，所以写了一个pywebbench满足需求

#url中的id会顺序变化
pywebbench.py -c 100 -t 10 http://test.com/xx.php?id=&#123;10000,12000000&#125;
#url中的id随机变化
pywebbench.py -c 100 -t 10 http://test.com/xx.php?id=&#123;10000,12000000#random}

实际数据

#这是pywebbench跑的数据,curl这么牛逼吗，远远把webbench落在后面。。。
$python ~/bin/pywebbench.py -c 300 -t [...]]]></description>
			<content:encoded><![CDATA[<p>可能是我的本子配置不行,服务器上连接数可以上1000</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">./pywebbench.py -c 1000 -t 10 http://172.16.0.38/test.php
&nbsp;
1000 clients, running 10 sec, timeout setting 2.
Requests: 7387 total ,7385 susceed, average 99%.
2 fail:
timeout:1
connect refused:1
not 2xx status:0</pre></div></div>

<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
2010.7.14更新 可以输出更多信息，svn版本7</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">100 clients, running 10 sec, timeout setting 2.
Requests: 1361 total ,1027 susceed, average 75%.
334 fail:
timeout:254
connect refused:80
not 2xx status:0</pre></div></div>

<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
测试需要，特别是测试缓存，逮住一个url压没什么用，所以写了一个pywebbench满足需求</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#url中的id会顺序变化</span>
pywebbench.py <span style="color: #660033;">-c</span> <span style="color: #000000;">100</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">10</span> http:<span style="color: #000000; font-weight: bold;">//</span>test.com<span style="color: #000000; font-weight: bold;">/</span>xx.php?<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">id</span></span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">10000</span>,<span style="color: #000000;">12000000</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#url中的id随机变化</span>
pywebbench.py <span style="color: #660033;">-c</span> <span style="color: #000000;">100</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">10</span> http:<span style="color: #000000; font-weight: bold;">//</span>test.com<span style="color: #000000; font-weight: bold;">/</span>xx.php?<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">id</span></span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">10000</span>,<span style="color: #000000;">12000000</span><span style="color: #666666; font-style: italic;">#random}</span></pre></div></div>

<p>实际数据</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">#这是pywebbench跑的数据,curl这么牛逼吗，远远把webbench落在后面。。。
$python ~/bin/pywebbench.py -c 300 -t 10 http://localhost/
&nbsp;
300 clients, running 10 sec.
Requests: 20430 total 19318 susceed, 1112 failed.
&nbsp;
#这是webbench跑的数据
$webbench -c 300 -t 10 http://localhost/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
&nbsp;
Benchmarking: GET http://localhost/
300 clients, running 10 sec.
&nbsp;
Speed=56964 pages/min, 3997446 bytes/sec.
Requests: 9494 susceed, 0 failed.</pre></div></div>

<p>已知问题:<br />
python的线程貌似开不多，-c 500 开不了。。</p>
<p>下载:<br />
<a href="http://code-of-emptyhua.googlecode.com/svn/trunk/pywebbench.py">http://code-of-emptyhua.googlecode.com/svn/trunk/pywebbench.py</a><br />
需要安装pycurl:sudo apt-get install python-pycurl</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/07/13/1347.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>terminal里看农历的东西</title>
		<link>http://bluehua.org/2010/05/03/1170.html</link>
		<comments>http://bluehua.org/2010/05/03/1170.html#comments</comments>
		<pubDate>Mon, 03 May 2010 13:14:05 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[liblunar]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[农历]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1170</guid>
		<description><![CDATA[曾经装了一个 liblunar ,用来在gnome panel里显示农历日历，今天升级到10.04，发现不灵了。由于liblunar提供了python的lib，于是简单写了一个命令行版的前端，顺便保持对python的熟悉程度。最近接触的语言有点杂，码代码时经常会搞混。。。

下载：zhcal.zip
使用之前需要安装liblunar,编译选项

./configure --prefix=/usr --enable-python
make
sudo make install

&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
另：分享一个firefox插件default full zoom level, 可以设置页面的默认缩放级别，对于高分屏的同学会有帮助～
现在终端的字体我已经调到16，浏览器默认缩放120%，基本上回到1024时代~ 
]]></description>
			<content:encoded><![CDATA[<p>曾经装了一个<a href="http://code.google.com/p/liblunar/"> liblunar</a> ,用来在gnome panel里显示农历日历，今天升级到10.04，发现不灵了。由于liblunar提供了python的lib，于是简单写了一个命令行版的前端，顺便保持对python的熟悉程度。最近接触的语言有点杂，码代码时经常会搞混。。。</p>
<p><a href="http://bluehua.org/wp-content/uploads/2010/05/_001.png"><img src="http://bluehua.org/wp-content/uploads/2010/05/截取选区_001.png" alt="" title="zhcal" width="693" height="469" class="alignnone size-full wp-image-1171" /></a></p>
<p>下载：<a href='http://bluehua.org/wp-content/uploads/2010/05/zhcal.zip'>zhcal.zip</a></p>
<p>使用之前需要安装liblunar,编译选项</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--enable-python</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
另：分享一个firefox插件<a href="https://addons.mozilla.org/zh-CN/firefox/addon/6965">default full zoom level</a>, 可以设置页面的默认缩放级别，对于高分屏的同学会有帮助～<br />
现在终端的字体我已经调到16，浏览器默认缩放120%，基本上回到1024时代~ </p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/05/03/1170.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>发个套页面的辅助工具</title>
		<link>http://bluehua.org/2010/04/13/1112.html</link>
		<comments>http://bluehua.org/2010/04/13/1112.html#comments</comments>
		<pubDate>Tue, 13 Apr 2010 07:21:12 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1112</guid>
		<description><![CDATA[2010.4.22 使用vim的同学可以这样

command -nargs=0 HTML2Array :call HTML2Array&#40;&#41;
function HTML2Array&#40;&#41;
    exe&#40;&#34;'&#60;,'&#62;s/\&#34;/\\\\\&#34;/g&#34;&#41;
    exe&#40;&#34;'&#60;,'&#62;s/^/\&#34;/&#34;&#41;
    exe&#40;&#34;'&#60;,'&#62;s/$/\&#34;,/&#34;&#41;
    exe&#40;&#34;'&#60;,'&#62;g/^\&#34;[\\t ]*\&#34;,$/d&#34;&#41;
endfunction

先用=排版命令对html排版,然后选中,:HTML2Array就可以了
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
jser套的页面一般是这样的

var html = &#91;
//....
&#34;            &#60;div  class=\&#34;right\&#34;&#62;\n&#34;,
&#34;               [...]]]></description>
			<content:encoded><![CDATA[<p>2010.4.22 使用vim的同学可以这样</p>

<div class="wp_syntax"><div class="code overflow"><pre class="vim" style="font-family:monospace;"><span style="color: #668080;">command</span> <span style="color: #668080;">-nargs</span>=<span style="color: #000000; font-weight:bold;">0</span> HTML2Array <span style="color: #000000;">:</span><span style="color: #804040;">call</span> HTML2Array<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #804040;">function</span> HTML2Array<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #804040;">exe</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">&quot;'&lt;,'&gt;s/<span style="">\&quot;</span>/<span style="">\\</span><span style="">\\</span><span style="">\&quot;</span>/g&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #804040;">exe</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">&quot;'&lt;,'&gt;s/^/<span style="">\&quot;</span>/&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #804040;">exe</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">&quot;'&lt;,'&gt;s/$/<span style="">\&quot;</span>,/&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #804040;">exe</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">&quot;'&lt;,'&gt;g/^<span style="">\&quot;</span>[<span style="">\\</span>t ]*<span style="">\&quot;</span>,$/d&quot;</span><span style="color: #000000;">&#41;</span>
endfunction</pre></div></div>

<p>先用=排版命令对html排版,然后选中,:HTML2Array就可以了<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
jser套的页面一般是这样的</p>

<div class="wp_syntax"><div class="code overflow"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
<span style="color: #006600; font-style: italic;">//....</span>
<span style="color: #3366CC;">&quot;            &lt;div  class=<span style="color: #000099; font-weight: bold;">\&quot;</span>right<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                &lt;div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                    &lt;span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                        &lt;input name=<span style="color: #000099; font-weight: bold;">\&quot;</span>a<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                    &lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                    &lt;span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                        &lt;input name=<span style="color: #000099; font-weight: bold;">\&quot;</span>b<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                    &lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                &lt;/div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                &lt;div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                    &lt;input name=<span style="color: #000099; font-weight: bold;">\&quot;</span>c<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                &lt;/div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                &lt;div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                    &lt;input name=<span style="color: #000099; font-weight: bold;">\&quot;</span>d<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;                &lt;/div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;            &lt;/div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
<span style="color: #006600; font-style: italic;">//....</span>
<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>以前偶都是一点一点手工拼接的,今天抽时间写了段python,可以辅助一下~</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#可以生成上面形式的字符串</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> tmp.html <span style="color: #000000; font-weight: bold;">|</span> python html2js.py
<span style="color: #666666; font-style: italic;">#或者生成 &quot;abcd&quot; + 这种字符串拼接的形式</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> tmp.html <span style="color: #000000; font-weight: bold;">|</span> python html2js.py <span style="color: #660033;">--string</span></pre></div></div>

<p>脚本下载 : <a href='http://bluehua.org/wp-content/uploads/2010/04/html2js.0.1.zip'>html2js.0.1</a></p>
<p>测试环境: ubuntu 9.10 python 2.6.4</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/04/13/1112.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>准备做一个wordpress的离线编辑器</title>
		<link>http://bluehua.org/2010/01/24/886.html</link>
		<comments>http://bluehua.org/2010/01/24/886.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 07:47:26 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[offline editor]]></category>
		<category><![CDATA[pyqt4]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=886</guid>
		<description><![CDATA[2010.3.6 更新
由于最近的学习充电计划,这个东西暂时搁置了,现在已经可以自动保存了~
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;
linux平台上一直没有这样一个所见即所得的blog离线编辑器,昨天试着用pyqt4写了一个小脚本,发现原来python做客户端软件是如此容易.然后下定决心要利用n个周末的时间自己写一个.
开始打算用纯qt的ui控件实现,但是感觉没有wordpress的编辑器这么亲切,于是想到一个界面亲切,实现也方便的方案: ui部分直接用web,框在一个pyqt的webkit组件里,逻辑部分用python的cgihttpserver在本地开一个cgi.
这个东西搞到今天雏形已经有了,可以实现跟wordress完全相同的书写体验.

顺带发那个pyqt的练手之作 :　emlreader.py 一个可以查看eml附件的脚本
]]></description>
			<content:encoded><![CDATA[<p>2010.3.6 更新<br />
由于最近的学习充电计划,这个东西暂时搁置了,现在已经可以自动保存了~<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
linux平台上一直没有这样一个所见即所得的blog离线编辑器,昨天试着用pyqt4写了一个小脚本,发现原来python做客户端软件是如此容易.然后下定决心要利用n个周末的时间自己写一个.</p>
<p>开始打算用纯qt的ui控件实现,但是感觉没有wordpress的编辑器这么亲切,于是想到一个界面亲切,实现也方便的方案: ui部分直接用web,框在一个pyqt的webkit组件里,逻辑部分用python的cgihttpserver在本地开一个cgi.</p>
<p>这个东西搞到今天雏形已经有了,可以实现跟wordress完全相同的书写体验.</p>
<p><a href="http://bluehua.org/wp-content/uploads/2010/01/screenshot_048.png"><img class="alignnone size-medium wp-image-887" title="screenshot_048" src="http://bluehua.org/wp-content/uploads/2010/01/screenshot_048-300x240.png" alt="" width="300" height="240" /></a></p>
<p>顺带发那个pyqt的练手之作 :　<a href="http://bluehua.org/wp-content/uploads/2010/01/emlreader.py_.zip">emlreader.py</a> 一个可以查看eml附件的脚本</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/01/24/886.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>替换js中的字符串常量为变量</title>
		<link>http://bluehua.org/2009/09/01/413.html</link>
		<comments>http://bluehua.org/2009/09/01/413.html#comments</comments>
		<pubDate>Tue, 01 Sep 2009 01:11:37 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=413</guid>
		<description><![CDATA[最近需要把整站js中的域名替成变量,awk查资料写了大半天也没整出个啥,话说我的正则还是太初级,话说我买的正则书也不知跑到哪去了,话说好书还是要放到家里&#8230;
于是还是用python,没有用正则,但是好像跑起来真的比awk快~
脚本下载:replace_keyword.zip
效果:

//替换之前
var s = '&#60;a href=&#34;http://blog.abc.com/show&#34;&#62;';
//替换之后
var s = '&#60;a href=&#34;http://blog.' + siteDomain + '/show&#34;&#62;';

使用方法:
首要要修改脚本里要替换的关键词

config&#91;'keyword'&#93; = 'abc.com'
config&#91;'vname'&#93; = 'siteDomain'

然后

python replace_keyword.py ./myscript.js &#62; /tmp/ooxx
mv /tmp/ooxx ./myscript.js

批量替换的话就需要写个简单的shell:replace_keyword.sh

#!/bin/sh
python replace_keyword.py $1 &#62; /tmp/ooxx
mv /tmp/ooxx $1

批量替换整个目录

find ./ -name &#34;*.js&#34; &#124; xargs -i sh replace_keyword.sh &#123;&#125;

最后任务远没有结束,这个脚本还不够强大,它只会替换字符串中的关键字,作为对象属性名称的字符串不会替换,正则中的关键字无法替换,像下面:

var config = &#123;
    'blog.abc.com' : 1,
    'game.abc.com' : 2
&#125;
//需要手工替换为
var config = [...]]]></description>
			<content:encoded><![CDATA[<p>最近需要把整站js中的域名替成变量,awk查资料写了大半天也没整出个啥,话说我的正则还是太初级,话说我买的正则书也不知跑到哪去了,话说好书还是要放到家里<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/msn/bofu3_17.gif" border="0" alt="" />&#8230;</p>
<p>于是还是用python,没有用正则,但是好像跑起来真的比awk快~</p>
<p>脚本下载:<a href='http://bluehua.org/wp-content/uploads/2009/09/replace_keyword.zip'>replace_keyword.zip</a></p>
<p>效果:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//替换之前</span>
<span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;a href=&quot;http://blog.abc.com/show&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//替换之后</span>
<span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;a href=&quot;http://blog.'</span> <span style="color: #339933;">+</span> siteDomain <span style="color: #339933;">+</span> <span style="color: #3366CC;">'/show&quot;&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p>使用方法:<br />
首要要修改脚本里要替换的关键词</p>

<div class="wp_syntax"><div class="code overflow"><pre class="python" style="font-family:monospace;">config<span style="color: black;">&#91;</span><span style="color: #483d8b;">'keyword'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'abc.com'</span>
config<span style="color: black;">&#91;</span><span style="color: #483d8b;">'vname'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'siteDomain'</span></pre></div></div>

<p>然后</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">python replace_keyword.py .<span style="color: #000000; font-weight: bold;">/</span>myscript.js <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ooxx
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ooxx .<span style="color: #000000; font-weight: bold;">/</span>myscript.js</pre></div></div>

<p>批量替换的话就需要写个简单的shell:replace_keyword.sh</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
python replace_keyword.py $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ooxx
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ooxx $<span style="color: #000000;">1</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> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.js&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-i</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> replace_keyword.sh <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>最后任务远没有结束,这个脚本还不够强大,它只会替换字符串中的关键字,作为对象属性名称的字符串不会替换,正则中的关键字无法替换,像下面:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">'blog.abc.com'</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'game.abc.com'</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">//需要手工替换为</span>
<span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
config<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'blog'</span> <span style="color: #339933;">+</span> siteDomain<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
config<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'game'</span> <span style="color: #339933;">+</span> siteDomain<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009966; font-style: italic;">/abc\.com/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">//需要手工替换为</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> siteDomain.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\.</span>'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</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> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.js&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'abc\\\?\.com'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/09/01/413.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gmail to wordpress：通过mail更新wordpress</title>
		<link>http://bluehua.org/2009/06/02/312.html</link>
		<comments>http://bluehua.org/2009/06/02/312.html#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:51:10 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[soft]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bluehua.org/2009/06/02/312.html</guid>
		<description><![CDATA[个人比较习惯用email更新博客，写日记用的blogger一直是手机写邮件更新，于是打算这个工作blog也要这么搞






wordpress自身有个通过邮件更新的功能，但是很弱，不支持附件.所以俺再次拿python做练习
实现方式：
发布blog时只要写信给somebody+xxoo@gmail.com
脚本会定时检查somebody@gmail邮箱，
取出收信人是somebody+xxoo@gmail.com的未读邮件（加xxoo为了防止垃圾邮件），然后将邮件正文中引用的图片取出，上传到blog或着picasa，将返回的地址作为图片的新地址，然后通过wordpress的metaWeblog api 发布到wordpress

实现特性：


可以通过添加&#34;[[tag:t1,t2,t3]]&#34;设定文章的标签
可以通过添加&#34;[[cat:c1,c2]]&#34;设定文章分类
可以添加&#34;[[end]]&#34;标记文章结尾，标记后面的字符将被忽略
可以添加[[html]][[/html]]块发布纯html代码块

可以将邮件中的图片提取，并上传到picasa或者wp



(备注：&#34;[[&#34;实际使用用时要用三个，即&#34;[[[xxxx]]]&#34;这里用两个是因为本文也是通过这个脚本发布的）



运行环境：python2.6(ubuntu)（其他版本未测)，gdata库

部分代码：

def after_publish&#40; self, mid &#41;:
&#160;
        self.mail.read&#40; mid &#41;
&#160;
&#160;
#实例化一个Gmail2Blog，参数依次为：gmail帐号，gmail密码，wp帐号，wp密码，blog的xmlrpc地址
myG2B = Gmail2Blog&#40; 'somebody@gmail.com', 'xxxx', 'admin', 'xxxx', 'http://xxoo.com/xmlrpc.php' &#41;
&#160;
&#160;
&#160;
#将处理完的邮件标记为已读
myG2B.publish_callback = after_publish
&#160;
#设置图片的上传方式，'picasa':上传到账户的picasa相册，'wp':上传到blog
myG2B.upload2 = 'picasa'
    
while True:
    #将收件箱中发送给'somebody+blog@gmail.com'的未读邮件发送到blog
&#160;
&#160;
    myG2B.publish_mail&#40; 'INBOX' , '(UNSEEN) (TO \&#34;somebody+blog@gmail.com\&#34;)' &#41;
    #每隔十分钟检查一次
    time.sleep&#40; 60 * 10 &#41;


源码下载：非常不靠谱版本（等靠谱了就放到vps上长期运行)
gmail2blog-sbeta.tar.gz


Gmail撰写截图：










]]></description>
			<content:encoded><![CDATA[<p>个人比较习惯用email更新博客，写日记用的blogger一直是手机写邮件更新，于是打算这个工作blog也要这么搞<img goomoji="338" style="margin: 0pt 0.2ex; vertical-align: middle;" src="http://lh4.ggpht.com/_l8FcMjS-xnI/SiUuIXS5nXI/AAAAAAAAFG0/W1vfUhNmGVc/new%20photo.gif?imgmax=640"></p>
<div class="gmail_quote">
<div class="gmail_quote">
<div class="gmail_quote">
<div class="gmail_quote">
<div>
<div class="im">
wordpress自身有个通过邮件更新的功能，但是很弱，不支持附件.所以俺再次拿python做练习</p>
<p>实现方式：</p>
<p>发布blog时只要写信给<a href="mailto:somebody%2Bxxoo@gmail.com">somebody+xxoo@gmail.com</a></p>
<p>脚本会定时检查somebody@gmail邮箱，
<div class="im">取出收信人是<a href="mailto:somebody%2Bxxoo@gmail.com" target="_blank">somebody+xxoo@gmail.com</a>的未读邮件（加xxoo为了防止垃圾邮件），然后将邮件正文中引用的图片取出，上传到blog或着picasa，将返回的地址作为图片的新地址，然后通过wordpress的<a href="http://codex.wordpress.org/XML-RPC_Support" target="_blank">metaWeblog api</a> 发布到wordpress</p>
</div>
<p>实现特性：</div>
<ul>
<div class="im">
<li>可以通过添加&quot;[[tag:t1,t2,t3]]&quot;设定文章的标签</li>
<li>可以通过添加&quot;[[cat:c1,c2]]&quot;设定文章分类</li>
<li>可以添加&quot;[[end]]&quot;标记文章结尾，标记后面的字符将被忽略</li>
<li>可以添加[[html]][[/html]]块发布纯html代码块</li>
</div>
<li>可以将邮件中的图片提取，并上传到picasa或者wp
</li>
</ul>
</div>
<div class="im">(备注：&quot;[[&quot;实际使用用时要用三个，即&quot;[[[xxxx]]]&quot;这里用两个是因为本文也是通过这个脚本发布的）</div>
<div>
<div class="im">
</div>
<p>运行环境：<br />python2.6(ubuntu)（其他版本未测)，<a href="http://code.google.com/apis/gdata/" target="_blank">gdata库</a>
<div class="im">
<p>部分代码：</p>

<div class="wp_syntax"><div class="code overflow"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> after_publish<span style="color: black;">&#40;</span> <span style="color: #008000;">self</span>, mid <span style="color: black;">&#41;</span>:
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">mail</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span> mid <span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">#实例化一个Gmail2Blog，参数依次为：gmail帐号，gmail密码，wp帐号，wp密码，blog的xmlrpc地址</span>
myG2B = Gmail2Blog<span style="color: black;">&#40;</span> <span style="color: #483d8b;">'somebody@gmail.com'</span>, <span style="color: #483d8b;">'xxxx'</span>, <span style="color: #483d8b;">'admin'</span>, <span style="color: #483d8b;">'xxxx'</span>, <span style="color: #483d8b;">'http://xxoo.com/xmlrpc.php'</span> <span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">#将处理完的邮件标记为已读</span>
myG2B.<span style="color: black;">publish_callback</span> = after_publish
&nbsp;
<span style="color: #808080; font-style: italic;">#设置图片的上传方式，'picasa':上传到账户的picasa相册，'wp':上传到blog</span>
myG2B.<span style="color: black;">upload2</span> = <span style="color: #483d8b;">'picasa'</span>
    
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
    <span style="color: #808080; font-style: italic;">#将收件箱中发送给'somebody+blog@gmail.com'的未读邮件发送到blog</span>
&nbsp;
&nbsp;
    myG2B.<span style="color: black;">publish_mail</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">'INBOX'</span> , <span style="color: #483d8b;">'(UNSEEN) (TO <span style="color: #000099; font-weight: bold;">\&quot;</span>somebody+blog@gmail.com<span style="color: #000099; font-weight: bold;">\&quot;</span>)'</span> <span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#每隔十分钟检查一次</span>
    <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span> <span style="color: #ff4500;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">10</span> <span style="color: black;">&#41;</span></pre></div></div>

</div>
<p>源码下载：<br />非常不靠谱版本（等靠谱了就放到vps上长期运行<img goomoji="32B" style="margin: 0pt 0.2ex; vertical-align: middle;" src="http://lh3.ggpht.com/_l8FcMjS-xnI/SiUuIRok4wI/AAAAAAAAFG4/XynMbvPzi_0/new%20photo.gif?imgmax=640">)</p>
<p><a href="http://sites.google.com/site/sharemyidea09/gmail-2-blog" target="_blank">gmail2blog-sbeta.tar.gz</a>
<div class="im">
<p></div>
<p>Gmail撰写截图：</p>
<p><img title="screenshot_016.png" alt="screenshot_016.png" src="http://lh5.ggpht.com/_l8FcMjS-xnI/SiUuI1KgYkI/AAAAAAAAFG8/tji9lyc-Oss/new%20photo.png?imgmax=640"></p>
</div>
</div>
<p>
</div>
<p>
</div>
<p>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/06/02/312.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>利用data-uri合并样式表和图片</title>
		<link>http://bluehua.org/2009/05/17/295.html</link>
		<comments>http://bluehua.org/2009/05/17/295.html#comments</comments>
		<pubDate>Sun, 17 May 2009 06:41:00 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[data-uri]]></category>
		<category><![CDATA[mhtml]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=295</guid>
		<description><![CDATA[data-URI是一种允许将图片直接嵌入页面或者样式表中的标准，新版本的firefox,safari,chrome,ie8均已支持，所以可以利用data-URI将样式表中的背景图片合并到文件，以减少连接数，加快网页的载入速度.
但是由于低于ie8的ie版本均不支持data-URI，所以要通过mhtml对ie6，7版本特殊照顾（ie中将网页保存为单个.mht文件时使用了该标准）
通过data-URI编码的图片要比原图大1/3，而且如果图片在样式表中反复出现，转换后的体积将比原文件加图片的体积不只大1/3，但是由于传输一般走gzip，客户端也有缓存，所以可以无视吧&#8230;.
恩，技术就是这么点，本来要用这个搞一下优化，但是老大没有点头，白写了脚本，不过学了会python也没用过，算练练手
下面这个就是通过脚本转换的曾经风靡全球的css garden的页面
http://bluehua.org/demo/data_uri/cssgarden/
页面加载完毕只有两个请求，一个html，一个css
转换文件使用的参数

python /home/hualu/bin/data-uri.py -l /media/we/share/cssgarden/ -r http://bluehua.org/demo/data_uri/cssgarden/ /media/we/share/cssgarden/001

既然用不着，脚本也就一直beta下去了，啊&#8230;.
python脚本下载
]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Data_URI_scheme">data-URI</a>是一种允许将图片直接嵌入页面或者样式表中的标准，新版本的firefox,safari,chrome,ie8均已支持，所以可以利用data-URI将样式表中的背景图片合并到文件，以减少连接数，加快网页的载入速度.</p>
<p>但是由于低于ie8的ie版本均不支持data-URI，所以要通过<a href="http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/">mhtml对ie6，7版本特殊照顾</a>（ie中将网页保存为单个.mht文件时使用了该标准）</p>
<p>通过data-URI编码的图片要比原图大1/3，而且如果图片在样式表中反复出现，转换后的体积将比原文件加图片的体积不只大1/3，但是由于传输一般走gzip，客户端也有缓存，所以可以无视吧&#8230;.</p>
<p>恩，技术就是这么点，本来要用这个搞一下优化，但是老大没有点头，白写了脚本，不过学了会python也没用过，算练练手<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/maomao/1.gif" border="0" alt="" /></p>
<p>下面这个就是通过脚本转换的曾经风靡全球的css garden的页面</p>
<p><a href="http://bluehua.org/demo/data_uri/cssgarden/" target="_blank">http://bluehua.org/demo/data_uri/cssgarden/</a></p>
<p>页面加载完毕只有两个请求，一个html，一个css</p>
<p>转换文件使用的参数</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">python <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>hualu<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>data-uri.py <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>we<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>cssgarden<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-r</span> http:<span style="color: #000000; font-weight: bold;">//</span>bluehua.org<span style="color: #000000; font-weight: bold;">/</span>demo<span style="color: #000000; font-weight: bold;">/</span>data_uri<span style="color: #000000; font-weight: bold;">/</span>cssgarden<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>we<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>cssgarden<span style="color: #000000; font-weight: bold;">/</span>001</pre></div></div>

<p>既然用不着，脚本也就一直beta下去了，啊&#8230;.</p>
<p><a href="http://sites.google.com/site/sharemyidea09/data-uri-builder-for-css-file" target="_blank">python脚本下载</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/05/17/295.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.469 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-09-10 17:52:22 -->
