<?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>梁剑的Blog</title>
	<atom:link href="http://icomes.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://icomes.net</link>
	<description>做有趣的事，做有用的人</description>
	<lastBuildDate>Sat, 05 Nov 2011 18:23:06 +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>监控iPhone 4S发布的Python脚本</title>
		<link>http://icomes.net/2011/11/03/%e7%9b%91%e6%8e%a7iphone-4s%e5%8f%91%e5%b8%83%e7%9a%84python%e8%84%9a%e6%9c%ac/</link>
		<comments>http://icomes.net/2011/11/03/%e7%9b%91%e6%8e%a7iphone-4s%e5%8f%91%e5%b8%83%e7%9a%84python%e8%84%9a%e6%9c%ac/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 15:56:36 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=574</guid>
		<description><![CDATA[但愿不用等太晚：） #!/usr/bin/python &#160; import urllib2 import sys import time &#160; def alarm&#40;&#41;: while True: sys.stdout.write&#40;'\a'&#41; sys.stdout.flush&#40;&#41; &#160; def poll&#40;&#41;: count=0; while True: count = count + 1 now = time.localtime&#40; time.time&#40;&#41; &#41; print '%02d:%02d:%02d %d' % &#40;now.tm_hour, now.tm_min, now.tm_sec, count&#41; try: urllib2.urlopen&#40;'http://store.apple.com/hk-zh/browse/home/shop_iphone/family/iphone/iphone4s'&#41; alarm&#40;&#41; except urllib2.HTTPError as error: pass #print error &#160; try: iphone4 = urllib2.urlopen&#40; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2011%2F02%2F13%2Fzen-of-python%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">The Zen of Python</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F01%2F24%2F%25E5%2588%259D%25E5%25AD%25A6python%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">初学Python</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F08%2F30%2Fanother-hello-world-is-running-on-my-iphone%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Another Hello World is running on my iPhone!</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F04%2F19%2Fiphone-22-firmware%25E4%25B8%258B%25E8%25BD%25BD%25E5%259C%25B0%25E5%259D%2580%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">iPhone 2.2 firmware下载地址</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>但愿不用等太晚：）</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib2</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;">time</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> alarm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
		<span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\a</span>'</span><span style="color: black;">&#41;</span>
		<span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> poll<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	count=<span style="color: #ff4500;">0</span><span style="color: #66cc66;">;</span>
	<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
		count = count + <span style="color: #ff4500;">1</span>
		now = <span style="color: #dc143c;">time</span>.<span style="color: black;">localtime</span><span style="color: black;">&#40;</span> <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%02d:%02d:%02d %d'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>now.<span style="color: black;">tm_hour</span>, now.<span style="color: black;">tm_min</span>, now.<span style="color: black;">tm_sec</span>, count<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">try</span>:
			<span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://store.apple.com/hk-zh/browse/home/shop_iphone/family/iphone/iphone4s'</span><span style="color: black;">&#41;</span>
			alarm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPError</span> <span style="color: #ff7700;font-weight:bold;">as</span> error:
			<span style="color: #ff7700;font-weight:bold;">pass</span>
			<span style="color: #808080; font-style: italic;">#print error</span>
&nbsp;
		<span style="color: #ff7700;font-weight:bold;">try</span>:
			iphone4 = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">'http://store.apple.com/hk-zh/browse/home/shop_iphone/family/iphone/iphone4'</span> <span style="color: black;">&#41;</span>
			html = <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span> iphone4.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
			<span style="color: #ff7700;font-weight:bold;">if</span> html.<span style="color: black;">find</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">'iPhone 4S'</span> <span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span> :
				alarm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">except</span>:
			<span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">#time.sleep(1)</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
	poll<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2011%2F02%2F13%2Fzen-of-python%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">The Zen of Python</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F01%2F24%2F%25E5%2588%259D%25E5%25AD%25A6python%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">初学Python</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F08%2F30%2Fanother-hello-world-is-running-on-my-iphone%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Another Hello World is running on my iPhone!</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F04%2F19%2Fiphone-22-firmware%25E4%25B8%258B%25E8%25BD%25BD%25E5%259C%25B0%25E5%259D%2580%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F11%2F03%2F%25E7%259B%2591%25E6%258E%25A7iphone-4s%25E5%258F%2591%25E5%25B8%2583%25E7%259A%2584python%25E8%2584%259A%25E6%259C%25AC%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">iPhone 2.2 firmware下载地址</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/11/03/%e7%9b%91%e6%8e%a7iphone-4s%e5%8f%91%e5%b8%83%e7%9a%84python%e8%84%9a%e6%9c%ac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Last Lecture</title>
		<link>http://icomes.net/2011/10/15/the-last-lecture/</link>
		<comments>http://icomes.net/2011/10/15/the-last-lecture/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 14:25:07 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[所思所想]]></category>
		<category><![CDATA[演讲]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=566</guid>
		<description><![CDATA[Randy Pausch是CMU的professor，2007年的时候46岁。 和Jobs一样，不幸患上了胰腺癌。 比Jobs更不幸的是，他所患的这种疾病不是罕见的那种，并不能通过手术治愈。 在告别自己无限留恋的妻儿之前，他准备并在CMU做了“The Last Lecture”的演讲，主题是如何实现自己儿时的梦想。 演讲时，他面对的是自己的妻子、朋友、同事和学生；实际上，他是在和未来的孩子对话。 当时，他的孩子分别是5、3、1岁。 他知道，这个演讲会被摄像机记录下来。很多孩子们当时无法明白的话，终有一天可以被理解。 跨越时空的言传身教，伟大的父亲。 从Professor Randy幽默的演讲里，可以领悟到太多的智慧。 具体是什么道理，就请自行领悟吧。 如果看过视频之后，想对Professor Randy了解更多，可以访问http://en.wikipedia.org/wiki/Randy_Pausch。 与演讲相应，有一本已经出版的书，也值得阅读和收藏http://book.douban.com/subject/3034706/。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="3"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="黄子华 – 娱乐圈血肉史2" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2011%2F01%2F22%2F%25E9%25BB%2584%25E5%25AD%2590%25E5%258D%258E-%25E5%25A8%25B1%25E4%25B9%2590%25E5%259C%2588%25E8%25A1%2580%25E8%2582%2589%25E5%258F%25B22%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F10%2F15%2Fthe-last-lecture%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15014211.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">黄子华 – 娱乐圈血肉史2</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Another Hello World is running on my iPhone!" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F08%2F30%2Fanother-hello-world-is-running-on-my-iphone%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F10%2F15%2Fthe-last-lecture%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015234.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Another Hello World is running on my iPhone!</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="利用ssh tunnel建立本地sock代理" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F07%2F25%2F%25E5%2588%25A9%25E7%2594%25A8ssh-tunnel%25E5%25BB%25BA%25E7%25AB%258B%25E6%259C%25AC%25E5%259C%25B0sock%25E4%25BB%25A3%25E7%2590%2586%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F10%2F15%2Fthe-last-lecture%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015597.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">利用ssh tunnel建立本地sock代理</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="3" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>Randy Pausch是CMU的professor，2007年的时候46岁。<br />
和Jobs一样，不幸患上了胰腺癌。<br />
比Jobs更不幸的是，他所患的这种疾病不是罕见的那种，并不能通过手术治愈。</p>
<p>在告别自己无限留恋的妻儿之前，他准备并在CMU做了“The Last Lecture”的演讲，主题是如何实现自己儿时的梦想。<br />
演讲时，他面对的是自己的妻子、朋友、同事和学生；实际上，他是在和未来的孩子对话。<br />
当时，他的孩子分别是5、3、1岁。</p>
<p>他知道，这个演讲会被摄像机记录下来。很多孩子们当时无法明白的话，终有一天可以被理解。<br />
跨越时空的言传身教，伟大的父亲。</p>
<p>从Professor Randy幽默的演讲里，可以领悟到太多的智慧。<br />
具体是什么道理，就请自行领悟吧。<br />
<object width="480" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://player.youku.com/player.php/sid/XMjQ3MTUzNDI4/v.swf" /><param name="allowfullscreen" value="true" /><param name="quality" value="high" /><param name="allowscriptaccess" value="always" /><embed width="480" height="400" type="application/x-shockwave-flash" src="http://player.youku.com/player.php/sid/XMjQ3MTUzNDI4/v.swf" allowfullscreen="true" quality="high" allowscriptaccess="always" /></object></p>
<p>如果看过视频之后，想对Professor Randy了解更多，可以访问<a title="http://en.wikipedia.org/wiki/Randy_Pausch" href="http://en.wikipedia.org/wiki/Randy_Pausch" target="_blank">http://en.wikipedia.org/wiki/Randy_Pausch</a>。</p>
<p>与演讲相应，有一本已经出版的书，也值得阅读和收藏<a title="http://book.douban.com/subject/3034706/" href="http://book.douban.com/subject/3034706/" target="_blank">http://book.douban.com/subject/3034706/</a>。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="3"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="用visio画的UML图例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F10%2F18%2F%25E7%2594%25A8visio%25E7%2594%25BB%25E7%259A%2584uml%25E5%259B%25BE%25E4%25BE%258B%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F10%2F15%2Fthe-last-lecture%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015128.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用visio画的UML图例</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="利用ssh tunnel建立本地sock代理" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F07%2F25%2F%25E5%2588%25A9%25E7%2594%25A8ssh-tunnel%25E5%25BB%25BA%25E7%25AB%258B%25E6%259C%25AC%25E5%259C%25B0sock%25E4%25BB%25A3%25E7%2590%2586%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F10%2F15%2Fthe-last-lecture%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015597.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">利用ssh tunnel建立本地sock代理</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Another Hello World is running on my iPhone!" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F08%2F30%2Fanother-hello-world-is-running-on-my-iphone%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F10%2F15%2Fthe-last-lecture%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015234.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Another Hello World is running on my iPhone!</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="3" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/10/15/the-last-lecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>频率限制算法的其中一种实现</title>
		<link>http://icomes.net/2011/06/04/frequence_limitation/</link>
		<comments>http://icomes.net/2011/06/04/frequence_limitation/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 14:31:26 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[技术笔记]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=551</guid>
		<description><![CDATA[算法的思想来自与和同事的一次聊天，做了改进，使得精度可以通过参数控制。 Frequence.h #pragma once &#160; class Frequence &#123; public: Frequence&#40; int precision = 10 &#41;; ~Frequence&#40; &#41;; &#160; int Check&#40; &#41;; &#160; private: int _precision; int _slot_num; &#160; struct stSlot &#123; int count; int time; &#125;; &#160; stSlot *_slot; &#160; inline int calculate&#40; int now &#41;; &#160; inline int get_current_slot_num&#40; int now &#41;; &#125;; Frequence.cpp [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F07%2F18%2Fleopard%25E4%25B8%258B%25E4%25B8%25BB%25E6%259C%25BA%25E5%2590%258D%25EF%25BC%2588%25E7%2594%25B5%25E8%2584%2591%25E5%2590%258D%25EF%25BC%2589%25E5%258F%2598%25E6%2588%2590bogon%25E7%259A%2584%25E5%2585%25B6%25E4%25B8%25AD%25E4%25B8%2580%25E7%25A7%258D%25E5%258E%259F%25E5%259B%25A0%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Leopard下主机名（电脑名）变成bogon的其中一种原因</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F10%2F24%2Fweb%25E5%25AE%259E%25E7%258E%25B0%25E6%259C%258D%25E5%258A%25A1%25E5%2599%25A8%25E6%258E%25A8%25E7%259A%2584%25E4%25B8%2589%25E7%25A7%258D%25E6%258A%2580%25E6%259C%25AF%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Web实现服务器推的三种技术</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2010%2F06%2F01%2Form%25E7%259A%2584%25E4%25B8%2580%25E5%258F%25A5%25E8%25AF%259D%25E8%25A7%25A3%25E9%2587%258A%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">ORM的一句话解释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F07%2F08%2F%25E7%25BD%2591%25E5%258D%25A1%25E5%2588%25AB%25E5%2590%258D-%25E7%25BB%2599%25E4%25B8%2580%25E5%259D%2597%25E7%2589%25A9%25E7%2590%2586%25E7%25BD%2591%25E5%258D%25A1%25E8%25AE%25BE%25E7%25BD%25AE%25E5%25A4%259A%25E4%25B8%25AAip%25E5%259C%25B0%25E5%259D%2580%25E7%259A%2584%25E6%2596%25B9%25E6%25B3%2595%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">网卡别名 – 给一块物理网卡设置多个IP地址的方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>算法的思想来自与和同事的一次聊天，做了改进，使得精度可以通过参数控制。</p>
<p>Frequence.h</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#pragma once</span>
&nbsp;
<span style="color: #0000ff;">class</span> Frequence 
<span style="color: #008000;">&#123;</span>
  <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
	Frequence<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> precision <span style="color: #000080;">=</span> <span style="color: #0000dd;">10</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	~Frequence<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">int</span> Check<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
	<span style="color: #0000ff;">int</span>		_precision<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> 	_slot_num<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">struct</span> stSlot
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">int</span> count<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">int</span> <span style="color: #0000dd;">time</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
	stSlot <span style="color: #000040;">*</span>_slot<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">int</span> calculate<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> now <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">int</span> get_current_slot_num<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> now <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>Frequence.cpp</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &quot;Frequence.h&quot;</span>
&nbsp;
<span style="color: #339900;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339900;">#include &lt;stdio.h&gt;</span>
<span style="color: #339900;">#include &lt;time.h&gt;</span>
&nbsp;
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> kMinute <span style="color: #000080;">=</span> <span style="color: #0000dd;">60</span><span style="color: #008080;">;</span>
&nbsp;
Frequence <span style="color: #008080;">::</span> <span style="color: #007788;">Frequence</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> precision <span style="color: #008000;">&#41;</span>
	<span style="color: #008080;">:</span>	_precision<span style="color: #008000;">&#40;</span> precision <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> _precision <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">60</span> <span style="color: #008000;">&#41;</span> _precision <span style="color: #000080;">=</span> <span style="color: #0000dd;">10</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> _precision <span style="color: #000080;">&lt;=</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span> _precision <span style="color: #000080;">=</span> <span style="color: #0000dd;">10</span><span style="color: #008080;">;</span>
&nbsp;
	_slot_num <span style="color: #000080;">=</span> kMinute <span style="color: #000040;">/</span> _precision <span style="color: #000040;">+</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	_slot <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span> stSlot <span style="color: #000040;">*</span> <span style="color: #008000;">&#41;</span><span style="color: #0000dd;">calloc</span><span style="color: #008000;">&#40;</span> _slot_num, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span> stSlot <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
Frequence <span style="color: #008080;">::</span> ~Frequence<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000dd;">free</span><span style="color: #008000;">&#40;</span> _slot <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> Frequence <span style="color: #008080;">::</span> <span style="color: #007788;">Check</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> now <span style="color: #000080;">=</span> <span style="color: #0000dd;">time</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">NULL</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> current_slot_num <span style="color: #000080;">=</span> get_current_slot_num<span style="color: #008000;">&#40;</span> now <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	stSlot <span style="color: #000040;">*</span>current_slot <span style="color: #000080;">=</span> _slot <span style="color: #000040;">+</span> current_slot_num<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">int</span> diff <span style="color: #000080;">=</span> now <span style="color: #000040;">-</span> current_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span><span style="color: #0000dd;">time</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> diff <span style="color: #000080;">&gt;</span> kMinute <span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		current_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>count <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span>
	<span style="color: #008000;">&#123;</span>
		current_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>count<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	current_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span><span style="color: #0000dd;">time</span> <span style="color: #000080;">=</span> now<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">return</span> calculate<span style="color: #008000;">&#40;</span> now <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> Frequence <span style="color: #008080;">::</span> <span style="color: #007788;">calculate</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> now <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> current_slot_num <span style="color: #000080;">=</span> get_current_slot_num<span style="color: #008000;">&#40;</span> now <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	stSlot <span style="color: #000040;">*</span>last_slot <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">int</span> total <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>	
	<span style="color: #0000ff;">int</span> index <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span> index <span style="color: #000080;">&lt;</span> _slot_num <span style="color: #000040;">-</span> <span style="color: #0000dd;">1</span> <span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">int</span> last_slot_num <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span> _slot_num <span style="color: #000040;">+</span> current_slot_num <span style="color: #000040;">-</span> index <span style="color: #008000;">&#41;</span> <span style="color: #000040;">%</span> _slot_num<span style="color: #008080;">;</span>
		last_slot <span style="color: #000080;">=</span> _slot <span style="color: #000040;">+</span> last_slot_num<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">int</span> diff <span style="color: #000080;">=</span> now <span style="color: #000040;">-</span> last_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span><span style="color: #0000dd;">time</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span> diff <span style="color: #000080;">&gt;</span> kMinute <span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			last_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>count <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
&nbsp;
		total <span style="color: #000040;">+</span><span style="color: #000080;">=</span> last_slot<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>count<span style="color: #008080;">;</span>
		index<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> total<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> Frequence <span style="color: #008080;">::</span> <span style="color: #007788;">get_current_slot_num</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> now <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">return</span> <span style="color: #008000;">&#40;</span> now <span style="color: #000040;">%</span> <span style="color: #008000;">&#40;</span> _slot_num <span style="color: #000040;">*</span> _precision <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> _precision<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F07%2F18%2Fleopard%25E4%25B8%258B%25E4%25B8%25BB%25E6%259C%25BA%25E5%2590%258D%25EF%25BC%2588%25E7%2594%25B5%25E8%2584%2591%25E5%2590%258D%25EF%25BC%2589%25E5%258F%2598%25E6%2588%2590bogon%25E7%259A%2584%25E5%2585%25B6%25E4%25B8%25AD%25E4%25B8%2580%25E7%25A7%258D%25E5%258E%259F%25E5%259B%25A0%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Leopard下主机名（电脑名）变成bogon的其中一种原因</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F10%2F24%2Fweb%25E5%25AE%259E%25E7%258E%25B0%25E6%259C%258D%25E5%258A%25A1%25E5%2599%25A8%25E6%258E%25A8%25E7%259A%2584%25E4%25B8%2589%25E7%25A7%258D%25E6%258A%2580%25E6%259C%25AF%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Web实现服务器推的三种技术</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2010%2F06%2F01%2Form%25E7%259A%2584%25E4%25B8%2580%25E5%258F%25A5%25E8%25AF%259D%25E8%25A7%25A3%25E9%2587%258A%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">ORM的一句话解释</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F07%2F08%2F%25E7%25BD%2591%25E5%258D%25A1%25E5%2588%25AB%25E5%2590%258D-%25E7%25BB%2599%25E4%25B8%2580%25E5%259D%2597%25E7%2589%25A9%25E7%2590%2586%25E7%25BD%2591%25E5%258D%25A1%25E8%25AE%25BE%25E7%25BD%25AE%25E5%25A4%259A%25E4%25B8%25AAip%25E5%259C%25B0%25E5%259D%2580%25E7%259A%2584%25E6%2596%25B9%25E6%25B3%2595%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F06%2F04%2Ffrequence_limitation%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">网卡别名 – 给一块物理网卡设置多个IP地址的方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/06/04/frequence_limitation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>什么是Nginx</title>
		<link>http://icomes.net/2011/02/24/%e4%bb%80%e4%b9%88%e6%98%afnginx/</link>
		<comments>http://icomes.net/2011/02/24/%e4%bb%80%e4%b9%88%e6%98%afnginx/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 17:06:07 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[技术笔记]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=539</guid>
		<description><![CDATA[好吧，大家（看到这些文字的地球人）都知道Nginx是什么用的了。 这里只是希望可以稍微详细的记录下收集到的信息。 毕竟在一头扎进源码的深潭之前，先在水面观察一阵并不是什么坏事：） Nginx不是一个普通HTTP Server，它还是一个免费、开源和高效的HTTP Server。 免费和开源是显然的事实，因为源码可以从官网上下载； 高效不能一眼看出，但也有测试数据和市场份额做间接的支持。 Nginx不仅仅是一个HTTP Server，它还可以用作Reverse Proxy和Mail Proxy。 作为Reverse Proxy，主要用于负载均衡、SSL支持、Cache等方面； Mail Proxy了解不多，暂不妄言：） 根据官网的数据，目前Nginx的市场份额为7.5%。这个数据也和netcraft.com上的调查结果一致。 详细数据可以参考http://news.netcraft.com/archives/2011/01/12/january-2011-web-server-survey-4.html。 顺便截下最新的分布。Nginx排名第三，而且势头良好。 不过如果想对领先的Apache和IIS构成威胁，则还是非常遥远的梦想。 项目从2002年开始，2004年开源。 初始作者和主要维护人名叫Igor Sysoev，俄罗斯人，70年生，目前在莫斯科。 可以在http://sysoev.ru/en/找到更多的资料。 不过如果想对个人有更更多的了解，最好懂点俄文。 这对东北的同学来说可能不是难事：） 对这位牛人的相貌比较好奇，Google到的结果让人无从选择。 好在这个星球上，除了Google，还有一个叫Facebook的网站：） 据他在Facebook上的资料显示，他和Intel有某种联系，莫非跳槽了？ 发音方面，和Linux一样，最好还是采用发明人的说法，“Engine X”。 挺酷的样子。 作为一个服务器，Nginx的优点非常突出。 据http://wiki.nginx.org的说法，高性能、稳定、功能丰富、配置简单，并且节省资源。 难道世界上真有只好不坏的东西？ 它使用事件驱动的异步模型，而不是多进程/线程竞争接入请求的架构，解决了C10K的问题。 从官网的描述可以看出，Igor对此架构非常自豪。 不过从现在看来，这样的架构被没什么超凡入圣之处，公司内可以看到很多类似的实现。 甚至可以说，这已经是常规的做法了， 可能回到2002年的时候会是一个非常创新的设计。 事件驱动模型在《Unix Network Programming》里也有详细的阐述， 只是没有提到epoll、kqueue等新的方法，原理都是相通的。 现在，Nginx的最新稳定版本是0.8.54，可以在http://nginx.org/en/download.html下载。 从http://nginx.org/的更新历史看，作者非常活跃，每个月起码更新一次。 开发版本已经到了0.9.5。 最后，对于想分析Nginx源码的中国人，http://code.google.com/p/nginxsrp/wiki/NginxCodeReview似乎是个不错的开始。 英文方面，可以看http://nginx.org/en/docs/introduction.html，是Igor写的三篇文章。 美中不足的是，这三篇文章主要都是介绍配置方面信息的，对架构、代码甚少涉及。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Nginx源码分析" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2011%2F02%2F22%2Fnginx%25E6%25BA%2590%25E7%25A0%2581%25E5%2588%2586%25E6%259E%2590%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Nginx源码分析</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Ubuntu 8.04 Server在VMWare中无法启动的解决办法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F06%2F29%2Fubuntu-804-server%25E5%259C%25A8vmware%25E4%25B8%25AD%25E6%2597%25A0%25E6%25B3%2595%25E5%2590%25AF%25E5%258A%25A8%25E7%259A%2584%25E8%25A7%25A3%25E5%2586%25B3%25E5%258A%259E%25E6%25B3%2595%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15017346.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Ubuntu 8.04 Server在VMWare中无法启动的解决办法</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Another Hello World is running on my iPhone!" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F08%2F30%2Fanother-hello-world-is-running-on-my-iphone%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015234.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Another Hello World is running on my iPhone!</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用visio画的UML图例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F10%2F18%2F%25E7%2594%25A8visio%25E7%2594%25BB%25E7%259A%2584uml%25E5%259B%25BE%25E4%25BE%258B%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015128.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用visio画的UML图例</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>好吧，大家（看到这些文字的地球人）都知道Nginx是什么用的了。<br />
这里只是希望可以稍微详细的记录下收集到的信息。<br />
毕竟在一头扎进源码的深潭之前，先在水面观察一阵并不是什么坏事：）</p>
<p>Nginx不是一个普通HTTP Server，它还是一个免费、开源和高效的HTTP Server。<br />
免费和开源是显然的事实，因为源码可以从官网上下载；<br />
高效不能一眼看出，但也有测试数据和市场份额做间接的支持。</p>
<p>Nginx不仅仅是一个HTTP Server，它还可以用作Reverse Proxy和Mail Proxy。<br />
作为Reverse Proxy，主要用于负载均衡、SSL支持、Cache等方面；<br />
Mail Proxy了解不多，暂不妄言：）</p>
<p>根据官网的数据，目前Nginx的市场份额为7.5%。这个数据也和netcraft.com上的调查结果一致。<br />
详细数据可以参考<a href="http://news.netcraft.com/archives/2011/01/12/january-2011-web-server-survey-4.html" target="_blank">http://news.netcraft.com/archives/2011/01/12/january-2011-web-server-survey-4.html</a>。</p>
<p>顺便截下最新的分布。Nginx排名第三，而且势头良好。<br />
不过如果想对领先的Apache和IIS构成威胁，则还是非常遥远的梦想。<br />
<a href="http://icomes.net/wp-content/uploads/2011/02/nginx_market_share.png"><img class="alignnone size-full wp-image-541" title="nginx_market_share" src="http://icomes.net/wp-content/uploads/2011/02/nginx_market_share.png" alt="nginx market share" width="494" height="149" /></a></p>
<p>项目从2002年开始，2004年开源。<br />
初始作者和主要维护人名叫Igor Sysoev，俄罗斯人，70年生，目前在莫斯科。<br />
可以在<a href="http://sysoev.ru/en/" target="_blank">http://sysoev.ru/en/</a>找到更多的资料。<br />
不过如果想对个人有更更多的了解，最好懂点俄文。<br />
这对东北的同学来说可能不是难事：）</p>
<p>对这位牛人的相貌比较好奇，Google到的结果让人无从选择。<br />
好在这个星球上，除了Google，还有一个叫Facebook的网站：）<br />
<a href="http://icomes.net/wp-content/uploads/2011/02/igor.jpg"><img class="alignnone size-full wp-image-540" title="igor" src="http://icomes.net/wp-content/uploads/2011/02/igor.jpg" alt="igor" width="200" height="302" /></a><br />
据他在Facebook上的资料显示，他和Intel有某种联系，莫非跳槽了？</p>
<p>发音方面，和Linux一样，最好还是采用发明人的说法，“Engine X”。<br />
挺酷的样子。</p>
<p>作为一个服务器，Nginx的优点非常突出。<br />
据<a href="http://wiki.nginx.org">http://wiki.nginx.org</a>的说法，高性能、稳定、功能丰富、配置简单，并且节省资源。<br />
难道世界上真有只好不坏的东西？</p>
<p>它使用事件驱动的异步模型，而不是多进程/线程竞争接入请求的架构，解决了C10K的问题。<br />
从官网的描述可以看出，Igor对此架构非常自豪。<br />
不过从现在看来，这样的架构被没什么超凡入圣之处，公司内可以看到很多类似的实现。<br />
甚至可以说，这已经是常规的做法了，<br />
可能回到2002年的时候会是一个非常创新的设计。<br />
事件驱动模型在《Unix Network Programming》里也有详细的阐述，<br />
只是没有提到epoll、kqueue等新的方法，原理都是相通的。</p>
<p>现在，Nginx的最新稳定版本是0.8.54，可以在<a href="http://nginx.org/en/download.html">http://nginx.org/en/download.html</a>下载。<br />
从<a href="http://nginx.org/" target="_blank">http://nginx.org/</a>的更新历史看，作者非常活跃，每个月起码更新一次。<br />
开发版本已经到了0.9.5。</p>
<p>最后，对于想分析Nginx源码的中国人，<a href="http://code.google.com/p/nginxsrp/wiki/NginxCodeReview" target="_blank">http://code.google.com/p/nginxsrp/wiki/NginxCodeReview</a>似乎是个不错的开始。<br />
英文方面，可以看<a href="http://nginx.org/en/docs/introduction.html" target="_blank">http://nginx.org/en/docs/introduction.html</a>，是Igor写的三篇文章。<br />
美中不足的是，这三篇文章主要都是介绍配置方面信息的，对架构、代码甚少涉及。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Nginx源码分析" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2011%2F02%2F22%2Fnginx%25E6%25BA%2590%25E7%25A0%2581%25E5%2588%2586%25E6%259E%2590%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Nginx源码分析</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Second Screenshot" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F09%2F03%2Fsecond-screensho%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015227.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Second Screenshot</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="新主题iBlog2" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F09%2F15%2F%25E6%2596%25B0%25E4%25B8%25BB%25E9%25A2%2598iblog2%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15014886.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">新主题iBlog2</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="利用ssh tunnel建立本地sock代理" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2009%2F07%2F25%2F%25E5%2588%25A9%25E7%2594%25A8ssh-tunnel%25E5%25BB%25BA%25E7%25AB%258B%25E6%259C%25AC%25E5%259C%25B0sock%25E4%25BB%25A3%25E7%2590%2586%2F&from=http%3A%2F%2Ficomes.net%2F2011%2F02%2F24%2F%25E4%25BB%2580%25E4%25B9%2588%25E6%2598%25AFnginx%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/06/29/15015597.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">利用ssh tunnel建立本地sock代理</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/02/24/%e4%bb%80%e4%b9%88%e6%98%afnginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx源码分析</title>
		<link>http://icomes.net/2011/02/22/nginx%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90/</link>
		<comments>http://icomes.net/2011/02/22/nginx%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 15:09:12 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[技术笔记]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=534</guid>
		<description><![CDATA[分析Nginx源码这个念头曾经出现过，也用GDB配合Source Insight跟踪过两天时间。 之后由于其他事情占据了时间，就搁置了下来，一晃就几个月。 做事过于随性是老毛病了，不过就像许多其他事情，虽明知不妥，却总也戒不掉，改不了。 借着写Nginx模块的惯性和余温，但愿这次可以一口气完成吧。 //Mac OS自带的输入法真不好用，公司们（Google, Tencent, Sogou, Baidu &#8230;）大发慈悲，做一个输入法吧 Nginx的代码写得好是出了名的：命名规范、模块化划分、函数简短、适当注释⋯⋯ 虽然有如此多的好处，但要对其代码做详细分析，既可俯瞰架构、又能深入细节，却实属艰难。 单单是内存池、回调机制、多重指针等之前几天让我费劲脑汁的技巧，已经让我超出预算。 况且了解细节易，纵观全局难，注定了是一个上下求索的过程。 //这个说法也适用于程序员生涯。 为免自己半途而废，写下以上文字，算是立字为据，也权当之后笔记的前言吧。]]></description>
			<content:encoded><![CDATA[<p>分析Nginx源码这个念头曾经出现过，也用GDB配合Source Insight跟踪过两天时间。<br />
之后由于其他事情占据了时间，就搁置了下来，一晃就几个月。</p>
<p>做事过于随性是老毛病了，不过就像许多其他事情，虽明知不妥，却总也戒不掉，改不了。<br />
借着写Nginx模块的惯性和余温，但愿这次可以一口气完成吧。<br />
//Mac OS自带的输入法真不好用，公司们（Google, Tencent, Sogou, Baidu &#8230;）大发慈悲，做一个输入法吧</p>
<p>Nginx的代码写得好是出了名的：命名规范、模块化划分、函数简短、适当注释⋯⋯<br />
虽然有如此多的好处，但要对其代码做详细分析，既可俯瞰架构、又能深入细节，却实属艰难。<br />
单单是内存池、回调机制、多重指针等之前几天让我费劲脑汁的技巧，已经让我超出预算。<br />
况且了解细节易，纵观全局难，注定了是一个上下求索的过程。<br />
//这个说法也适用于程序员生涯。</p>
<p>为免自己半途而废，写下以上文字，算是立字为据，也权当之后笔记的前言吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/02/22/nginx%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Zen of Python</title>
		<link>http://icomes.net/2011/02/13/zen-of-python/</link>
		<comments>http://icomes.net/2011/02/13/zen-of-python/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 05:45:50 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[技术笔记]]></category>
		<category><![CDATA[zen]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=530</guid>
		<description><![CDATA[by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren&#8217;t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly [...]]]></description>
			<content:encoded><![CDATA[<h3>by Tim Peters</h3>
<p>Beautiful is better than ugly.<br />
Explicit is better than implicit.<br />
Simple is better than complex.<br />
Complex is better than complicated.<br />
Flat is better than nested.<br />
Sparse is better than dense.<br />
Readability counts.<br />
Special cases aren&#8217;t special enough to break the rules.<br />
Although practicality beats purity.<br />
Errors should never pass silently.<br />
Unless explicitly silenced.<br />
In the face of ambiguity, refuse the temptation to guess.<br />
There should be one&#8211; and preferably only one &#8211;obvious way to do it.<br />
Although that way may not be obvious at first unless you&#8217;re Dutch.<br />
Now is better than never.<br />
Although never is often better than *right* now.<br />
If the implementation is hard to explain, it&#8217;s a bad idea.<br />
If the implementation is easy to explain, it may be a good idea.<br />
Namespaces are one honking great idea &#8212; let&#8217;s do more of those!</p>
<p>just “import this”:)</p>
]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/02/13/zen-of-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>黄子华 &#8211; 娱乐圈血肉史2</title>
		<link>http://icomes.net/2011/01/22/%e9%bb%84%e5%ad%90%e5%8d%8e-%e5%a8%b1%e4%b9%90%e5%9c%88%e8%a1%80%e8%82%89%e5%8f%b22/</link>
		<comments>http://icomes.net/2011/01/22/%e9%bb%84%e5%ad%90%e5%8d%8e-%e5%a8%b1%e4%b9%90%e5%9c%88%e8%a1%80%e8%82%89%e5%8f%b22/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 08:56:39 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[默认分类]]></category>
		<category><![CDATA[黄子华]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=524</guid>
		<description><![CDATA[错过了买票，只能上土豆找，居然也有发现 都是佛山的同学拍的，效果还不错 开场30分钟 第二Part update: Youku上也有发现]]></description>
			<content:encoded><![CDATA[<p>错过了买票，只能上土豆找，居然也有发现<br />
都是佛山的同学拍的，效果还不错</p>
<p>开场30分钟<br />
<embed src="http://www.tudou.com/v/0Tqkb0bJcMc/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="480" height="400"></embed></p>
<p>第二Part<br />
<embed src="http://www.tudou.com/v/q1eSmfNR3qI/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="480" height="400"></embed></p>
<p>update:</p>
<p>Youku上也有发现<br />
<embed src="http://player.youku.com/player.php/sid/XMjM0NzYzMzE2/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2011/01/22/%e9%bb%84%e5%ad%90%e5%8d%8e-%e5%a8%b1%e4%b9%90%e5%9c%88%e8%a1%80%e8%82%89%e5%8f%b22/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>卡尔维诺 &#8211; 做起来（尖脚猫游戏）</title>
		<link>http://icomes.net/2010/10/14/%e5%8d%a1%e5%b0%94%e7%bb%b4%e8%af%ba-%e5%81%9a%e8%b5%b7%e6%9d%a5%ef%bc%88%e5%b0%96%e8%84%9a%e7%8c%ab%e6%b8%b8%e6%88%8f%ef%bc%89/</link>
		<comments>http://icomes.net/2010/10/14/%e5%8d%a1%e5%b0%94%e7%bb%b4%e8%af%ba-%e5%81%9a%e8%b5%b7%e6%9d%a5%ef%bc%88%e5%b0%96%e8%84%9a%e7%8c%ab%e6%b8%b8%e6%88%8f%ef%bc%89/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 15:19:22 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[所思所想]]></category>
		<category><![CDATA[读书笔记]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=507</guid>
		<description><![CDATA[有这样一个镇子，做什么事情都被禁止了。 现在，因为惟一未被禁止的就是尖脚猫游戏，所以镇上的臣民就经常聚在镇后边的草坪上，成天地玩尖脚猫游戏。 因为禁令被制订的时候总有恰当的原因，所以没有任何人觉得有理由抱怨，也没人觉得受不了。 几年过去了。有一天，官员们觉得再没有任何理由禁止臣民做这些事了，他们就派了传令官四处通知人们一切都开禁了。 传令官来到老百姓喜欢聚集的那些地方。 “听好了，听好了，”他们宣布，“所有的都开禁了。”但人们还是玩尖脚 猫游戏。 “明白吗？”传令官重申，“你们现在可以任意做想做的事了。” “好的，”臣民们回答。“我们玩尖脚猫。” 那些传令官一再地提醒他们的臣民，他们又可以回到他们从前曾经从事的那些高尚而有用的职业中去了。但是老百姓都不愿听，他们继续玩尖脚猫，一圈又一圈，甚至都不停下来喘口气。 看到他们是白费劲了，那些传令官就回去禀报上面。 “这很容易，”那些官员们说，“现在我们下令禁止尖脚猫。” 人民就是在那时开始反抗的，杀了部分官员。 然后人民分秒必争地又回去玩尖脚猫游戏了。 有种看《Monster》时的诡异感觉，让我误以为卡尔维诺是东欧人。 另外，尖脚猫这个游戏是怎么玩的？]]></description>
			<content:encoded><![CDATA[<blockquote><p>有这样一个镇子，做什么事情都被禁止了。<br />
现在，因为惟一未被禁止的就是尖脚猫游戏，所以镇上的臣民就经常聚在镇后边的草坪上，成天地玩尖脚猫游戏。<br />
因为禁令被制订的时候总有恰当的原因，所以没有任何人觉得有理由抱怨，也没人觉得受不了。</p>
<p>几年过去了。有一天，官员们觉得再没有任何理由禁止臣民做这些事了，他们就派了传令官四处通知人们一切都开禁了。<br />
传令官来到老百姓喜欢聚集的那些地方。<br />
“听好了，听好了，”他们宣布，“所有的都开禁了。”但人们还是玩尖脚 猫游戏。<br />
“明白吗？”传令官重申，“你们现在可以任意做想做的事了。”<br />
“好的，”臣民们回答。“我们玩尖脚猫。”</p>
<p>那些传令官一再地提醒他们的臣民，他们又可以回到他们从前曾经从事的那些高尚而有用的职业中去了。但是老百姓都不愿听，他们继续玩尖脚猫，一圈又一圈，甚至都不停下来喘口气。<br />
看到他们是白费劲了，那些传令官就回去禀报上面。<br />
“这很容易，”那些官员们说，“现在我们下令禁止尖脚猫。”</p>
<p>人民就是在那时开始反抗的，杀了部分官员。<br />
然后人民分秒必争地又回去玩尖脚猫游戏了。</p></blockquote>
<p>有种看《Monster》时的诡异感觉，让我误以为卡尔维诺是东欧人。<br />
另外，尖脚猫这个游戏是怎么玩的？</p>
]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2010/10/14/%e5%8d%a1%e5%b0%94%e7%bb%b4%e8%af%ba-%e5%81%9a%e8%b5%b7%e6%9d%a5%ef%bc%88%e5%b0%96%e8%84%9a%e7%8c%ab%e6%b8%b8%e6%88%8f%ef%bc%89/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac下iso转换成dmg的方法</title>
		<link>http://icomes.net/2010/10/14/mac%e4%b8%8biso%e8%bd%ac%e6%8d%a2%e6%88%90dmg%e7%9a%84%e6%96%b9%e6%b3%95/</link>
		<comments>http://icomes.net/2010/10/14/mac%e4%b8%8biso%e8%bd%ac%e6%8d%a2%e6%88%90dmg%e7%9a%84%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 13:18:17 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[技巧]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=504</guid>
		<description><![CDATA[升级到Snow Leopard的时候，找到的是dmg文件。 Mac自带的磁盘工具支持将dmg写入到USB stick，并用USB stick来引导安装。 当时就想，是不是iso文件也可以这样做？ 今天准备装Ubuntu 10.10的时候，在Ubuntu的安装向导中找到了答案： Download the desired file Open the Terminal (in /Applications/Utilities/ or query Terminal in Spotlight) Convert the .iso file to .img using the convert option of hdiutil (e.g.,hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso) Note: OS X tends to put the .dmg ending on the output file automatically. Run diskutil [...]]]></description>
			<content:encoded><![CDATA[<p>升级到Snow Leopard的时候，找到的是dmg文件。<br />
Mac自带的磁盘工具支持将dmg写入到USB stick，并用USB stick来引导安装。</p>
<p>当时就想，是不是iso文件也可以这样做？<br />
今天准备装Ubuntu 10.10的时候，在Ubuntu的安装向导中找到了答案：</p>
<ol>
<li>Download the desired file</li>
<li>Open the Terminal (in /Applications/Utilities/ or query Terminal in Spotlight)</li>
<li>Convert the .iso file to .img using the convert option of hdiutil (e.g.,<code>hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso</code>)</li>
<li><strong>Note:</strong> OS X tends to put the <code>.dmg</code> ending on the output file automatically.</li>
<li>Run <code>diskutil list</code> to get the current list of devices</li>
<li>Insert your flash media</li>
<li>Run <code>diskutil list</code> again and determine the device node assigned to your flash media (e.g. /dev/disk2)</li>
<li>Run <code>diskutil unmountDisk /dev/diskN</code> (replace <em>N</em> with the disk number from the last command; in the previous example, <em>N</em> would be 2)</li>
<li>Execute <code>sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m</code> (replace <code>/path/to/downloaded.img</code> with the path where the image file is located; for example, <code>./ubuntu.img </code>or <code>./ubuntu.dmg</code>).</li>
<li>Using <code>/dev/rdisk</code> instead of <code>/dev/disk</code> may be faster.<br />
If you see the error <code>dd: Invalid number '1m'</code>, you are using GNU dd. Use the same command but replace <code>bs=1m</code> with <code>bs=1M</code>.<br />
If you see the error <code>dd: /dev/diskN: Resource busy</code>, make sure the disk is not in use. Start the &#8216;Disk Utility.app&#8217; and unmount (don&#8217;t eject) the drive.</li>
<li>Run <code>diskutil eject/dev/diskN</code> and remove your flash media when the command completes</li>
<li>Restart your Mac and press <code>alt</code> while the Mac is restarting to choose the USB-Stick</li>
</ol>
<p>从第5步起，也可以直接用“磁盘工具”代替<br />
原文地址：<a href="http://www.ubuntu.com/desktop/get-ubuntu/download" target="_blank">http://www.ubuntu.com/desktop/get-ubuntu/download</a></p>
<p>另外，上文也提到了在Windows下将iso做成可引导USB stick的方法。用这个小工具应该比UltraISO要方便吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2010/10/14/mac%e4%b8%8biso%e8%bd%ac%e6%8d%a2%e6%88%90dmg%e7%9a%84%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>《浪潮之巅》</title>
		<link>http://icomes.net/2010/10/09/%e3%80%8a%e6%b5%aa%e6%bd%ae%e4%b9%8b%e5%b7%85%e3%80%8b/</link>
		<comments>http://icomes.net/2010/10/09/%e3%80%8a%e6%b5%aa%e6%bd%ae%e4%b9%8b%e5%b7%85%e3%80%8b/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 03:16:30 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[读书笔记]]></category>
		<category><![CDATA[读书]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=500</guid>
		<description><![CDATA[趁着国庆长假，看完了这本书。 作者以工程师、科学家的身份，从非技术的角度，描述了现代IT业的兴衰成败。 尤其是其中关于硅谷背景、风投运作和华尔街对IT公司影响的章节，让作为工程师的我了解到很多平时接触不到的内幕。 虽然有不少错别字（又一个懒得学五笔的人？），依然强烈推荐。 希望作者抽空完成剩下的部分，只是不能再发到Google黑板报了。 下载：浪潮之巅1-18 PS. 作者吴军最近加盟了我们公司：）]]></description>
			<content:encoded><![CDATA[<p>趁着国庆长假，看完了这本书。</p>
<p>作者以工程师、科学家的身份，从非技术的角度，描述了现代IT业的兴衰成败。<br />
尤其是其中关于硅谷背景、风投运作和华尔街对IT公司影响的章节，让作为工程师的我了解到很多平时接触不到的内幕。<br />
虽然有不少错别字（又一个懒得学五笔的人？），依然强烈推荐。<br />
希望作者抽空完成剩下的部分，只是不能再发到Google黑板报了。</p>
<p>下载：<a href="http://icomes.net/wp-content/uploads/2010/10/浪潮之巅1-18.pdf">浪潮之巅1-18</a></p>
<p>PS. 作者吴军最近加盟了我们公司：）</p>
]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2010/10/09/%e3%80%8a%e6%b5%aa%e6%bd%ae%e4%b9%8b%e5%b7%85%e3%80%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

