<?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://chenyc.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://chenyc.info</link>
	<description>人生是一个不断折腾的过程，生命不息，折腾不止</description>
	<lastBuildDate>Mon, 06 Feb 2012 12:48:03 +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>node.js初体验</title>
		<link>http://chenyc.info/2012/02/node-js-learn/</link>
		<comments>http://chenyc.info/2012/02/node-js-learn/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 12:27:45 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=847</guid>
		<description><![CDATA[因为阿里的云计算平台采用的是Node.js，好奇所以就简单的了解了一下. Node.js可以用JavaScript编写服务端的代码，实际上编写Node.js的应用， 不仅仅是编写一个应用，而是整个服务器。 Node.js的特性 1. 单线程 2. 非阻塞IO 3. Google V8 4. 事件驱动 据网上的评测，由于事件驱动和非阻塞IO等特性，Node.js编写出来的程序性能极高，但由于是单线程的，难于利用多处理器的优势，另外也因为是单线程，导致Node.js编写的程序极其脆弱，如果有一个页面访问出错，就会导致整个应用服务器崩溃掉，所以我认为得Node.js编写的程序需要充分测试（或许还有方法可以避免应用服务器直接崩溃掉）。 另外Node.js不像python这样可以修改后直接看到效果，而是需要重启服务器，这点感觉调试起来感觉很不爽。 来个Hello World的例子，拷贝以下代码保存为hello_world.js: var http = require("http"); function onRequest(request, response) {   console.log("Request received.");   response.writeHead(200, {"Content-Type": "text/plain"});   response.write("Hello World");   response.end(); } http.createServer(onRequest).listen(8888); console.log("Server &#8230; <a href="http://chenyc.info/2012/02/node-js-learn/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>因为阿里的云计算平台采用的是<a href="http://nodejs.org/">Node.js</a>，好奇所以就简单的了解了一下.</p>
<p><a href="http://nodejs.org/">Node.js</a>可以用JavaScript编写服务端的代码，实际上编写<a href="http://nodejs.org/">Node.js</a>的应用，</p>
<p>不仅仅是编写一个应用，而是整个服务器。</p>
<p>Node.js的特性</p>
<p style="padding-left: 30px;"><strong>1. 单线程</strong></p>
<p style="padding-left: 30px;"><strong>2. 非阻塞IO</strong></p>
<p style="padding-left: 30px;"><strong>3. Google V8</strong></p>
<p style="padding-left: 30px;"><strong>4. 事件驱动</strong></p>
<p>据网上的评测，由于事件驱动和非阻塞IO等特性，Node.js编写出来的程序性能极高，但由于是单线程的，难于利用多处理器的优势，另外也因为是单线程，导致Node.js编写的程序极其脆弱，如果有一个页面访问出错，就会导致整个应用服务器崩溃掉，所以我认为得<a href="http://nodejs.org/">Node.js</a>编写的程序需要充分测试（或许还有方法可以避免应用服务器直接崩溃掉）。</p>
<p>另外Node.js不像python这样可以修改后直接看到效果，而是需要重启服务器，这点感觉调试起来感觉很不爽。</p>
<p>来个Hello World的例子，拷贝以下代码保存为hello_world.js:</p>
<pre>var http = require("http");

function onRequest(request, response) {
  console.log("Request received.");
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");
  response.end();
}

http.createServer(onRequest).listen(8888);

console.log("Server has started.");</pre>
<pre>运行：在命令行输入 node hello_world.js</pre>
<p>我是参照<a href="http://www.nodebeginner.org/index-zh-cn.html">http://www.nodebeginner.org/index-zh-cn.html</a>学习的，总体感觉还是比较容易上手的，另外<a href="http://nodejs.org/">Node.js</a>还有一个比较流行的MVC框架<a href="http://expressjs.com/">Express</a>，有空可以研究一下。</p>
<p>附：</p>
<p style="padding-left: 30px;"><a href="http://blog.sina.com.cn/s/blog_593832910100o1v5.html" target="_blank">node.js调研与服务性能测试</a></p>
<h1 style="padding-left: 30px;"><a id="cb_post_title_url" href="http://www.cnblogs.com/QLeelulu/archive/2011/01/28/nodejs_into_and_n2mvc.html" target="_blank">Node.js：用JavaScript写服务器端程序-介绍并写个MVC框架</a></h1>
<h3 style="padding-left: 30px;"><a href="http://snoopyxdy.blog.163.com/blog/static/60117440201183101319257/" target="_blank">巅峰对决：node.js和php性能测试 </a></h3>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2012/02/node-js-learn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>迁移Blog到Amazon EC2云服务器</title>
		<link>http://chenyc.info/2012/02/blog-to-ec2/</link>
		<comments>http://chenyc.info/2012/02/blog-to-ec2/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 16:10:03 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://chenyc.info/blog/?p=827</guid>
		<description><![CDATA[Amazon EC2云服务器首年使用免费，第二年开始得每年100多美元，到时候再重新弄个帐号，再搬一下。 注册Amazon EC2还是比较麻烦的，需要通过手机和信用卡认证，可以参考Amazon EC2一年免费服务注册过程(图解)。 注册完成后选择实例，需要选择基于EBS文件系统的，且主机类型需要选择micro类型，这样才能有第一年免费;接着安装和配置服务，我选择的是LNMP，参考http://blog.hebine.com/archives/1552.html EC2提供了不同区域的服务器，我测试了美国西海岸和日本东京的，美国西海岸在网通下速度还行，在电信下非常的慢；日本东京的稍微好一些，所以就选择了日本东京的服务器。 最后迁移wordpress,最简单的办法就是备份所有文件和数据库，到新服务器上还原就行了，然后打开godaddy修改域名解析，EC2提供了独立IP，所以直接配置中指定IP就OK了，域名修改生效也非常快。 如果服务稳定的话，以后准备一直使用下去了，毕竟EC2就是一台VPS啊，拥有所有的权限，非常方便，以后还可以配置基于SSH的代理等；还可以部署一个Python web服务器，在自己折腾一些想法的时候使用（SAE也可以，但是受控感觉不大方便）。 为了以后迁移方便，记下一些主要步骤 1.选择AMI安装系统，搜索“099720109477”发布的Ubuntu 11.04系统，这是Ubuntu官方在EC2上提供的系统。 2.安装LNMP，参考http://blog.hebine.com/archives/1552.html。另外由于采用了nginx，实现wordpress固定链接的支持需要在nginx的配置中加入 try_files $uri $uri/ /index.php?q=$uri&#38;$args; 3.安装vsftpd，配置ftp服务器。参考http://www.douban.com/note/80626720/，在windows连接vsftpd时需要选择被动模式，在EC2下连接其他FTP服务器时，需要使用ftp -p ip地址，必须加上-p参数。 4.tar备份/home/www目录，phpMyAdmin备份数据库。 5.通过ftp下载备份文件并解压，恢复mysql数据库。 6.检查恢复的系统是否存在问题，正常的话，修改goDaddy域名解析的配置。]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/ec2/" target="_blank">Amazon EC2</a>云服务器首年使用免费，第二年开始得每年100多美元，到时候再重新弄个帐号，再搬一下。<br />
注册<a href="http://aws.amazon.com/ec2/" target="_blank">Amazon EC2</a>还是比较麻烦的，需要通过手机和信用卡认证，可以参考<a title="Amazon EC2一年免费服务注册过程(图解)" href="http://www.bityun.com/archives/42" target="_blank">Amazon EC2一年免费服务注册过程(图解)</a>。</p>
<p>注册完成后选择实例，需要选择基于EBS文件系统的，且主机类型需要选择micro类型，这样才能有第一年免费;接着安装和配置服务，我选择的是LNMP，参考<a href="http://blog.hebine.com/archives/1552.html">http://blog.hebine.com/archives/1552.html</a></p>
<p>EC2提供了不同区域的服务器，我测试了美国西海岸和日本东京的，美国西海岸在网通下速度还行，在电信下非常的慢；日本东京的稍微好一些，所以就选择了日本东京的服务器。</p>
<p>最后迁移<a href="http://www.wordpress.org" target="_blank">wordpress</a>,最简单的办法就是备份所有文件和数据库，到新服务器上还原就行了，然后打开<a href="https://www.godaddy.com/" target="_blank">godaddy</a>修改域名解析，EC2提供了独立IP，所以直接配置中指定IP就OK了，域名修改生效也非常快。</p>
<p>如果服务稳定的话，以后准备一直使用下去了，毕竟EC2就是一台VPS啊，拥有所有的权限，非常方便，以后还可以配置基于SSH的代理等；还可以部署一个Python web服务器，在自己折腾一些想法的时候使用（SAE也可以，但是受控感觉不大方便）。</p>
<p><strong>为了以后迁移方便，记下一些主要步骤</strong></p>
<p style="padding-left: 30px;">1.选择AMI安装系统，搜索“099720109477”发布的Ubuntu 11.04系统，这是Ubuntu官方在EC2上提供的系统。</p>
<p style="padding-left: 30px;">2.安装LNMP，参考<a href="http://blog.hebine.com/archives/1552.html">http://blog.hebine.com/archives/1552.html</a>。另外由于采用了nginx，实现wordpress固定链接的支持需要在nginx的配置中加入</p>
<pre style="padding-left: 30px;">try_files $uri $uri/ /index.php?q=$uri&amp;$args;</pre>
<p style="padding-left: 30px;">3.安装vsftpd，配置ftp服务器。参考<a href="http://www.douban.com/note/80626720/">http://www.douban.com/note/80626720/</a>，在windows连接vsftpd时需要选择被动模式，在EC2下连接其他FTP服务器时，需要使用ftp -p ip地址，必须加上-p参数。</p>
<p style="padding-left: 30px;">4.tar备份/home/www目录，phpMyAdmin备份数据库。</p>
<p style="padding-left: 30px;">5.通过ftp下载备份文件并解压，恢复mysql数据库。</p>
<p style="padding-left: 30px;">6.检查恢复的系统是否存在问题，正常的话，修改goDaddy域名解析的配置。</p>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2012/02/blog-to-ec2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>正则表达式学习摘录</title>
		<link>http://chenyc.info/2012/01/regex-study/</link>
		<comments>http://chenyc.info/2012/01/regex-study/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 09:31:26 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[其他]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=812</guid>
		<description><![CDATA[1．正则表达式匹配匹配结果，只包括匹配上的部分，不包括整个字符串， 如果需要把整个字符串传递到后续处理时，需要注意。 2．字符点（.）可以匹配任何一个字符，可以在正则表达式中多次出现。 3.[]中的字符，代表字符集，如[ns]将匹配n或者s字符 4.^符号，代表取非操作 5.\b 回退符 \f 换页符 \n 换行符 \r 回车符 \t 制表符（TAB） \v 垂直制表符 6.\d 任何一个数字，\D 任何一个非数字 7.\w 任何一个字母，数字字符，\W 任何一个非字母，非数字字符 8.\s 任何一个空白字符，\S 任何一个非空白字符 9.{}中的哦数字，代表匹配的重复次数 10.{2,4}的含义最少重复2次，最多重复4次 11.？代表出现0次或1次 12.*,+号等匹配时默认都是贪婪型元素符，如 测试文字：&#60;b&#62;hello&#60;/b&#62;&#60;b&#62;world&#60;/b&#62; 采用此正则&#60;[Bb]&#62;.*&#60;/[Bb]&#62;匹配时，会从头匹配到结尾，结果是 &#60;b&#62;hello&#60;/b&#62;&#60;b&#62;world&#60;/b&#62; 但我们不需要这种贪婪型匹配时，需要加载*号，将其变成懒惰型，改成 &#60;[Bb]&#62;.*?&#60;/[Bb]&#62;,此时的匹配结果如下： 【匹配结果：2】 (1)&#60;b&#62;hello&#60;/b&#62; (2)&#60;b&#62;world&#60;/b&#62; 13.位置匹配 \b &#8230; <a href="http://chenyc.info/2012/01/regex-study/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1．正则表达式匹配匹配结果，只包括匹配上的部分，不包括整个字符串，<br />
   如果需要把整个字符串传递到后续处理时，需要注意。</p>
<p>2．字符点（.）可以匹配任何一个字符，可以在正则表达式中多次出现。</p>
<p>3.[]中的字符，代表字符集，如[ns]将匹配n或者s字符</p>
<p>4.^符号，代表取非操作</p>
<p>5.\b 回退符 \f 换页符 \n 换行符 \r 回车符 \t 制表符（TAB） \v 垂直制表符</p>
<p>6.\d 任何一个数字，\D 任何一个非数字</p>
<p>7.\w 任何一个字母，数字字符，\W 任何一个非字母，非数字字符</p>
<p>8.\s 任何一个空白字符，\S 任何一个非空白字符</p>
<p>9.{}中的哦数字，代表匹配的重复次数</p>
<p>10.{2,4}的含义最少重复2次，最多重复4次</p>
<p>11.？代表出现0次或1次</p>
<p>12.*,+号等匹配时默认都是贪婪型元素符，如</p>
<blockquote><p>测试文字：&lt;b&gt;hello&lt;/b&gt;&lt;b&gt;world&lt;/b&gt;</p>
<p>采用此正则&lt;[Bb]&gt;.*&lt;/[Bb]&gt;匹配时，会从头匹配到结尾，结果是</p>
<p>&lt;b&gt;hello&lt;/b&gt;&lt;b&gt;world&lt;/b&gt;</p>
<p>但我们不需要这种贪婪型匹配时，需要加载*号，将其变成懒惰型，改成</p>
<p>&lt;[Bb]&gt;.*?&lt;/[Bb]&gt;,此时的匹配结果如下：</p>
<p>【匹配结果：2】</p>
<p>(1)&lt;b&gt;hello&lt;/b&gt;</p>
<p>(2)&lt;b&gt;world&lt;/b&gt;</p></blockquote>
<p>13.位置匹配</p>
<p>\b 单词边界，如\bcat\b,将在文本中只匹配cat单词</p>
<p>^匹配字符串开头</p>
<p>$匹配字符串结尾</p>
<p>(?m) 表示分行匹配模式，^和$可以匹配每一行的开始和结尾</p>
<p>14.子表达式,子表达式用()括起来即可</p>
<p>15.回溯引用 \1 代表在正则中出现的第一个表达式</p>
<p>16.替换中使用$1表示正则中的第一个表达式、</p>
<p>17.前后查找，?=表示向前查找，只找到对应值，但不出现到匹配结果里; ?&lt;=  表示向后查找</p>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2012/01/regex-study/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android NDK介绍及JNI调用</title>
		<link>http://chenyc.info/2012/01/android-ndk-and-jni/</link>
		<comments>http://chenyc.info/2012/01/android-ndk-and-jni/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 03:36:32 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[jni]]></category>
		<category><![CDATA[ndk]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=798</guid>
		<description><![CDATA[Android NDK是用来编译能在手机ARM平台上运行的，通过C/C++编写的LIB库。 注：理论上不只在ARM平台，以后应该也能在Intel x86平台上运行的。 JNI调用，是为了使java能够调用C/C++所编写的程序的一种机制。 Android NDK和JNI调用结合，就能够使Android程序，调用原生底层用C/C++实现的功能。 1.NDK开发环境配置 在Windows下开发需要安装Cygwin，安装时除了默认选择项外，还要选中gcc和make. 在Linux下，如Ubuntu，通过apt-get 安装gcc和make即可。 然后下载NDK，解压到特定的目录（如：D:\Android） 由于awt兼容性的问题，需要将D:\Android\android-ndk-r7\prebuilt\windows\bin中的awt.exe改为awt_.exe. 同时把D:\Android\android-ndk-r7加入到系统的PATH中，方便使用， 打开Cygwin，cd到/cygdrive/d/Android/android-ndk-r7/samples/hello-jni/jni目录，输入ndk-build，测试环境是否正常 出现以上显示的内容，即表示环境配置正常。 注：/cygdrive/d/即表示windows中的D盘。 2.开发Android测试程序 新建一个Android项目hello,包名com.hello 把自动生成的HelloActivity中修改为以下内容 public class HelloActivity extends Activity { private static final String TAG = &#34;Hello&#34;; static { System.loadLibrary(&#34;hello&#34;); } private native String &#8230; <a href="http://chenyc.info/2012/01/android-ndk-and-jni/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Android NDK是用来编译能在手机ARM平台上运行的，通过C/C++编写的LIB库。</p>
<p>注：理论上不只在ARM平台，以后应该也能在Intel x86平台上运行的。</p>
<p>JNI调用，是为了使java能够调用C/C++所编写的程序的一种机制。</p>
<p>Android NDK和JNI调用结合，就能够使Android程序，调用原生底层用C/C++实现的功能。</p>
<p><strong>1.NDK</strong><strong>开发环境配置</strong></p>
<p>在Windows下开发需要安装<a href="http://www.cygwin.com/">Cygwin</a>，安装时除了默认选择项外，还要选中gcc和make.</p>
<p><a href="/blog/wp-content/uploads/2012/01/img1.jpg"><img class="alignnone size-full wp-image-257" title="img1" src="/blog/wp-content/uploads/2012/01/img1.jpg" alt="" width="439" height="320" /></a></p>
<p>在Linux下，如Ubuntu，通过apt-get 安装gcc和make即可。</p>
<p>然后<a href="http://developer.android.com/sdk/ndk/index.html">下载NDK</a>，解压到特定的目录（如：D:\Android）</p>
<p>由于awt兼容性的问题，需要将D:\Android\android-ndk-r7\prebuilt\windows\bin中的awt.exe改为awt_.exe.</p>
<p>同时把D:\Android\android-ndk-r7加入到系统的PATH中，方便使用，</p>
<p>打开Cygwin，cd到/cygdrive/d/Android/android-ndk-r7/samples/hello-jni/jni目录，输入ndk-build，测试环境是否正常</p>
<p><a href="/blog/wp-content/uploads/2012/01/img2.jpg"><img class="alignnone size-full wp-image-258" title="img2" src="/blog/wp-content/uploads/2012/01/img2.jpg" alt="" width="453" height="253" /></a></p>
<p>出现以上显示的内容，即表示环境配置正常。</p>
<p>注：/cygdrive/d/即表示windows中的D盘。</p>
<p><strong>2.</strong><strong>开发</strong><strong>Android</strong><strong>测试程序</strong></p>
<p>新建一个Android项目hello,包名com.hello</p>
<p>把自动生成的HelloActivity中修改为以下内容</p>
<pre>
public class HelloActivity extends Activity {

	private static final String TAG = &quot;Hello&quot;;

	static {
		System.loadLibrary(&quot;hello&quot;);
	}

	private native String printJNI();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Log.d(TAG, printJNI());
	}
}
</pre>
<p>通过System.loadLibrary(“hello”)加载C编写的LIB，并定义native方法printJNI，最后调用printJNI()方法测试。</p>
<p><strong>3.开发C语言程序，并通过NDK编译</strong></p>
<p>在新建在helo项目的根目录下新建jni目录，如D:\MyWorkSpace3\hello</p>
<p>打开终端，转到D:\MyWorkSpace3\hello\，执行</p>
<pre>javah -classpath bin/classes -d jni com.hello.HelloActivity</pre>
<p>执行成功后，会在jni目录下生成com_hello_HelloActivity.h头文件；<br />
接着在jni目录下新建一个C文件com_hello_HelloActivity.c，编写如下代码：</p>
<pre>
#include &quot;com_hello_HelloActivity.h&quot;
#define LOG_TAG &quot;JNITest&quot;
#undef LOG
JNIEXPORT jstring JNICALL Java_com_hello_HelloActivity_printJNI
(JNIEnv * env, jobject obj)
{
return (*env)-&gt;NewStringUTF(env, (char *)&quot;JNITest Native String&quot;);
}
</pre>
<p>再在jni目录下新建一个Android.mk文件，用于配置编译的文件及选项</p>
<pre>
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := hello
LOCAL_SRC_FILES := com_hello_HelloActivity.c

include $(BUILD_SHARED_LIBRARY)
</pre>
<p>LOCAL_PATH指编译文件的目录，$(call my-dir)指向当前目录<br />
LOCAL_MODULE指定编译生成的lib名字<br />
LOCAL_SRC_FILES指需要编辑的源文件，可自动多个文件，换行时用\分隔</p>
<p>完成后打开Cygwin,cd到项目的jni目录下，<br />
比如/cygdrive/d/MyWorkSpace3/hello/jni<br />
执行ndk-build<br />
<a href="/blog/wp-content/uploads/2012/01/img3.jpg"><img class="alignnone size-full wp-image-266" title="img3" src="/blog/wp-content/uploads/2012/01/img3.jpg" alt="" width="587" height="324" /></a></p>
<p>生成的lib文件会安装到\libs\armeabi下，名称为libhello.so，但注意在java加载中只用写hello作为lib名称就可以了。</p>
<p><strong>4.检测执行结果</strong></p>
<p>在eclipse中刷新项目，运行，在logcat中应该可以看到“JNITest Native String”</p>
<p>项目附件：<a href='/blog/wp-content/uploads/2012/01/hello.zip'>hello.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2012/01/android-ndk-and-jni/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>新浪SAE python试用</title>
		<link>http://chenyc.info/2011/12/sae-python-try/</link>
		<comments>http://chenyc.info/2011/12/sae-python-try/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 12:45:48 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[sae]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=785</guid>
		<description><![CDATA[新浪目前提供SAE python版本的内测，内测帐号可以到http://appstack.sinaapp.com/queue申请， 一般估计5分钟左右就可以开通了，开通后没有任何提示，你要自己去SAE里新建项目，看能不能新建python项目了 通过sae python的文档，目前已支持以下几种web框架，比java版的进展快多了 Django Flask Bottle Tornado Uliweb web.py 比较了这几种框架，准备采用Flask作为自己的框架，因为比较简单，灵活性大，学习成本低。而且在SAE都只是做一些个人学习研究性的项目，不需要太复杂的功能。 目前已在本地配置好环境，参考dev-server的安装说明 准备做一下个保存WIKI条目的列表（如百家姓等），通过JSON格式输出，由Android手机端调用显示，并跳转到具体的WIKI页面。 另外目前维基百科访问时，有时候链接会被重置，跟Google一样，这是个头疼的问题，SAE在国内，也不能作为代理访问，这个只能到时候再看了。]]></description>
			<content:encoded><![CDATA[<p>新浪目前提供SAE python版本的内测，内测帐号可以到<a href="http://appstack.sinaapp.com/queue">http://appstack.sinaapp.com/queue</a>申请，</p>
<p>一般估计5分钟左右就可以开通了，开通后没有任何提示，你要自己去SAE里新建项目，看能不能新建python项目了</p>
<p>通过<a href="&lt;a href=&quot;http://appstack.sinaapp.com/static/doc/release/testing/index.html#&quot;&gt;http://appstack.sinaapp.com/static/doc/release/testing/index.html#&lt;">sae python的文档</a>，目前已支持以下几种web框架，比java版的进展快多了</p>
<ul>
<li><a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#django">Django</a></li>
<li><a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#flask">Flask</a></li>
<li><a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#bottle">Bottle</a></li>
<li><a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#tornado">Tornado</a></li>
<li><a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#uliweb">Uliweb</a></li>
<li><a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#web-py">web.py</a></li>
</ul>
<p>比较了这几种框架，准备采用<a href="http://appstack.sinaapp.com/static/doc/release/testing/framework.html#flask">Flask</a>作为自己的框架，因为比较简单，灵活性大，学习成本低。而且在SAE都只是做一些个人学习研究性的项目，不需要太复杂的功能。</p>
<p>目前已在本地配置好环境，参考<a href="http://appstack.sinaapp.com/static/doc/release/testing/runtime.html#dev-server">dev-server</a>的安装说明</p>
<p>准备做一下个保存WIKI条目的列表（如百家姓等），通过JSON格式输出，由Android手机端调用显示，并跳转到具体的WIKI页面。</p>
<p>另外目前<a href="http://zh.wikipedia.org">维基百科</a>访问时，有时候链接会被重置，跟Google一样，这是个头疼的问题，SAE在国内，也不能作为代理访问，这个只能到时候再看了。</p>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2011/12/sae-python-try/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android EditText强制输入数字</title>
		<link>http://chenyc.info/2011/12/android-edittext_only_digits/</link>
		<comments>http://chenyc.info/2011/12/android-edittext_only_digits/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 09:16:15 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=782</guid>
		<description><![CDATA[需要控制同时软输入法和实体输入法 //控制输入法只能用数字输入法 inputEdit.setInputType(InputType.TYPE_CLASS_PHONE); //设置文本框只接收数字输入，禁止实体键盘输入其他字符 DigitsKeyListener listener = new DigitsKeyListener(); inputEdit.setKeyListener(listener);]]></description>
			<content:encoded><![CDATA[<p>需要控制同时软输入法和实体输入法</p>
<pre>
//控制输入法只能用数字输入法
inputEdit.setInputType(InputType.TYPE_CLASS_PHONE);

//设置文本框只接收数字输入，禁止实体键盘输入其他字符
DigitsKeyListener listener = new DigitsKeyListener();
inputEdit.setKeyListener(listener);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2011/12/android-edittext_only_digits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android EditText 增加自定义过滤</title>
		<link>http://chenyc.info/2011/12/android-edittext-plus/</link>
		<comments>http://chenyc.info/2011/12/android-edittext-plus/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 09:07:46 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=773</guid>
		<description><![CDATA[在Android中，可以通过对EditText设置setFilters方法，用代码控制EditText的输入长度，或控制输入小数的位数等。 1.设置EditText的输入长度 inputEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter( length) }); 2.控制输入小数的位数 // 设置小数位数控制 InputFilter lengthfilter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // 删除等特殊字符，直接返回 if (&#34;&#34;.equals(source.toString())) { return null; &#8230; <a href="http://chenyc.info/2011/12/android-edittext-plus/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>在Android中，可以通过对EditText设置setFilters方法，用代码控制EditText的输入长度，或控制输入小数的位数等。</p>
<p style="padding-left: 30px;"><strong>1.设置EditText的输入长度</strong></p>
<pre>
inputEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
				length) });
</pre>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;"><strong>2.控制输入小数的位数</strong></p>
<pre>
		// 设置小数位数控制
		InputFilter lengthfilter = new InputFilter() {
			public CharSequence filter(CharSequence source, int start, int end,
					Spanned dest, int dstart, int dend) {

				// 删除等特殊字符，直接返回
				if (&quot;&quot;.equals(source.toString())) {
					return null;
				}

				String dValue = dest.toString();
				String[] splitArray = dValue.split(&quot;\\.&quot;);
				if (splitArray.length &gt; 1) {
					String dotValue = splitArray[1];
					int diff = dotValue.length() + 1 - digLength;
					if (diff &gt; 0) {
						return source.subSequence(start, end - diff);
					}
				}
				return null;
			}
		};

		inputEdit.setFilters(new InputFilter[] { lengthfilter });
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2011/12/android-edittext-plus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache 设置htaccess实现域名伪绑定</title>
		<link>http://chenyc.info/2011/12/apache-%e8%ae%be%e7%bd%aehtaccess%e5%ae%9e%e7%8e%b0%e5%9f%9f%e5%90%8d%e4%bc%aa%e7%bb%91%e5%ae%9a/</link>
		<comments>http://chenyc.info/2011/12/apache-%e8%ae%be%e7%bd%aehtaccess%e5%ae%9e%e7%8e%b0%e5%9f%9f%e5%90%8d%e4%bc%aa%e7%bb%91%e5%ae%9a/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 18:26:46 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://chenyc.info/2011/12/apache-%e8%ae%be%e7%bd%aehtaccess%e5%ae%9e%e7%8e%b0%e5%9f%9f%e5%90%8d%e4%bc%aa%e7%bb%91%e5%ae%9a/</guid>
		<description><![CDATA[创建.htaccess这个文件，写入以下内容 RewriteEngine On RewriteBase / RewriteRule ^(.*)$ http://kindlesync.sinaapp.com/$1 [P]]]></description>
			<content:encoded><![CDATA[<p>创建.htaccess这个文件，写入以下内容</p>
<blockquote><pre>RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://kindlesync.sinaapp.com/$1 [P]</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2011/12/apache-%e8%ae%be%e7%bd%aehtaccess%e5%ae%9e%e7%8e%b0%e5%9f%9f%e5%90%8d%e4%bc%aa%e7%bb%91%e5%ae%9a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android LinearLayout根据状态切换图片(模拟按钮的效果）</title>
		<link>http://chenyc.info/2011/12/android_linearlayout_as_button/</link>
		<comments>http://chenyc.info/2011/12/android_linearlayout_as_button/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 14:58:23 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[LinearLayout]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=731</guid>
		<description><![CDATA[在Android中Button可以根据选中，点击等状态切换图片，我想用LinearLayout实现类似的功能， 但是默认情况下pressed状态“容器类”（继承于ViewGroup的类）是接收不到的， 所以LinearLayout的按下就没有效果，后来分析代码，可以通过设置setAddStatesFromChildren 方法获得内部View的状态，就可以取得pressed状态。 linearLayout.setAddStatesFromChildren(true); 还有一个相反的方法setDuplicateParentStateEnabled，内部类获得外部容器类的状态， 这个方法和setAddStatesFromChildren不能同时设置，同时设置会产生异常。]]></description>
			<content:encoded><![CDATA[<p><font size="2" face="宋体">在Android中Button可以根据选中，点击等状态切换图片，我想用LinearLayout实现类似的功能，</font></p>
<p><font size="2" face="宋体">但是默认情况下pressed状态“容器类”（继承于ViewGroup的类）是接收不到的，</font></p>
<p><font size="2"><font face="宋体">所以LinearLayout的按下就没有效果，后来分析代码，可以通过设置<span style="color: #0000ff">setAddStatesFromChildren</span></font></font></p>
<p><span style="color: #0000ff"></span><font size="2" face="宋体">方法获得内部View的状态，就可以取得pressed状态。</font></p>
<blockquote><p><span style="color: #0000ff"><font size="2" face="宋体">linearLayout.setAddStatesFromChildren(true);</font></span></p>
</blockquote>
<p><font size="2" face="宋体"></font></p>
<p><font size="2" face="宋体">还有一个相反的方法<span style="color: #0000ff">setDuplicateParentStateEnabled</span>，内部类获得外部容器类的状态，</font></p>
<p><font size="2" face="宋体">这个方法和<span style="color: #0000ff">setAddStatesFromChildren</span>不能同时设置，同时设置会产生异常。</font></p>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2011/12/android_linearlayout_as_button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android layout布局相关的注意点</title>
		<link>http://chenyc.info/2011/12/android-layout%e5%b8%83%e5%b1%80%e7%9b%b8%e5%85%b3%e7%9a%84%e6%b3%a8%e6%84%8f%e7%82%b9/</link>
		<comments>http://chenyc.info/2011/12/android-layout%e5%b8%83%e5%b1%80%e7%9b%b8%e5%85%b3%e7%9a%84%e6%b3%a8%e6%84%8f%e7%82%b9/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 14:19:20 +0000</pubDate>
		<dc:creator>阳春面</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://chenyc.info/?p=726</guid>
		<description><![CDATA[1.不要过多的嵌套布局，特别是在ListView中需要重复获取的情况下。嵌套布局的情况可以采用RelativeLayout替代LinearLayout,减少嵌套层数。 2.可以采用SDK工具里的hierarchyviewer，分析layout的执行效率。 3.利用新版的ADT(adt1.6)的提示功能，纠正布局文件中影响性能的部分。 4.在采用LinearLayout布局时，尽量不要嵌套中使用layout_weight属性，这会导致所有的内部VIew执行两次measure. 5.对于公用的layout编写,可以采用&#60;merge&#62;作为父标签，这样include到其他layout中后，merge标签不会作为容器，可以减少layout层次。 &#60;merge xmlns:android=&#34;http://schemas.android.com/apk/res/android&#34;&#62; &#60;Button android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;wrap_content&#34; android:text=&#34;@string/add&#34;/&#62; &#60;Button android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;wrap_content&#34; android:text=&#34;@string/delete&#34;/&#62; &#60;/merge&#62; 6.采用ViewStub按需加载View &#60;ViewStub     android:id=&#34;@+id/stub_import&#34;     android:inflatedId=&#34;@+id/panel_import&#34;     android:layout=&#34;@layout/progress_overlay&#34;     android:layout_width=&#34;fill_parent&#34;     android:layout_height=&#34;wrap_content&#34;     android:layout_gravity=&#34;bottom&#34; /&#62; 加载方法： View importPanel &#8230; <a href="http://chenyc.info/2011/12/android-layout%e5%b8%83%e5%b1%80%e7%9b%b8%e5%85%b3%e7%9a%84%e6%b3%a8%e6%84%8f%e7%82%b9/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1.不要过多的嵌套布局，特别是在ListView中需要重复获取的情况下。嵌套布局的情况可以采用<code><a href="http://developer.android.com/reference/android/widget/RelativeLayout.html">RelativeLayout</a>替代<a href="http://developer.android.com/reference/android/widget/LinearLayout.html">LinearLayout</a>,减少嵌套层数。</code></p>
<p>2.可以采用SDK工具里的<code>hierarchyviewer，分析layout的执行效率。</code></p>
<p><img src="http://developer.android.com/images/training/hierarchy-linearlayout.png" alt="" /></p>
<p><img src="http://developer.android.com/images/training/hierarchy-layouttimes.png" alt="" /></p>
<p>3.利用新版的ADT(adt1.6)的提示功能，纠正布局文件中影响性能的部分。</p>
<p>4.在采用<a href="http://developer.android.com/reference/android/widget/LinearLayout.html">LinearLayout</a>布局时，尽量不要嵌套中使用layout_weight属性，这会导致所有的内部VIew执行两次measure.</p>
<p>5.对于公用的layout编写,可以采用&lt;merge&gt;作为父标签，这样include到其他layout中后，merge标签不会作为容器，可以减少layout层次。</p>
<pre>&lt;merge xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

&lt;Button
android:layout_width=&quot;fill_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:text=&quot;@string/add&quot;/&gt;

&lt;Button
android:layout_width=&quot;fill_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:text=&quot;@string/delete&quot;/&gt;

&lt;/merge&gt;</pre>
<p>6.采用ViewStub按需加载View</p>
<pre>&lt;ViewStub
    android:id=&quot;@+id/stub_import&quot;
    android:inflatedId=&quot;@+id/panel_import&quot;
    android:layout=&quot;@layout/progress_overlay&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:layout_gravity=&quot;bottom&quot; /&gt;</pre>
<p>加载方法：</p>
<pre>
View importPanel = ((ViewStub) findViewById(R.id.stub_import)).inflate();
</pre>
<p>加载完成后，ViewStub的Id就不再有效了</p>
<p>7.在ListView中采用ViewHolder保存View的引用，不要重复使用findViewById方法，<br />
这样可加快执行的性能。</p>
<pre>
ViewHolder holder = new ViewHolder();
holder.icon = (ImageView) convertView.findViewById(R.id.listitem_image);
holder.text = (TextView) convertView.findViewById(R.id.listitem_text);
holder.timestamp = (TextView) convertView.findViewById(R.id.listitem_timestamp);
holder.progress = (ProgressBar) convertView.findViewById(R.id.progress_spinner);
convertView.setTag(holder);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chenyc.info/2011/12/android-layout%e5%b8%83%e5%b1%80%e7%9b%b8%e5%85%b3%e7%9a%84%e6%b3%a8%e6%84%8f%e7%82%b9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

