<?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, 13 Apr 2012 14:08:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<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>Python简介</title>
		<link>http://bluehua.org/2011/04/15/1585.html</link>
		<comments>http://bluehua.org/2011/04/15/1585.html#comments</comments>
		<pubDate>Fri, 15 Apr 2011 10:51:38 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1585</guid>
		<description><![CDATA[给同事做了一个小分享，主要是简单介绍一下python这门语言,ppt贴上，期待python能够成为主流！！！ Python简介 View more presentations from emptyhua]]></description>
			<content:encoded><![CDATA[<p>给同事做了一个小分享，主要是简单介绍一下python这门语言,ppt贴上，期待python能够成为主流！！！</p>
<div style="width:425px" id="__ss_7637766"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/emptyhua/python-7637766" title="Python简介">Python简介</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/7637766" 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/">presentations</a> from <a href="http://www.slideshare.net/emptyhua">emptyhua</a> </div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/04/15/1585.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PPJ回忆录</title>
		<link>http://bluehua.org/2011/01/16/1529.html</link>
		<comments>http://bluehua.org/2011/01/16/1529.html#comments</comments>
		<pubDate>Sun, 16 Jan 2011 09:27:11 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PPJ]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bluehua.org/2011/01/16/1529.html</guid>
		<description><![CDATA[个人以为:学一门脚本很容易，但是学几门就是一个痛苦的事，因为我经常把他们搞混。。 于是我下决心写一个能够帮我理清楚的文档，我命之为《PPJ回忆录》,从周5写到今天，精疲力尽，剩下OO和正则部分没写，我决定先歇会~ 毫不客气的说，对于同时学里面任意两门语言的同学，这个文档都会对你有帮助。 &#8212;&#8212;&#8212;&#8211; post by gmail~]]></description>
			<content:encoded><![CDATA[<p>个人以为:学一门脚本很容易，但是学几门就是一个痛苦的事，因为我经常把他们搞混。。</p>
<p>于是我下决心写一个能够帮我理清楚的文档，我命之为<a href="http://bluehua.org/demo/PPJ.html">《PPJ回忆录》</a>,从周5写到今天，精疲力尽，剩下OO和正则部分没写，我决定先歇会~</p>
<p>毫不客气的说，对于同时学里面任意两门语言的同学，这个文档都会对你有帮助。</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2011/01/16/1529.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>终于可以直接在vim里编辑日志了</title>
		<link>http://bluehua.org/2010/11/28/1480.html</link>
		<comments>http://bluehua.org/2010/11/28/1480.html#comments</comments>
		<pubDate>Sun, 28 Nov 2010 14:58:55 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[soft]]></category>
		<category><![CDATA[blogo2]]></category>
		<category><![CDATA[mail2blog]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/11/28/1480.html</guid>
		<description><![CDATA[最终我还是给blogo2增加了一个不实用的通过邮件编辑日志的功能，需要加一个#edit:BLOGID的标记，但是因为邮件客户端跟本不知道已发blog的id，所以功能略显鸡肋。这绝对是我专用的功能,在bin目录又加了一个小命令,只需在vim里输入:r!wpblog bluehua.org 便可以把最新的blog拽回来，包括blogid wpblog的内容 #!/usr/bin/env python import sys import xmlrpclib import getpass import os &#160; ''' A simple tool for dump blog powered by wordpress For example: in vim, dump the last webblog into current buffer :r!wpblog myblog.domain ''' &#160; #make sure the stderr is the control terminal if os.name == 'posix': sys.stderr = open&#40;'/dev/tty', [...]]]></description>
			<content:encoded><![CDATA[<p>最终我还是给<a href="http://www.blogo2.com">blogo2</a>增加了一个不实用的通过邮件编辑日志的功能，需要加一个#edit:BLOGID的标记，但是因为邮件客户端跟本不知道已发blog的id，所以功能略显鸡肋。这绝对是我专用的功能,在bin目录又加了一个小命令,只需在vim里输入:r!wpblog bluehua.org 便可以把最新的blog拽回来，包括blogid</p>
<p>wpblog的内容</p>

<div class="wp_syntax"><div class="code overflow"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span> 
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">getpass</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
&nbsp;
<span style="color: #483d8b;">''</span><span style="color: #483d8b;">'
A simple tool for dump blog powered by wordpress
For example: in vim, dump the last webblog into current buffer
:r!wpblog myblog.domain
'</span><span style="color: #483d8b;">''</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#make sure the stderr is the control terminal </span>
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">name</span> == <span style="color: #483d8b;">'posix'</span>:
    <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/dev/tty'</span>, <span style="color: #483d8b;">'a'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">2</span>: 
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span>,<span style="color: #483d8b;">''</span><span style="color: #483d8b;">'
Usage:
wpblog myblog.domain [blogid]
    '</span><span style="color: #483d8b;">''</span>
    exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
rpc = <span style="color: #483d8b;">'http://%s/xmlrpc.php'</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span>, <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Username:'</span>
<span style="color: #dc143c;">user</span> = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
passwd = <span style="color: #dc143c;">getpass</span>.<span style="color: #dc143c;">getpass</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Password:'</span><span style="color: black;">&#41;</span>
&nbsp;
api = <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span>rpc<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">try</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">2</span>:
        blog = api.<span style="color: black;">metaWeblog</span>.<span style="color: black;">getPost</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>, <span style="color: #dc143c;">user</span>, passwd<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        blogs = api.<span style="color: black;">metaWeblog</span>.<span style="color: black;">getRecentPosts</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>, <span style="color: #dc143c;">user</span>, passwd, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>blogs<span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span>, <span style="color: #483d8b;">'no blog returned~'</span>
            exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
        blog = blogs<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">Fault</span>, ex:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stderr</span>, ex.<span style="color: black;">faultString</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'utf-8'</span><span style="color: black;">&#41;</span>
        exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'#cats:%s'</span> <span style="color: #66cc66;">%</span> u<span style="color: #483d8b;">','</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>blog<span style="color: black;">&#91;</span><span style="color: #483d8b;">'categories'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'utf-8'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'#tags:%s'</span> <span style="color: #66cc66;">%</span> blog<span style="color: black;">&#91;</span><span style="color: #483d8b;">'mt_keywords'</span><span style="color: black;">&#93;</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'utf-8'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'#edit:%s'</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blog<span style="color: black;">&#91;</span><span style="color: #483d8b;">'postid'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> blog<span style="color: black;">&#91;</span><span style="color: #483d8b;">'description'</span><span style="color: black;">&#93;</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'utf-8'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/11/28/1480.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>冥王星2011</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的替代品。以前用”flash 录音”两个关键词，结果大多是FMS实现，还有个开源的Red5，java实现的，还是算了，vps上跑java。。偶尔换了个高级点的关键词”python rtmp”立刻找到我想要的: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的替代品。以前用”flash 录音”两个关键词，结果大多是FMS实现，还有个开源的Red5，java实现的，还是算了，vps上跑java。。偶尔换了个高级点的关键词”python rtmp”立刻找到我想要的:<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>2</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>冥王星2011</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=”dialog:{}”,则表明在开启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=”dialog:{}”,则表明在开启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>冥王星2011</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 [...]]]></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>1</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>冥王星2011</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>冥王星2011</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; &#60;div&#62;\n&#34;, &#34; &#60;span&#62;\n&#34;, &#34; &#60;input name=\&#34;a\&#34; type=\&#34;text\&#34; /&#62;\n&#34;, &#34; &#60;/span&#62;\n&#34;, &#34; &#60;span&#62;\n&#34;, &#34; &#60;input name=\&#34;b\&#34; type=\&#34;text\&#34; /&#62;\n&#34;, &#34; &#60;/span&#62;\n&#34;, &#34; &#60;/div&#62;\n&#34;, &#34; &#60;div&#62;\n&#34;, &#34; &#60;input name=\&#34;c\&#34; type=\&#34;text\&#34; /&#62;\n&#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>冥王星2011</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>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.677 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-22 09:16:04 -->

