<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>岚涟小筑</title>
	<atom:link href="http://brightconan.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://brightconan.com</link>
	<description>conan的wordpress博客</description>
	<lastBuildDate>Tue, 04 May 2010 11:31:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python的哲学</title>
		<link>http://brightconan.com/?p=53</link>
		<comments>http://brightconan.com/?p=53#comments</comments>
		<pubDate>Tue, 04 May 2010 11:30:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[语言]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pythonic]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=53</guid>
		<description><![CDATA[今天看了豆瓣洪强宁的技术分享，又看到了pep上的这段话，觉得太经典了，于是就转了过来，细细品味，很有味道
The Zen of Python, 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 silenced.
In the face of ambiguity, refuse the [...]]]></description>
			<content:encoded><![CDATA[<p>今天看了豆瓣<a href="http://www.douban.com/people/hongqn/">洪强宁</a>的<a href="http://www.slideshare.net/hongqn/qcon2010-3881323">技术分享</a>，又看到了pep上的这段话，觉得太经典了，于是就转了过来，细细品味，很有味道</p>
<p>The Zen of Python, by Tim Peters<br />
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>
<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=53</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[转]谈一下怎样判断网页是静态的还是伪静态的?</title>
		<link>http://brightconan.com/?p=51</link>
		<comments>http://brightconan.com/?p=51#comments</comments>
		<pubDate>Mon, 08 Feb 2010 13:12:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器管理]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[url-rewrite]]></category>
		<category><![CDATA[伪静态]]></category>
		<category><![CDATA[静态]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=51</guid>
		<description><![CDATA[怎样判断网页是静态还是伪静态呢?
SEO文章看多了，经常能听到静态、伪静态这类的词语，那什么样的网页是静态的，什么样的网页是伪静态的呢？
IE5浏览器以上：
打开你想判断的网站后，再在网址框中输入javascript:alert(document.lastModified)
IE5以上&#8230; ，此方法可以判断一个网页的最后更新时间，如果这个时间与现在的时间相同，说明是伪静态的，反之为静态的。
火狐浏览器下：
先用火狐打开一个网页如：http://bbs.ittang.com/forum-13-1.html 等网页完全打开后进入FireFox的控制台。&#8221;工具&#8221;-“错误控制台”快捷键：shift+ctrl+J  然后在控制台里面输入：alert(document.lastModified); 查看最后修改时间并记录。
接下来关闭控制台，重新刷新网页，再用相同的方法在控制台里输入查询代码，再查看文件的最后修改时间，连续几次如果发现时间不同则可以判断它是伪静态的了
相关知识：关于伪静态和真静态网页用处和利弊对比
1.关于伪静态的用处
有些用户觉得,伪静态和真静态实际被收录量会相差很大,其实不然,从你个人角度,你去判断一下一个帖子到底是真静态还是伪静态?
估计很难看得出,因为所谓静态的意思,就是地址中不带问号,不带问号的就是静态,管他是真的还是伪的?搜索引擎看得出吗?
所以说,其实不论是真的还是伪的,其实对于搜索引擎来说都是一样的,搜索引擎没有说,你这个是伪的,我不收录你.
揪根掘底的来说,为什么搜索引擎会不收录带问号的网址?因为搜索引擎怕由于问号而进入死循环(以前动网就有这样一个漏洞,蜘蛛进去出不来了),所以很多时候带问号的地址是不会进去的,伪静态对于搜索引擎来说,其实就是静态,因为地址中没有带问号,所以没有真静态比伪静态收录得多的说法.
2.为什么选择伪静态
有很多用户说:
真静态不好吗?
为什么不用真静态?
访问起来不是更快吗?
负载不是更好吗?
等等等等&#8230;
在这里,其实只用一个问题来回答:为什么选择MYSQL.
很多用户大概不明白为什么那么多大型论坛都选择了MYSQL数据库作为储存机制,大概大部分都是想:&#8221;因为DZ用了MYSQL,所以就是MYSQL&#8221;.
其实不然,试想DZ为什么会在那么多论坛程序并存的日子生存下来并笑傲江湖,很大原因是因为DZ用了MYSQL.试想如果大C当年改的程序是一个文本论坛,那还会有DZ的今天吗?
或者从另一个角度问,为什么那么多大型网站都选择了MYSQL而不是文本作为储存机制?
所谓文本论坛,实际就跟真静态的说法差不多了,将数据储存在空间上面,大量读写硬盘,等等&#8230;
为什么这种写法会被淘汰呢?
我相信答案不会是老师所说的:
&#8220;discuz.net 目前有 2129867 篇帖子，存储成html的话大约是 20799 M，也就是 20G左右。这当中还不计算由于磁盘存储机制造成的空间浪费（100个1k 的文件占用的空间可能会是200K）。&#8221;
这种说法从我个人观点来看,这个理由不能给予用户不使用真静态充分的理由.
然而,另一个理由却是值得我们注意思考的,也是为什么绝大多数站都不选择生成静态:
&#8220;删除、更新这些html内容会导致大量的磁盘io操作以及大量的磁盘碎片.&#8221;
正如上面这个说法,在实际当中确实会导致大量的磁盘I/O操作(input,output),大量进行I/O操作带来的后果可想而知,会产生大量的磁盘碎片甚至会导致硬盘出现坏道.
所以对于生成静态而言,还不如去用文本论坛,可以更好的解决你们的需求.
(副W就是做文本论坛出生的,当时的名字为ofstar http://www.ofstar.net ,后因发展困难转为MYSQL,而PW生成静态页面也就是PW以前文本方式稍加改进用于吸引用户眼球的噘头)
当然,如果大家记忆力好的话,应该可以记得PW4的时候PW论坛不能访问很长一段时间,后来恢复到一段时间前的数据,官方的说法是被人攻击而导致硬盘损坏,其实这种说法是比较不可信的,相对于是被攻击导致硬盘损坏还是大量I/O操作而产生的后果,我个人更倾向于后者.
当然,如果大家比较关注5d6d的话,应该知道前几天有一天时间5d6d无法访问,根据非官方消息是因为硬盘坏了,而损坏的原因我想当然是因为大量用户大量进行I/O操作了,试想,我们一个论坛,进行磁盘I/O操作的仅为管理员进行更新缓存时进行的,而5d6d每一个会员就是一个管理员,试想下对磁盘是多大的考验?所以我并不奇怪5d6d的硬盘坏了.
当然,也许在读这篇文章的很多朋友都有使用过BT,也听说过BT对硬盘很伤,不能开多,而所谓伤害,和这里指的都是同一样东西,大量I/O导致磁盘出现碎片甚至出现磁盘坏道.
这里都是说些很实际的例子来说明问题了.
3.关于伪静态的坏处
当然犹如一篇文章的作者所说的
&#8220;如果流量稍大一些使用伪静态就出现CPU使用超负荷，我的同时在线300多人就挂了，而不使用伪静态的时候同时在线超500人都不挂，我的ISS数是1000&#8243;
确实是这样的,由于伪静态是用正则判断而不是真实地址,分辨到底显示哪个页面的责任也由直接指定转由CPU来判断了,所以CPU占有量的上升,确实是伪静态最大的弊病.
4.我们该如何做?
我们来总结一下.
1.使用真静态和假静态对SEO来说没有什么区别
2.使用真静态可能将导致硬盘损坏并将影响论坛性能
3.使用伪静态将占用一定量的CPU占有率,大量使用将导致CPU超负荷
4.最重要的一点,我们要静态是为了SEO
所以.
1.使用真静态的方法可以直接排除了,因为无论怎么生成,对硬盘来说都是很伤的.
2.既然真伪静态的效果一样,我们就可以选择伪静态了.
3.但是伪静态大量使用会照成CPU超负荷.
4.所以我们只要不大量使用就可以了.
5.既然静态只是给SEO看的,我们只需要伪静态给SEO就行了,不需要给用户使用.
6.所以我们只要在专门提供给SEO爬的Archiver中使用伪静态就可以了.
7.谢谢大家耐心看我写的文章.
8.有何不解的地方或是有不同的看法欢迎提出.
Copyright &#169; 2008 This feed is for personal, non-commercial use only.  The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of [...]]]></description>
			<content:encoded><![CDATA[<p>怎样判断网页是静态还是伪静态呢?</p>
<p>SEO文章看多了，经常能听到静态、伪静态这类的词语，那什么样的网页是静态的，什么样的网页是伪静态的呢？</p>
<p>IE5浏览器以上：<br />
打开你想判断的网站后，再在网址框中输入javascript:alert(document.lastModified)<br />
IE5以上&#8230; ，此方法可以判断一个网页的最后更新时间，如果这个时间与现在的时间相同，说明是伪静态的，反之为静态的。</p>
<p>火狐浏览器下：</p>
<p>先用火狐打开一个网页如：http://bbs.ittang.com/forum-13-1.html 等网页完全打开后进入FireFox的控制台。&#8221;工具&#8221;-“错误控制台”快捷键：shift+ctrl+J  然后在控制台里面输入：alert(document.lastModified); 查看最后修改时间并记录。</p>
<p>接下来关闭控制台，重新刷新网页，再用相同的方法在控制台里输入查询代码，再查看文件的最后修改时间，连续几次如果发现时间不同则可以判断它是伪静态的了</p>
<p>相关知识：关于伪静态和真静态网页用处和利弊对比</p>
<p>1.关于伪静态的用处<br />
有些用户觉得,伪静态和真静态实际被收录量会相差很大,其实不然,从你个人角度,你去判断一下一个帖子到底是真静态还是伪静态?<br />
估计很难看得出,因为所谓静态的意思,就是地址中不带问号,不带问号的就是静态,管他是真的还是伪的?搜索引擎看得出吗?<br />
所以说,其实不论是真的还是伪的,其实对于搜索引擎来说都是一样的,搜索引擎没有说,你这个是伪的,我不收录你.<br />
揪根掘底的来说,为什么搜索引擎会不收录带问号的网址?因为搜索引擎怕由于问号而进入死循环(以前动网就有这样一个漏洞,蜘蛛进去出不来了),所以很多时候带问号的地址是不会进去的,伪静态对于搜索引擎来说,其实就是静态,因为地址中没有带问号,所以没有真静态比伪静态收录得多的说法.</p>
<p>2.为什么选择伪静态<br />
有很多用户说:<br />
真静态不好吗?<br />
为什么不用真静态?<br />
访问起来不是更快吗?<br />
负载不是更好吗?<br />
等等等等&#8230;<br />
在这里,其实只用一个问题来回答:为什么选择MYSQL.<br />
很多用户大概不明白为什么那么多大型论坛都选择了MYSQL数据库作为储存机制,大概大部分都是想:&#8221;因为DZ用了MYSQL,所以就是MYSQL&#8221;.<br />
其实不然,试想DZ为什么会在那么多论坛程序并存的日子生存下来并笑傲江湖,很大原因是因为DZ用了MYSQL.试想如果大C当年改的程序是一个文本论坛,那还会有DZ的今天吗?<br />
或者从另一个角度问,为什么那么多大型网站都选择了MYSQL而不是文本作为储存机制?<br />
所谓文本论坛,实际就跟真静态的说法差不多了,将数据储存在空间上面,大量读写硬盘,等等&#8230;<br />
为什么这种写法会被淘汰呢?<br />
我相信答案不会是老师所说的:</p>
<p>&#8220;discuz.net 目前有 2129867 篇帖子，存储成html的话大约是 20799 M，也就是 20G左右。这当中还不计算由于磁盘存储机制造成的空间浪费（100个1k 的文件占用的空间可能会是200K）。&#8221;</p>
<p>这种说法从我个人观点来看,这个理由不能给予用户不使用真静态充分的理由.<br />
然而,另一个理由却是值得我们注意思考的,也是为什么绝大多数站都不选择生成静态:</p>
<p>&#8220;删除、更新这些html内容会导致大量的磁盘io操作以及大量的磁盘碎片.&#8221;</p>
<p>正如上面这个说法,在实际当中确实会导致大量的磁盘I/O操作(input,output),大量进行I/O操作带来的后果可想而知,会产生大量的磁盘碎片甚至会导致硬盘出现坏道.</p>
<p>所以对于生成静态而言,还不如去用文本论坛,可以更好的解决你们的需求.<br />
(副W就是做文本论坛出生的,当时的名字为ofstar http://www.ofstar.net ,后因发展困难转为MYSQL,而PW生成静态页面也就是PW以前文本方式稍加改进用于吸引用户眼球的噘头)<br />
当然,如果大家记忆力好的话,应该可以记得PW4的时候PW论坛不能访问很长一段时间,后来恢复到一段时间前的数据,官方的说法是被人攻击而导致硬盘损坏,其实这种说法是比较不可信的,相对于是被攻击导致硬盘损坏还是大量I/O操作而产生的后果,我个人更倾向于后者.</p>
<p>当然,如果大家比较关注5d6d的话,应该知道前几天有一天时间5d6d无法访问,根据非官方消息是因为硬盘坏了,而损坏的原因我想当然是因为大量用户大量进行I/O操作了,试想,我们一个论坛,进行磁盘I/O操作的仅为管理员进行更新缓存时进行的,而5d6d每一个会员就是一个管理员,试想下对磁盘是多大的考验?所以我并不奇怪5d6d的硬盘坏了.</p>
<p>当然,也许在读这篇文章的很多朋友都有使用过BT,也听说过BT对硬盘很伤,不能开多,而所谓伤害,和这里指的都是同一样东西,大量I/O导致磁盘出现碎片甚至出现磁盘坏道.</p>
<p>这里都是说些很实际的例子来说明问题了.</p>
<p>3.关于伪静态的坏处<br />
当然犹如一篇文章的作者所说的</p>
<p>&#8220;如果流量稍大一些使用伪静态就出现CPU使用超负荷，我的同时在线300多人就挂了，而不使用伪静态的时候同时在线超500人都不挂，我的ISS数是1000&#8243;</p>
<p>确实是这样的,由于伪静态是用正则判断而不是真实地址,分辨到底显示哪个页面的责任也由直接指定转由CPU来判断了,所以CPU占有量的上升,确实是伪静态最大的弊病.</p>
<p>4.我们该如何做?</p>
<p>我们来总结一下.<br />
1.使用真静态和假静态对SEO来说没有什么区别<br />
2.使用真静态可能将导致硬盘损坏并将影响论坛性能<br />
3.使用伪静态将占用一定量的CPU占有率,大量使用将导致CPU超负荷<br />
4.最重要的一点,我们要静态是为了SEO</p>
<p>所以.<br />
1.使用真静态的方法可以直接排除了,因为无论怎么生成,对硬盘来说都是很伤的.<br />
2.既然真伪静态的效果一样,我们就可以选择伪静态了.<br />
3.但是伪静态大量使用会照成CPU超负荷.<br />
4.所以我们只要不大量使用就可以了.<br />
5.既然静态只是给SEO看的,我们只需要伪静态给SEO就行了,不需要给用户使用.<br />
6.所以我们只要在专门提供给SEO爬的Archiver中使用伪静态就可以了.<br />
7.谢谢大家耐心看我写的文章.<br />
8.有何不解的地方或是有不同的看法欢迎提出.</p>
<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=51</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDFmyURL.com &#8211; 把任意网站转换成PDF</title>
		<link>http://brightconan.com/?p=49</link>
		<comments>http://brightconan.com/?p=49#comments</comments>
		<pubDate>Sat, 16 Jan 2010 01:55:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[趣味网站]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=49</guid>
		<description><![CDATA[在cnbeta上发现一个很好玩的网站，于是就转过来吧。
如果您要将一个网站迅速保存下来，可以用多种方法，首先是普通的HTML，这样会带来许多网页文件，保存成mht也可以解决问题，不过不够直观，而PDF文件的通用性和对电子阅读器的友好性，让这家名叫PDFmyURL.com的网站亮了。它可以迅速将HTML转换成PDF文件，这一切非常简单，访问他们主页，输入要做PDF的页面地址就好了，制作结束网站会提示你获取PDF，不过需要注意的是，它并没有中文字库，因此会显示一个一个框框。
访问www.PDFmyURL.com

Copyright &#169; 2008 This feed is for personal, non-commercial use only.  The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint: )]]></description>
			<content:encoded><![CDATA[<p>在cnbeta上发现一个很好玩的网站，于是就转过来吧。<br />
如果您要将一个网站迅速保存下来，可以用多种方法，首先是普通的HTML，这样会带来许多网页文件，保存成mht也可以解决问题，不过不够直观，而PDF文件的通用性和对电子阅读器的友好性，让这家名叫PDFmyURL.com的网站亮了。它可以迅速将HTML转换成PDF文件，这一切非常简单，访问他们主页，输入要做PDF的页面地址就好了，制作结束网站会提示你获取PDF，不过需要注意的是，它并没有中文字库，因此会显示一个一个框框。<br />
访问<a href="http://www.PDFmyURL.com">www.PDFmyURL.com</a><br />
</p>
<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=49</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用find,xargs,tar命令可选备份</title>
		<link>http://brightconan.com/?p=47</link>
		<comments>http://brightconan.com/?p=47#comments</comments>
		<pubDate>Tue, 12 Jan 2010 10:19:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器管理]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[xargs]]></category>
		<category><![CDATA[备份]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=47</guid>
		<description><![CDATA[今天写了一个脚本要把server上所有的文件重新处理一下，由于没仔细检查就在server上跑了，导致server上所有的文件改错了，而且这个过程不可逆，幸好在另外一个server上面有备份，于是就想着把备份移过来，刚开始移的时候直接tar命令，没想到要恢复的那个目录下面还有很多pdf,mp3,ppt&#8230;文件，估计大概有20多个G，而我的脚本只改动了文本文件，于是，用find加tar试了一下，可是没想到对文件名中存在空格的文件会出错，搜索了一下，找到了一个好办法。
基本的用法比如：

find . -name '*.htm' &#124; xargs tar czvf backup.tar.gz

一般情况，上面这个命令运行的很好，但是如果找到的文件名代空格，上面的命令运行就可能会出问题了。
find有一个参数-print0，于默认的-print相比，输出的序列不是以空格分隔，而是以null字符分隔。而xargs也有一个参数-0，可以接受以null而非空格间隔的输入流。所以说xargs简直就是为find而生的。上面的问题就很好解决了：

find . -name '*.htm' -print0 &#124; xargs -0 tar czvf backup.tar.gz

Copyright &#169; 2008 This feed is for personal, non-commercial use only.  The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are [...]]]></description>
			<content:encoded><![CDATA[<p>今天写了一个脚本要把server上所有的文件重新处理一下，由于没仔细检查就在server上跑了，导致server上所有的文件改错了，而且这个过程不可逆，幸好在另外一个server上面有备份，于是就想着把备份移过来，刚开始移的时候直接tar命令，没想到要恢复的那个目录下面还有很多pdf,mp3,ppt&#8230;文件，估计大概有20多个G，而我的脚本只改动了文本文件，于是，用find加tar试了一下，可是没想到对文件名中存在空格的文件会出错，搜索了一下，找到了一个好办法。</p>
<p>基本的用法比如：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.htm'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> czvf backup.tar.gz</pre></div></div>

<p>一般情况，上面这个命令运行的很好，但是如果找到的文件名代空格，上面的命令运行就可能会出问题了。</p>
<p>find有一个参数-print0，于默认的-print相比，输出的序列不是以空格分隔，而是以null字符分隔。而xargs也有一个参数-0，可以接受以null而非空格间隔的输入流。所以说xargs简直就是为find而生的。上面的问题就很好解决了：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.htm'</span> <span style="color: #660033;">-print0</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-0</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> czvf backup.tar.gz</pre></div></div>

<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=47</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python脚本抓取学位照信息</title>
		<link>http://brightconan.com/?p=45</link>
		<comments>http://brightconan.com/?p=45#comments</comments>
		<pubDate>Sun, 27 Dec 2009 06:27:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[数据抓取]]></category>
		<category><![CDATA[nju]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web crawler]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=45</guid>
		<description><![CDATA[前两天学校里拍了学位照，在档案馆网站上可以看到自己照片了，由于只要学号和姓名信息，所以就写了个脚本把照片给全部抓下来了，主要用到了urllib2，urllib，汗，以前一直用很底层的httplib做东西，还有这次写了一下代码对浏览器如何操作整个请求过程有了比较深入的了解，脚本执行时需要同目录下有个数据文件，其中包含学号和姓名信息，用逗号隔开，代码如下：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import urllib
import urllib2
import re
&#160;
def save_image&#40;dir,image_name,image&#41;:
    if not os.path.isdir&#40;dir&#41;:
        os.makedirs&#40;dir&#41;
    try:
        image_file = open&#40;dir + image_name,'wb'&#41;
    except IOError as &#40;error, strerror&#41;:
        print &#34;I/O error({0}):{1}&#34;.format&#40;error,strerror&#41;
  [...]]]></description>
			<content:encoded><![CDATA[<p>前两天学校里拍了学位照，在档案馆网站上可以看到自己照片了，由于只要学号和姓名信息，所以就写了个脚本把照片给全部抓下来了，主要用到了urllib2，urllib，汗，以前一直用很底层的httplib做东西，还有这次写了一下代码对浏览器如何操作整个请求过程有了比较深入的了解，脚本执行时需要同目录下有个数据文件，其中包含学号和姓名信息，用逗号隔开，代码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
<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;">re</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> save_image<span style="color: black;">&#40;</span><span style="color: #008000;">dir</span>,image_name,image<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">isdir</span><span style="color: black;">&#40;</span><span style="color: #008000;">dir</span><span style="color: black;">&#41;</span>:
        <span style="color: #dc143c;">os</span>.<span style="color: black;">makedirs</span><span style="color: black;">&#40;</span><span style="color: #008000;">dir</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        image_file = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">dir</span> + image_name,<span style="color: #483d8b;">'wb'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span> <span style="color: #ff7700;font-weight:bold;">as</span> <span style="color: black;">&#40;</span>error, strerror<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;I/O error({0}):{1}&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>error,strerror<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        image_file.<span style="color: black;">write</span><span style="color: black;">&#40;</span>image<span style="color: black;">&#41;</span>
        image_file.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> get_image<span style="color: black;">&#40;</span>name,student_no,login_url,picture_url,pattern<span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;">#Parameter Information</span>
    login_type = <span style="color: #483d8b;">'yes'</span>
    <span style="color: #808080; font-style: italic;">#Configure opener to handle cookies</span>
    opener = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">build_opener</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPCookieProcessor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">install_opener</span><span style="color: black;">&#40;</span>opener<span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#Build Prameters</span>
    params = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'xm'</span>:name,<span style="color: #483d8b;">'xh'</span>:student_no,<span style="color: #483d8b;">'login'</span>:login_type<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#Open login html</span>
    f = opener.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>login_url,params<span style="color: black;">&#41;</span>
    login_html = f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    f.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#Search the image link</span>
    m = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>pattern,login_html<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> m <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<span style="color: #808080; font-style: italic;">#The student hasn't taken picture</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #808080; font-style: italic;">#Get the image    </span>
        match_part = m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
        f = opener.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>picture_url + match_part<span style="color: black;">&#41;</span>
        image = f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> image
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> grab_all<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #008000;">dir</span> = r<span style="color: #483d8b;">'D:<span style="color: #000099; font-weight: bold;">\\</span>temp<span style="color: #000099; font-weight: bold;">\\</span>'</span>
    login_url = <span style="color: #483d8b;">'http://dawww.nju.edu.cn/xwz/login.asp'</span>
    picture_url = <span style="color: #483d8b;">'http://dawww.nju.edu.cn/xwz/picture.asp'</span>
    picture_pattern = <span style="color: #483d8b;">'src=&quot;picture.asp(<span style="color: #000099; font-weight: bold;">\?</span>i=<span style="color: #000099; font-weight: bold;">\d</span>+)&quot;'</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        software_student_file = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'software.txt'</span>,<span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span> <span style="color: #ff7700;font-weight:bold;">as</span> <span style="color: black;">&#40;</span>error, strerror<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;I/O error({0}):{1}&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>error,strerror<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        lines = software_student_file.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> lines:
            line = line.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span>
            name = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
            student_no = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
            image = get_image<span style="color: black;">&#40;</span>name,student_no,login_url,picture_url,picture_pattern<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> image <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:
                save_image<span style="color: black;">&#40;</span><span style="color: #008000;">dir</span>,student_no + <span style="color: #483d8b;">'_'</span> + name + <span style="color: #483d8b;">'.jpg'</span>,image<span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> student_no + <span style="color: #483d8b;">'_'</span> + name + <span style="color: #483d8b;">'.jpg'</span> + <span style="color: #483d8b;">' is saved'</span>
        software_student_file.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    grab_all<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=45</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>如何控制frames的部分打印</title>
		<link>http://brightconan.com/?p=42</link>
		<comments>http://brightconan.com/?p=42#comments</comments>
		<pubDate>Tue, 22 Dec 2009 08:00:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前台设计]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[print]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=42</guid>
		<description><![CDATA[前两天要做一个页面的print button，但是网页是由两个frame构成的，而且其中的一个frame中包含了一个width很大的table，所以每次使用ie打印的时候都会将table的右部截去，但是FF打印的时候会自动缩放，T_T，由此可见ie的劣根性。。。
网上搜索了一下，大概有几种方法可以解决局部打印问题。

在html里面嵌入&#60;!&#8211;start_pirnt&#8211;&#62;&#60;!&#8211;end_print&#8211;&#62;标签，然后使用js将要打印的部分取出，然后新打开一个窗口，将要打印的部分送入新窗口，onload事件里面写window.print即可，这样做了以后table就会全打出来了，但是这样做的用户体验不会太好，新开的窗口还需手动关上，但是我看了一下好几个大型网站的做法，在页面布局很复杂的情况下，按下print按钮，先会出来一个print preview的页面，然后再打印，这样也许给了用户适当的选择。
使用css控制要打印的内容，对不打印的部分加上&#60;div class=&#8221;noprint&#8221;&#62;&#60;/div&#62;，对要缩放的table加上id=zoom_table，然后css里面加上@media print{.noprint {display:none;} #zoom_talbe{zoom:70%}}，这里要注意的是，zoom这个属性只有ie支持，这样就可以解决部分打印的问题了，自己使用的是第二种方法

这里还要注意的是如果不想把另外一个frame打印出来，则需window.parent.frame_name.print

Copyright &#169; 2008 This feed is for personal, non-commercial use only.  The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint: )]]></description>
			<content:encoded><![CDATA[<p>前两天要做一个页面的print button，但是网页是由两个frame构成的，而且其中的一个frame中包含了一个width很大的table，所以每次使用ie打印的时候都会将table的右部截去，但是FF打印的时候会自动缩放，T_T，由此可见ie的劣根性。。。</p>
<p>网上搜索了一下，大概有几种方法可以解决局部打印问题。</p>
<ol>
<li>在html里面嵌入&lt;!&#8211;start_pirnt&#8211;&gt;&lt;!&#8211;end_print&#8211;&gt;标签，然后使用js将要打印的部分取出，然后新打开一个窗口，将要打印的部分送入新窗口，onload事件里面写window.print即可，这样做了以后table就会全打出来了，但是这样做的用户体验不会太好，新开的窗口还需手动关上，但是我看了一下好几个大型网站的做法，在页面布局很复杂的情况下，按下print按钮，先会出来一个print preview的页面，然后再打印，这样也许给了用户适当的选择。</li>
<li>使用css控制要打印的内容，对不打印的部分加上&lt;div class=&#8221;noprint&#8221;&gt;&lt;/div&gt;，对要缩放的table加上id=zoom_table，然后css里面加上@media print{.noprint {display:none;} #zoom_talbe{zoom:70%}}，这里要注意的是，zoom这个属性只有ie支持，这样就可以解决部分打印的问题了，自己使用的是第二种方法</li>
</ol>
<p>这里还要注意的是如果不想把另外一个frame打印出来，则需window.parent.frame_name.print</p>
<ol></ol>
<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>上海交通大学08年研究生机试题B</title>
		<link>http://brightconan.com/?p=40</link>
		<comments>http://brightconan.com/?p=40#comments</comments>
		<pubDate>Wed, 23 Sep 2009 12:04:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[算法]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[机试]]></category>
		<category><![CDATA[研究生]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=40</guid>
		<description><![CDATA[题目
Problem B. Simple Sorting
Input file: Standard Input
Output file: Standard Output
Time Limit: 1 Second
You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.
Input
The first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next [...]]]></description>
			<content:encoded><![CDATA[<p><strong>题目</strong><br />
Problem B. Simple Sorting<br />
<strong>Input file: </strong>Standard Input<br />
<strong>Output file: </strong>Standard Output<br />
<strong>Time Limit: </strong>1 Second</p>
<p>You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.</p>
<p><strong>Input</strong><br />
The first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next N lines contain N integer numbers(one number per each line) of the original array.</p>
<p><strong>Output</strong><br />
Output file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.</p>
<p><strong>Sample input and output</strong><br />
Standard Input                  Standard Output<br />
6                                                  3<br />
8                                                  7<br />
8                                                  8<br />
7<br />
3<br />
7<br />
7</p>
<p><strong>C++代码</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;fstream&gt;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
<span style="color: #339900;">#define MAX_LEN 1000</span>
&nbsp;
<span style="color: #0000ff;">int</span> number_of_inputs<span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> inputs<span style="color: #008000;">&#91;</span>MAX_LEN<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> get_inputs<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> i<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span> <span style="color: #000080;">&gt;&gt;</span> number_of_inputs<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>number_of_inputs<span style="color: #008080;">;</span><span style="color: #000040;">++</span>i<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cin</span> <span style="color: #000080;">&gt;&gt;</span> inputs<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> <span style="color: #0000dd;">qsort</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> left,<span style="color: #0000ff;">int</span> right<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> left<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> j <span style="color: #000080;">=</span> right<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> pivot_index <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000040;">+</span> j<span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> pivot <span style="color: #000080;">=</span> inputs<span style="color: #008000;">&#91;</span>pivot_index<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">&lt;=</span> j<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>inputs<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;</span> pivot<span style="color: #008000;">&#41;</span>
			<span style="color: #000040;">++</span>i<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>inputs<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&gt;</span> pivot<span style="color: #008000;">&#41;</span>
			<span style="color: #000040;">--</span>j<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">&lt;=</span> j<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">int</span> temp <span style="color: #000080;">=</span> inputs<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			inputs<span style="color: #008000;">&#91;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> inputs<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			inputs<span style="color: #008000;">&#91;</span>j<span style="color: #000040;">--</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> temp<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">&gt;</span> left<span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">qsort</span><span style="color: #008000;">&#40;</span>left,j<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>j <span style="color: #000080;">&lt;</span> right<span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">qsort</span><span style="color: #008000;">&#40;</span>i,right<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	get_inputs<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000dd;">qsort</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>,number_of_inputs<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	ofstream output_file<span style="color: #008080;">;</span>
	output_file.<span style="color: #007788;">open</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;output.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>number_of_inputs<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span><span style="color: #000040;">++</span>i<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>inputs<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> inputs<span style="color: #008000;">&#91;</span>i<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
			output_file <span style="color: #000080;">&lt;&lt;</span> inputs<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">==</span> number_of_inputs <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span>
		output_file <span style="color: #000080;">&lt;&lt;</span> inputs<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	output_file.<span style="color: #007788;">close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>上海交通大学08年研究生机试题A</title>
		<link>http://brightconan.com/?p=34</link>
		<comments>http://brightconan.com/?p=34#comments</comments>
		<pubDate>Wed, 23 Sep 2009 11:51:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[算法]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[机试]]></category>
		<category><![CDATA[研究生]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=34</guid>
		<description><![CDATA[这两天在准备保送到交大软院，由于要考机试，这两天狂练C++中，把自己的代码贴出来吧，不能再懒了，再懒博客就要荒废了。
题目：
Problem A. Prime Number
Input file: Standard Input Page 1 of 2
Output file: Standard Output
Time Limit: 1 Second
Output the k-th prime number.
Input
k≤10000
Output
The k-th prime number.
Sample input and output
Standard Input    Standard Output
3                       [...]]]></description>
			<content:encoded><![CDATA[<p>这两天在准备保送到交大软院，由于要考机试，这两天狂练C++中，把自己的代码贴出来吧，不能再懒了，再懒博客就要荒废了。</p>
<p>题目：<br />
Problem A. Prime Number<br />
Input file: Standard Input Page 1 of 2<br />
Output file: Standard Output<br />
Time Limit: 1 Second<br />
Output the k-th prime number.</p>
<p>Input<br />
k≤10000</p>
<p>Output<br />
The k-th prime number.</p>
<p>Sample input and output<br />
Standard Input    Standard Output<br />
3                                   5<br />
7                                  17</p>
<p>C++代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;cmath&gt;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> isPrime<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> n<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> i,flag <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span><span style="color: #0000dd;">sqrt</span><span style="color: #008000;">&#40;</span>n<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><span style="color: #000040;">++</span>i<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>n <span style="color: #000040;">%</span> i <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			flag <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> flag<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span>,n <span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span>,k,result<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span> <span style="color: #000080;">&gt;&gt;</span> k<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>i <span style="color: #000080;">&lt;=</span> k<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		result <span style="color: #000080;">=</span> n<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>isPrime<span style="color: #008000;">&#40;</span>result<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
			<span style="color: #000040;">++</span>i<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> result<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=34</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3个很好用的Launcher加载器</title>
		<link>http://brightconan.com/?p=31</link>
		<comments>http://brightconan.com/?p=31#comments</comments>
		<pubDate>Thu, 17 Sep 2009 07:32:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[系统工具]]></category>
		<category><![CDATA[Launcher]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=31</guid>
		<description><![CDATA[  加载器（Launcher）是一类应用程序，允许你输入应用程序（或文档）名称的第一部分来加载它。通常，这是一种更高效地加载应用程序的方式。
  在这里我将推荐3款Launcher加载器：
  1. Launchy
  2. Colibri
  3. Enso
  Launchy和Colibri都开源，两者都允许你打开一个小窗口，你输入应用程序名称，它就会弹出一个应用列表。Launchy是现在最流行的开源加载器。Colibri则尝试模仿一个名为“Quicksilver”的Mac OS X工具。而Enso加载器有一些有趣的附加特性。它也是免费的，有Humanized公司开发。该公司是Jef Raskin所创立。Enso中融入了许多他自己的用户界面设计观点&#8211;有时有点偏激，但很有效。
Copyright &#169; 2008 This feed is for personal, non-commercial use only.  The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are [...]]]></description>
			<content:encoded><![CDATA[<p>  加载器（Launcher）是一类应用程序，允许你输入应用程序（或文档）名称的第一部分来加载它。通常，这是一种更高效地加载应用程序的方式。</p>
<div id="attachment_32" class="wp-caption alignnone" style="width: 370px"><img src="http://brightconan.com/wp-content/uploads/2009/09/2009-9-17-15-15-11.png" alt="Launcher" title="Launcher" width="360" height="308" class="size-full wp-image-32" /><p class="wp-caption-text">Launcher</p></div>
<p>  在这里我将推荐3款Launcher加载器：<br />
  1. <a href="http://www.launchy.net">Launchy</a><br />
  2. <a href="http://colibri.leetspeak.org">Colibri</a><br />
  3. <a href="http://www.humanized.com">Enso</a></p>
<p>  Launchy和Colibri都开源，两者都允许你打开一个小窗口，你输入应用程序名称，它就会弹出一个应用列表。Launchy是现在最流行的开源加载器。Colibri则尝试模仿一个名为“Quicksilver”的Mac OS X工具。而Enso加载器有一些有趣的附加特性。它也是免费的，有Humanized公司开发。该公司是Jef Raskin所创立。Enso中融入了许多他自己的用户界面设计观点&#8211;有时有点偏激，但很有效。</p>
<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=31</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TFTP协议里的魔术师学徒症(Sorcerer&#8217;s Apprentice Syndrome)</title>
		<link>http://brightconan.com/?p=24</link>
		<comments>http://brightconan.com/?p=24#comments</comments>
		<pubDate>Wed, 10 Jun 2009 02:34:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[网络]]></category>
		<category><![CDATA[SAS]]></category>
		<category><![CDATA[Sorcerer's Apprentice Syndrome]]></category>
		<category><![CDATA[TFTP]]></category>
		<category><![CDATA[魔术师学徒综合症]]></category>

		<guid isPermaLink="false">http://brightconan.com/?p=24</guid>
		<description><![CDATA[最近正在学习互联网程序设计课程，老师要求写一个TFTP服务器，看了一下TFTP的相关知识，发现其中有一个Sorcerer&#8217;s Apprentice Syndrome专有名词，不是很懂，然后到wiki上面看了一下，然后明白了大概是怎么回事，下面讲一下。
在TFTP早期版本(RFC783)中，规定了数据发送方在一次数据发送之后，必须等待数据接收方acknowledgement包的送回，当接收到acknowledgement包的时候，就把接下来的数据继续发送，但是如果从发送开始到接收到acknowledgement包之间的时间大于一个值timeout，那么，数据发送方认为本次发送的数据包丢失，它将再次发送本次数据包。
可是，在有一种情况下，会产生很严重的问题：
1. 数据发送方S（source）发送数据X给数据接收方D（Destination）
2. 数据接收方D收到了数据X，并且将数据X的确认包acknowledgement发送给S
3. 此时该确认包acknowledgement在网络中严重堵塞，但是没有丢失
4. 当timeout值超时后，S将数据报X再次发送给D
5. S收到了X的第一次数据确认包，发送数据包X+1给D
6. D第二次收到了S发送的数据包X，将数据X的确认包再次发送给S
7. D收到了数据包X+1，并将数据包X+1的确认包返回给S
8. S第二次收到了数据包X的确认包，再次将数据包X+1发送给D
9. S收到了X+1的确认包，把数据包X+2发送给D
10. D第二次收到了数据包X+1，再次发送数据包X+1的确认包给S
11. D收到了X+2的数据包，将数据包X+2的确认包返回给S
如此往复
这样，这个过程已经趋于稳定，现在网络中S向D发送数据每次都需要发送同一数据的两份拷贝，这样极大地占用了网络资源，而在最坏的情况下，有可能接下来所有发出的数据包都会超时，那么这种情况下会造成数据包传输的指数级爆炸，就像魔术师学徒变扫帚一样，一个变两，两个变四，四个变八（具体那部电影没看过，这里只能YY下^_^），这种情况在现实中是不允许存在的，这会给TFTP服务器以及网络带来太大的负担，那么如何解决这个问题呢，很简单，只有当收到某个数据的第一个确认包时才将该数据包的下一个数据包给对端，这样就很方便地解决了魔术师学徒综合症问题（SAS）
Copyright &#169; 2008 This feed is for personal, non-commercial use only.  The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the [...]]]></description>
			<content:encoded><![CDATA[<p>最近正在学习互联网程序设计课程，老师要求写一个TFTP服务器，看了一下TFTP的相关知识，发现其中有一个Sorcerer&#8217;s Apprentice Syndrome专有名词，不是很懂，然后到wiki上面看了一下，然后明白了大概是怎么回事，下面讲一下。</p>
<p>在TFTP早期版本(RFC783)中，规定了数据发送方在一次数据发送之后，必须等待数据接收方acknowledgement包的送回，当接收到acknowledgement包的时候，就把接下来的数据继续发送，但是如果从发送开始到接收到acknowledgement包之间的时间大于一个值timeout，那么，数据发送方认为本次发送的数据包丢失，它将再次发送本次数据包。</p>
<p>可是，在有一种情况下，会产生很严重的问题：<br />
1. 数据发送方S（source）发送数据X给数据接收方D（Destination）<br />
2. 数据接收方D收到了数据X，并且将数据X的确认包acknowledgement发送给S<br />
3. 此时该确认包acknowledgement在网络中严重堵塞，但是没有丢失<br />
4. 当timeout值超时后，S将数据报X再次发送给D<br />
5. S收到了X的第一次数据确认包，发送数据包X+1给D<br />
6. D第二次收到了S发送的数据包X，将数据X的确认包再次发送给S<br />
7. D收到了数据包X+1，并将数据包X+1的确认包返回给S<br />
8. S第二次收到了数据包X的确认包，再次将数据包X+1发送给D<br />
9. S收到了X+1的确认包，把数据包X+2发送给D<br />
10. D第二次收到了数据包X+1，再次发送数据包X+1的确认包给S<br />
11. D收到了X+2的数据包，将数据包X+2的确认包返回给S<br />
如此往复</p>
<p>这样，这个过程已经趋于稳定，现在网络中S向D发送数据每次都需要发送同一数据的两份拷贝，这样极大地占用了网络资源，而在最坏的情况下，有可能接下来所有发出的数据包都会超时，那么这种情况下会造成数据包传输的指数级爆炸，就像魔术师学徒变扫帚一样，一个变两，两个变四，四个变八（具体那部电影没看过，这里只能YY下^_^），这种情况在现实中是不允许存在的，这会给TFTP服务器以及网络带来太大的负担，那么如何解决这个问题呢，很简单，只有当收到某个数据的第一个确认包时才将该数据包的下一个数据包给对端，这样就很方便地解决了魔术师学徒综合症问题（SAS）</p>
<hr /><small>Copyright &copy; 2008<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small>]]></content:encoded>
			<wfw:commentRss>http://brightconan.com/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
