<?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; Notes</title>
	<atom:link href="http://fwso.cn/category/notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://fwso.cn</link>
	<description>行.思.悟</description>
	<lastBuildDate>Sat, 21 Jan 2012 03:33:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>在JavaScript中使用in操作符</title>
		<link>http://fwso.cn/notes/%e5%9c%a8javascript%e4%b8%ad%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6/</link>
		<comments>http://fwso.cn/notes/%e5%9c%a8javascript%e4%b8%ad%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 15:12:48 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Operator]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=260</guid>
		<description><![CDATA[今天在阅读jQuery源码的时候看到在if中使用in操作符，发现原来in不仅仅是用在for中，看来对JavaScript的了解实在太少了:) 对我来说最有用的功能是像PHP中的in_array一样使用，其用途可以类似于PHP中的isset(感谢@littlexiang纠正)，如下面的代码所示： var arr = [1, 2, 3, 4, 5]; var obj = { "4": true, "6":false, "9":true, "11":true }; if ( 2 in arr) { alert('2 in arr'); } else { alert('2 NOT in arr'); } if ( 4 &#8230; <a href="http://fwso.cn/notes/%e5%9c%a8javascript%e4%b8%ad%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今天在阅读jQuery源码的时候看到在if中使用in操作符，发现原来in不仅仅是用在for中，看来对JavaScript的了解实在太少了:)</p>
<p><del datetime="2011-07-12T11:48:36+00:00">对我来说最有用的功能是像PHP中的in_array一样使用</del>，其用途可以类似于PHP中的isset(感谢<a href="http://www.ballsache.com/blog/" target="_blank">@littlexiang</a>纠正)，如下面的代码所示：</p>
<pre class="brush:javascript">
var arr = [1, 2, 3, 4, 5];
var obj = {
			"4": true,
			"6":false,
			"9":true,
			"11":true
		};

if ( 2 in arr) {
	alert('2 in arr');
} else {
	alert('2 NOT in arr');
}

if ( 4 in obj) {
	alert('4 in obj');
} else {
	alert('4 NOT in obj');
}

if ( 6 in obj) {
	alert('6 in obj');
} else {
	alert('6 NOT in obj');
}

if ( 21 in arr) {
	alert('21 in arr');
} else {
	alert('21 NOT in arr');
}

if ( 2 in obj) {
	alert('2 in obj');
} else {
	alert('2 NOT in obj');
}

if ( 0 in arr) {
	alert('0 in arr');
} else {
	alert('0 NOT in arr');
}

if ( 5 in arr) {
	alert('5 in arr');
} else {
	alert('5 NOT in arr');
}
</pre>
<p>For more information, please refer to: <a href="http://www.caveofprogramming.com/javascript-2/javascript-in-using-the-in-operator-to-iterate-through-arrays-and-objects/">Using the ‘In’ Operator to Iterate Through Arrays and Objects</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/%e5%9c%a8javascript%e4%b8%ad%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE下Select InnerHTML的问题</title>
		<link>http://fwso.cn/notes/ie%e4%b8%8bselect-innerhtml%e7%9a%84%e9%97%ae%e9%a2%98/</link>
		<comments>http://fwso.cn/notes/ie%e4%b8%8bselect-innerhtml%e7%9a%84%e9%97%ae%e9%a2%98/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 14:54:04 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[问题]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=257</guid>
		<description><![CDATA[在IE下，包括IE8, 9，不能使用innerHTML对select设置option内容，如下面的代码无法得到预期的结果： document.getElementById('mySelectId').innerHTML = ' New value '; 这个问题在2003年就已经发布在微软支持网站上，但到IE9依然存在这个问题，微软似乎并不把它当成一个问题，详细请参考：http://support.microsoft.com/kb/276228，该文档提出了几种解决方案。 我倾向于采用文章中提到的第三种方法来替代innerHTML: var daysNode = document.getElementById('mySelectId'); function updateOptions () { while ( daysNode.firstChild ) { daysNode.removeChild( daysNode.firstChild ); } for (var i = 1; i < 10; i++) { var options = &#8230; <a href="http://fwso.cn/notes/ie%e4%b8%8bselect-innerhtml%e7%9a%84%e9%97%ae%e9%a2%98/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>在IE下，包括IE8, 9，不能使用innerHTML对select设置option内容，如下面的代码无法得到预期的结果：</p>
<pre class="brush:javascript">
document.getElementById('mySelectId').innerHTML = '
<option value="new_value">New value</option>

';
</pre>
<p>这个问题在2003年就已经发布在微软支持网站上，但到IE9依然存在这个问题，微软似乎并不把它当成一个问题，详细请参考：http://support.microsoft.com/kb/276228，该文档提出了几种解决方案。</p>
<p>我倾向于采用文章中提到的第三种方法来替代innerHTML:</p>
<pre class="brush:javascript">
var daysNode = document.getElementById('mySelectId');

function updateOptions () {

	while ( daysNode.firstChild ) {
		daysNode.removeChild( daysNode.firstChild );
	}

	for (var i = 1; i < 10; i++) {
		var options = document.createElement('option');
		options.setAttribute('value', i);
		options.appendChild(document.createTextNode(i));
		daysNode.appendChild(options);
	}
}
</pre>
<p>完整示例请参考：http://code.google.com/p/mixedlab/source/browse/trunk/javascript/ie_select_dom.html</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/ie%e4%b8%8bselect-innerhtml%e7%9a%84%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>该博客域名解析出现问题</title>
		<link>http://fwso.cn/notes/%e8%af%a5%e5%8d%9a%e5%ae%a2%e5%9f%9f%e5%90%8d%e8%a7%a3%e6%9e%90%e5%87%ba%e7%8e%b0%e9%97%ae%e9%a2%98/</link>
		<comments>http://fwso.cn/notes/%e8%af%a5%e5%8d%9a%e5%ae%a2%e5%9f%9f%e5%90%8d%e8%a7%a3%e6%9e%90%e5%87%ba%e7%8e%b0%e9%97%ae%e9%a2%98/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 05:41:05 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=149</guid>
		<description><![CDATA[今天突然发现我的博客无法访问，原以为是服务器出了什么问题，结果发现是DNS解析出错，但在几分钟之后恢复正常，具体原因还不清楚！ 域名被指向了59.37.71.87：]]></description>
			<content:encoded><![CDATA[<p>今天突然发现我的博客无法访问，原以为是服务器出了什么问题，结果发现是DNS解析出错，但在几分钟之后恢复正常，具体原因还不清楚！</p>
<p><a href="http://fwso.cn/wp-content/uploads/2010/12/dns-error.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/12/dns-error.jpg" alt="" title="dns-error" width="589" height="422" class="alignnone size-full wp-image-150" /></a></p>
<p>域名被指向了59.37.71.87：<br />
<a href="http://fwso.cn/wp-content/uploads/2010/12/dns-error2.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/12/dns-error2.jpg" alt="" title="dns-error2" width="414" height="136" class="alignnone size-full wp-image-151" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/%e8%af%a5%e5%8d%9a%e5%ae%a2%e5%9f%9f%e5%90%8d%e8%a7%a3%e6%9e%90%e5%87%ba%e7%8e%b0%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nested function extension of gcc</title>
		<link>http://fwso.cn/notes/nested-function-extension-of-gcc/</link>
		<comments>http://fwso.cn/notes/nested-function-extension-of-gcc/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 05:49:04 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[gcc]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=143</guid>
		<description><![CDATA[gcc supports Nested functions as the following example shows: void isort (int arr[], int len) { //shift_element() is the nested function void shift_element (int i) { int ivalue; for (ivalue=arr[i]; i &#038;&#038; arr[i-1] > ivalue; i--) { arr[i] = arr[i-1]; &#8230; <a href="http://fwso.cn/notes/nested-function-extension-of-gcc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://gcc.gnu.org/">gcc</a>  supports Nested functions as the following example shows:</p>
<pre class="brush:c">
void isort (int arr[], int len) {

        //shift_element() is the nested function
	void shift_element (int i) {
		int ivalue;
		for (ivalue=arr[i]; i &#038;&#038; arr[i-1] > ivalue; i--) {
			arr[i] = arr[i-1];
		}

		arr[i] = ivalue;
	}

	int i;
	for (i=1; i < len; i++) {
		if (arr[i] < arr[i-1]) {
			shift_element(i);
		}
	}
}
</pre>
<p>gcc also provides many other useful features which can NOT be found in ANSI standard c. For more information, refer to  <a href="http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html">Extensions to the C Language Family</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/nested-function-extension-of-gcc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个页面加载速度分析</title>
		<link>http://fwso.cn/php/%e4%b8%80%e4%b8%aa%e9%a1%b5%e9%9d%a2%e5%8a%a0%e8%bd%bd%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90/</link>
		<comments>http://fwso.cn/php/%e4%b8%80%e4%b8%aa%e9%a1%b5%e9%9d%a2%e5%8a%a0%e8%bd%bd%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 05:41:31 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=109</guid>
		<description><![CDATA[昨日同事发现项目的其中一个页面加载速度比其它页面要慢一点，主要是在IE上加载的时候比其它页面多一点停顿时间。该页面是用于查询和显示，数据的数据的读取涉及到多个表，并且数据量相对比较大，所以第一反应可能是数据查询存在问题。 服务器端测试 为了找出效率瓶颈所在，我用Xdebug的profiling功能来分析页面的执行时间,结果发现确实在获取数据的时候花费了大量时间，另外是在Smarty显示模板的时候经几次测试结果差不多，下图是测试结果： 首先对数据查询的SQL进行了分析，发现其中一个表可以增加两个索引，添加索引之后查询时间有了明显减少，如下图所示： 第一次执行 第二次执行 由于页面数据比较多，对Smarty显示慢的原因暂时没有进行优化。 客户端测试 另一个问题是，这个页面在Firefox与Chrome上的显示时间比IE明显要快，而该页面的HTML结构相对比较复杂，所以有理由相信这跟IE的页面处理效率特别是页面渲染速度有关。 添加索引前在Chrome中的加载情况： 添加索引后在Chrome中加载速度的体现： 总结 其实页面的加载速度跟很多因素有关，数据库结构、SQL查询语句、程序实现、HTML结构、浏览器、服务器等都能影响网页的速度，这里只是很简单的测试，希望有时间对页面性能进行深入研究。]]></description>
			<content:encoded><![CDATA[<p>昨日同事发现项目的其中一个页面加载速度比其它页面要慢一点，主要是在IE上加载的时候比其它页面多一点停顿时间。该页面是用于查询和显示，数据的数据的读取涉及到多个表，并且数据量相对比较大，所以第一反应可能是数据查询存在问题。</p>
<h3>服务器端测试</h3>
<p>为了找出效率瓶颈所在，我用<a href="http://xdebug.org/" title="Xdebug">Xdebug</a>的profiling功能来分析页面的执行时间,结果发现确实在获取数据的时候花费了大量时间，另外是在Smarty显示模板的时候经几次测试结果差不多，下图是测试结果：</p>
<p><a href="http://fwso.cn/wp-content/uploads/2010/10/xdebug-test-01.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/10/xdebug-test-01.jpg" alt="" title="xdebug-test-01" width="587" height="360" class="alignnone size-full wp-image-110" /></a></p>
<p>首先对数据查询的SQL进行了分析，发现其中一个表可以增加两个索引，添加索引之后查询时间有了明显减少，如下图所示：</p>
<p>第一次执行<br />
<a href="http://fwso.cn/wp-content/uploads/2010/10/xdebug-test-02.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/10/xdebug-test-02.jpg" alt="" title="xdebug-test-02" width="543" height="294" class="alignnone size-full wp-image-113" /></a></p>
<p>第二次执行<br />
<a href="http://fwso.cn/wp-content/uploads/2010/10/xdebug-test-03.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/10/xdebug-test-03.jpg" alt="" title="xdebug-test-03" width="542" height="274" class="alignnone size-full wp-image-112" /></a></p>
<p>由于页面数据比较多，对Smarty显示慢的原因暂时没有进行优化。</p>
<h3>客户端测试</h3>
<p>另一个问题是，这个页面在Firefox与Chrome上的显示时间比IE明显要快，而该页面的HTML结构相对比较复杂，所以有理由相信这跟IE的页面处理效率特别是页面渲染速度有关。</p>
<p>添加索引前在Chrome中的加载情况：<br />
<a href="http://fwso.cn/wp-content/uploads/2010/10/ctest-00.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/10/ctest-00.jpg" alt="" title="ctest-00" width="477" height="74" class="alignnone size-full wp-image-117" /></a></p>
<p>添加索引后在Chrome中加载速度的体现：<br />
<a href="http://fwso.cn/wp-content/uploads/2010/10/ctest-01.jpg"><img src="http://fwso.cn/wp-content/uploads/2010/10/ctest-01.jpg" alt="" title="ctest-01" width="541" height="80" class="alignnone size-full wp-image-118" /></a></p>
<h3>总结</h3>
<p>其实页面的加载速度跟很多因素有关，数据库结构、SQL查询语句、程序实现、HTML结构、浏览器、服务器等都能影响网页的速度，这里只是很简单的测试，希望有时间对页面性能进行深入研究。</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/php/%e4%b8%80%e4%b8%aa%e9%a1%b5%e9%9d%a2%e5%8a%a0%e8%bd%bd%e9%80%9f%e5%ba%a6%e5%88%86%e6%9e%90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>像成功者一样思考</title>
		<link>http://fwso.cn/notes/%e5%83%8f%e6%88%90%e5%8a%9f%e8%80%85%e4%b8%80%e6%a0%b7%e6%80%9d%e8%80%83/</link>
		<comments>http://fwso.cn/notes/%e5%83%8f%e6%88%90%e5%8a%9f%e8%80%85%e4%b8%80%e6%a0%b7%e6%80%9d%e8%80%83/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 15:27:13 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=69</guid>
		<description><![CDATA[最近阅读了《像成功者一样思考》这本书，个人觉得这本书非常不错。并且摘录了部分经典语句，以便反复思考。 <a href="http://fwso.cn/notes/%e5%83%8f%e6%88%90%e5%8a%9f%e8%80%85%e4%b8%80%e6%a0%b7%e6%80%9d%e8%80%83/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近阅读了<a target="_blank" href="http://www.amazon.cn/mn/detailApp?asin=B002Q8GJS6&#038;tag=fwso-23&#038;camp=404&#038;creative=2024&#038;linkCode=as1&#038;creativeASIN=B002Q8GJS6&#038;adid=1T79Z7S2WC3SYGF0X7FP&#038;" target="_blank">像成功者一样思考</a>，个人觉得这本书非常不错。并且摘录了部分经典语句，以便反复思考。</p>
<p>1. 真诚面对自己、面对工作是一笔财富。记住，这笔财富用不着刻意保护。</p>
<p>2. 创新：关键在于留心，大脑和感官要随时对新鲜的刺激保持敏感。</p>
<p>3. 无论你的志趣是什么，都要学会巧妙地组合这样一来，就踏上了发明创造之路。胸怀高远的人要有丰富热烈的思绪和冲动，以使智力敏锐，所以，一定要让你的头脑尽量保持在最活跃的状态。</p>
<p>4. 在生活和工作中，要保持热情的团队精神你会得到很好甚至惊人的结果。</p>
<p>5. 有时，我们自己的心火几近熄灭，别人把它重新点燃。每个人都该心怀感恩，感激那个点燃我们心火的人。——阿尔伯特.史威泽</p>
<p>6. 一定要对新观念、新事物保持开放的心态。</p>
<p>7. 学习需要一点毅力，不过，学习的过程也可能像一次历险。它还可以为你踏上新的旅程作好准备。</p>
<p>8. 你没有看见别人干活，不等于人家在闲暇时或者私底下没有干活。</p>
<p>9. 思维敏捷、反应快是多年钻研、磨砺的结果。</p>
<p>10. 积蓄能量只能靠自己。</p>
<p>11. 你得夜以继日、心无旁骛才行。</p>
<p>12. 人可以通过意识的努力使生命超拔，这种能力是确定的，我不知道还有什么比这一点更激动人心。—— 梭罗</p>
<p>13. 伟大的构想终归是构想，除非你积极行动，把它落实。</p>
<p>14. 统帅可以吃败仗，却没有理由对此感到惊讶。</p>
<p>15. 不要贱卖自己。贱卖自己是很可悲的，想一想都可悲。</p>
<p>16. 不要觉得差不多就行了，无论付出还是索取，差不多都是不行的。</p>
<p>17. 争取完美，保持对奇迹的期待和好奇，你会发现，你已严阵以待，正在全神贯注地准备着赢得大满贯。</p>
<p>18. 理想主义只要不脱开理性，没什么不好。梦想家把世界推进到全新的广度和深度。</p>
<p>19. 积累经验，蓄养锐气，为自己打好基础，是为了干一番大事业。要知道，你随时可能置身伟大创想的最前沿。</p>
<p>20. 突破往往就在我们埋头干别的事时发生。</p>
<p>21. 勤奋是创意的吸铁石，懒散和吊儿郎当则会滑向自暴自弃。</p>
<p>22. 每个人都蕴藏着独一无二的潜质可供挖掘。</p>
<p>23. 不要随波逐流，请赶快上岸，行动起来吧！</p>
<p>24. 智慧是若干因素作用的结果：一是经验，一是知识.</p>
<p>25. 想当冠军就要不甘心碌碌无为。冠军胸怀高远，冠军目标坚定，冠军严于律己，冠军拼搏时气吞山河。</p>
<p>26. 与自己竞争，做最好的自己。</p>
<p>27. 害怕与众不同，就是害怕做最好的自己。</p>
<p>28. 生活是一门艺术，那就做一名艺术家，做最好的自己吧！</p>
<p>29. 要是你打算在这个世界上干出点名堂，一定要及时掌握全球的动态，一天也不能松懈。</p>
<p>30. 简短、直接、明白</p>
<p>31. 你的目光既要执著于理想，又专注于现实。</p>
<p>32. 不用太强调问题，要突出解决办法.</p>
<p>33. 成功的心态包括责任感和专注。</p>
<p>34. 要保持强劲的动力。</p>
<p>35. 从挫折和错误中汲取营养。</p>
<p>36. 宣传自己，要习惯于肯定自己</p>
<p>37. 要相信你的直觉</p>
<p>38. 事物的发展具有周期性，要能伸能缩，要坚定执著，要独树一帜，要保持积极的心态。</p>
<p>39. 要懂得理财。</p>
<p>40. 提前计划很重要，而保持灵活性、不受计划拘泥也很重要。</p>
<p>41. 记住，你要执著、顽强，对可能出现耽搁、可能走弯路作好心理准备。</p>
<p>42. 成功环环相扣</p>
<p>43. 所谓智慧，就是什么时候该等待，什么时候该前进。</p>
<p>44. 不要怕冒险</p>
<p>45. 要严肃地看待工作，不要严肃地看待自己。</p>
<p>46. 理想、情操在生意场上绝无位置只会耽误大家的时间。</p>
<p>47. 要有个人魅力。</p>
<p>48. 不要低估自己</p>
<p>49. 逆流而动</p>
<p>50. 要找到自己效率最高的工作方式。</p>
<p>51. 追求成功不总是一帆风顺的。</p>
<p>52. 激情和效率</p>
<p>53. 研读《<a target="_blank" title="孙子兵法" href="http://www.amazon.cn/mn/searchApp?source=fwso-23&amp;searchType=1&amp;keywords=孙子兵法">孙子兵法</a>》</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/%e5%83%8f%e6%88%90%e5%8a%9f%e8%80%85%e4%b8%80%e6%a0%b7%e6%80%9d%e8%80%83/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[转载]受益终身的故事</title>
		<link>http://fwso.cn/notes/%e8%bd%ac%e8%bd%bd%e5%8f%97%e7%9b%8a%e7%bb%88%e8%ba%ab%e7%9a%84%e6%95%85%e4%ba%8b/</link>
		<comments>http://fwso.cn/notes/%e8%bd%ac%e8%bd%bd%e5%8f%97%e7%9b%8a%e7%bb%88%e8%ba%ab%e7%9a%84%e6%95%85%e4%ba%8b/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 01:14:46 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=27</guid>
		<description><![CDATA[小故事，大道理，今天在QQ空间看到这几个故事，感觉很有意思，故转载于此，以时常回味。 <a href="http://fwso.cn/notes/%e8%bd%ac%e8%bd%bd%e5%8f%97%e7%9b%8a%e7%bb%88%e8%ba%ab%e7%9a%84%e6%95%85%e4%ba%8b/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>1、买烟</strong></p>
<p>甲去买烟，烟29元，但他没火柴，跟店员说：．“顺便送一盒火柴吧。”店员没给。</p>
<p>乙去买烟，烟29元，他也没火柴，跟店员说：“便宜一毛吧。”最后，他用这一毛买一盒火柴。</p>
<p>这是最简单的心理边际效应。第一种：店主认为自己在一个商品上赚钱了，另外一个没赚钱。赚钱感觉指数为1。第二种：店主认为两个商品都赚钱了，赚钱指数为2。当然心理倾向第二种了。同样，这种心理还表现在买一送一的花招上，顾客认为有一样东西不用付钱，就赚了，其实都是心理边际效应在作怪。</p>
<p>变换一种方式往往能起到意想不到的效果!通常很多事情换一种做法结果就不同了。人生道路上，改善心智模式和思维方式是很重要的。</p>
<p><strong>2.聪明的男孩</strong></p>
<p>有个小男孩，有一天妈妈带着他到杂货店去买东西，老板看到这个可爱的小孩，就打开一罐糖果，要小男孩自己拿一把糖果。但是这个男孩却没有任何动作。几次的邀请之后，老板亲自抓了一大把糖果放进他的口袋中。回到家中，母亲好奇地问小男孩，为什么没有自己去抓糖果而要老板抓呢?小男孩回答很妙：“因为我的手比较小呀!而老板的手比较大，所以他拿的一定比我拿的多很多!”</p>
<p>这是一个聪明的孩子，他知道自己的有限，而更重要的，他也知道别人比自己强。凡事不只靠自己的力量，学会适时地依靠他人，是一种谦卑，更是一种聪明。</p>
<p><strong>3.听的艺术</strong></p>
<p>美国知名主持人林克莱特有一天访问一名小朋友，问他说：“你长大后想要当做什么呀?”小朋友天真地回答：“嗯……我要当飞机的驾驶员!”林克莱特接着问：“如果有一天，你的飞机飞到太平洋上空所有引擎都熄火了，你会怎么办?”小朋友想了想：“我会先告诉坐在飞机上的人绑好安全带，然后我挂上我的降落伞跳出去。”当在场的观众笑得东倒西歪时，林克莱特继续注视着这孩子，想看他是不是自作聪明的家伙。没想到，接着孩子的两行热泪夺眶而出，这才使得林克莱特发觉这孩子的悲悯之心远非笔墨所能形容。于是林克莱特问他说：为什么你要这么做?”小孩的答案透露了这个孩子真挚的想法：“我要去拿燃料，我还要回来!!!”</p>
<p>这就是“听的艺术”。一是听话不要听一半。二是不要把自己的意思，投射到别人所说的话上头。要学会聆听，用心听，虚心听。</p>
<p><strong>4.两个和尚</strong></p>
<p>有两个和尚分别住在相邻的两座山上的庙里。两山之间有一条溪，两个和尚每天都会在同一时间下山去溪边挑水。不知不觉已经过了五年。 突然有一天，左边这座山的和尚没有下山挑水，右边那座山的和尚心想：“他大概睡过头了。”便不以为然。哪知第二天，左边这座山的和尚，还是没有下山挑水，第三天也一样，直到过了一个月，右边那座山的和尚想：“我的朋友可能生病了。”于是他便爬上了左边这座山去探望他的老朋友。当他看到他的老友正在庙前打太极拳时。他十分好奇地问：“你已经一个月没有下山挑水了，难道你可以不喝水吗?”左边这座山的和尚指着一口井说：“这五年来，我每天做完功课后，都会抽空挖这口井。如今，终于让我挖出水，我就不必再下山挑水，我可以有更多时间练我喜欢的太极拳了。”</p>
<p>我们常常会忘记把握下班后的时间，挖一口属于自己的井，培养自己另一方面的实力。这样在未来当我们年纪大了，我们还依然会有水喝，而且还能喝得很悠闲。</p>
<p><strong>5.学会舍弃</strong></p>
<p>有两个人相约到山上去寻找精美的石头，甲背了满满的一筐，乙的筐里只有一个他认为是最精美的石头。甲就笑乙：“你为什么只挑一个啊?”乙说：“漂亮的石头虽然多，但我只选一个最精美的就够了。”甲笑而不语，下山的路上，甲感到负担越来越重，最后不得已不断地从一筐的石头中挑一个最差的扔下，到下山的时候他的筐里结果只剩下一个石头!</p>
<p>人生中会有许多的东西，值得留恋，有的时候你应该学会去放弃。</p>
<p><strong>6.把心径扩大1毫米</strong></p>
<p>有一家牙膏厂，产品优良，包装精美，受到顾客的喜爱，营业额连续10年递增，每年的增长率在10％～20％。可到了第11年，业绩停滞下来，以后两年也如此。公司经理召开高级会议，商讨对策。会议中，公司总裁许诺说：谁能想出解决问题的办法，让公司的业绩增长，重奖10万元。有位年轻经理站起来，递给总裁一张纸条，总裁看完后，马上签了一张10万元的支票给了这位经理。 那张纸条上写着：将现在牙膏开口扩大1毫米。消费者每天早晨挤出同样长度的牙膏，开口扩大了l毫米，每个消费者就多用1毫米宽的牙膏，每天的消费量将多出多少呢!公司立即更改包装。第14年，公司的营业额增加了32％。</p>
<p>面对生活中的变化，我们常常习惯过去的思维方法。其实只要你把心径扩大1毫米，你就会看到生活中的变化都有它积极的一面，充满了机遇和挑战.</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/%e8%bd%ac%e8%bd%bd%e5%8f%97%e7%9b%8a%e7%bb%88%e8%ba%ab%e7%9a%84%e6%95%85%e4%ba%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>初识Makefile</title>
		<link>http://fwso.cn/notes/%e5%88%9d%e8%af%86makefile/</link>
		<comments>http://fwso.cn/notes/%e5%88%9d%e8%af%86makefile/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 07:34:41 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Makefile]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=25</guid>
		<description><![CDATA[其实很早以前就知道Makefile, 并且很多时候在Linux下安装程序时也间接地用到了它，不过今天是第一次学习使用。 <a href="http://fwso.cn/notes/%e5%88%9d%e8%af%86makefile/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>继续学习<a title="Advanced Linux Programming" href="http://www.advancedlinuxprogramming.com/alp-folder">Advanced Linux Programming</a>.</p>
<p>Java程序员应该很熟悉Ant这个构建工具，Makefile是类似的自动化构建工具，很多C/C++程序都是用Makefile来构建的。<br />
同样使用《<a title="安装C/C++编译环境" href="http://fwso.cn/notes/%E5%AE%89%E8%A3%85cc%E7%BC%96%E8%AF%91%E7%8E%AF%E5%A2%83/" target="_blank">安装C/C++编译环境</a>》的示例程序，初步了解Makefile的使用.</p>
<p>下面的Makefile将自动完成编译、连接和工作。</p>
<pre class="brush:plain">
reciprocal: main.o reciprocal.o
	g++ $(CFLAGS) -o reciprocal main.o reciprocal.o

main.o: main.c reciprocal.hpp
	gcc $(CFLAGS) -c main.c

reciprocal.o: reciprocal.cpp reciprocal.hpp
	g++ $(CFLAGS) -c reciprocal.cpp

clean:
	rm -f *.o reciprocal
</pre>
<p>冒号左边是目标(target)，与Ant中的target类似，冒号右边是该目标的依赖。第一目标下面是该目标的执行规则，规则左边必须有Tab空格。<br />
其中的$(CFLAGS)是make变量，可以在Makefile文件中定义，也可以在命令行一定义。</p>
<p>执行make命令将自动构建该程序：</p>
<pre class="brush:plain">
make CFLAGS=-o2
</pre>
<p>定义CFLAGS, -o2为编译优化程序的参数：</p>
<pre class="brush:plain">
make
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/%e5%88%9d%e8%af%86makefile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装C/C++编译环境</title>
		<link>http://fwso.cn/notes/%e5%ae%89%e8%a3%85cc%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83/</link>
		<comments>http://fwso.cn/notes/%e5%ae%89%e8%a3%85cc%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 06:35:28 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Notes]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=13</guid>
		<description><![CDATA[C/C++编译环境的安装虽然很简单，但还是记录于此，以便日后参考，也希望对初学者有所帮助。 <a href="http://fwso.cn/notes/%e5%ae%89%e8%a3%85cc%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>操作系统CentOS 5</p>
<p>如果gcc命令不存在，直接用以下命令安装:</p>
<pre class="brush:plain">
yum install gcc
</pre>
<p>但这默认只安装C语言编译器，如果需要C++编辑器,还需要安装gcc-c++,执行以下命令即可:</p>
<pre class="brush:plain">
yum install gcc-c++
</pre>
<h3>测试编译环境</h3>
<p>下面程序来自《<a href="http://www.advancedlinuxprogramming.com/alp-folder" title="Advanced Linux Programming">Advanced Linux Programming</a>》.</p>
<p>主程序main.c</p>
<pre class="brush:c">
/**
 * File: main.c
 */
#include &lt;stdio.h&gt;
#include "reciprocal.hpp"

int main(int argc, char** argv)
{
	int i;
	i = atoi (argv[1]);
	printf("The reciprocal of %d is %g\n", i, reciprocal(i));
	return 0;
}
</pre>
<p>C++程序reciprocal.cpp</p>
<pre class="brush:cpp">
/**
 * File: reciprocal.cpp
 */
#include &lt;cassert&gt;
#include "reciprocal.hpp"

double reciprocal (int i) {
	assert(i != 0);
	return 1.0/i;
}
</pre>
<p>C++头文件reciprocal.hpp</p>
<pre class="brush:cpp">
/**
 * File: reciprocal.hpp
 */
#ifdef __cplusplus
extern "C" {
#endif

	extern double reciprocal (int i);

#ifdef __cplusplus
}
#endif
</pre>
<p>分别执行以下命令:</p>
<p>1. 将main.c编译为目标程序</p>
<pre class="brush:plain">
gcc -c main.c
</pre>
<p>2. 将reciprocal.cpp编译成目标程序</p>
<pre class="brush:plain">
g++ -c reciprocal.cpp
</pre>
<p>3. 连接目标程序</p>
<pre class="brush:plain">
g++ -o reciprocal main.o reciprocal.o
</pre>
<p>4.  运行reciprocal</p>
<pre class="brush:plain">
./reciprocal 2
</pre>
<p>应该输出：The reciprocal of 2 is 0.5.</p>
<p>完成</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/%e5%ae%89%e8%a3%85cc%e7%bc%96%e8%af%91%e7%8e%af%e5%a2%83/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Measure Twice, Cut Once</title>
		<link>http://fwso.cn/notes/measure-twice-cut-once/</link>
		<comments>http://fwso.cn/notes/measure-twice-cut-once/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 03:13:54 +0000</pubDate>
		<dc:creator>James Tang</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://fwso.cn/?p=9</guid>
		<description><![CDATA[Code Complete这本书很有名，可是一直没有时间阅读，今天读了一点，受益匪浅，更为我目前所在项目的开发过程感到羞耻。 <a href="http://fwso.cn/notes/measure-twice-cut-once/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这是Code Complete一个章节的标题，完整的标题是Measure Twice, Cut Once: Upstream Prerequisites，其一语道出了软件上流设计的重要性。而在现实开发中，很多人总是有意无意的忽略了这一些，让整个开发过程变成：简单需求+编码+简单测试。而这样的后果就是整个系统没有一个整体的架构，代码杂乱无章，程序错漏百出，扩展起来比登天还难&#8230;</p>
<blockquote><p>A good project planner clears rishs out of the way as early as possible so that the bulk of the project can proceed as smoothly as possible.</p></blockquote>
<p>不幸的是，在很多项目中并没有这样的一位策划者，不仅不能尽可能早地清除风险。</p>
]]></content:encoded>
			<wfw:commentRss>http://fwso.cn/notes/measure-twice-cut-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  fwso.cn/category/notes/feed/ ) in 0.35268 seconds, on Feb 8th, 2012 at 3:49 pm CST. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 3:49 pm CST -->
