<?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>Happy SA &#187; happysa</title>
	<atom:link href="http://blog.happysa.org/author/happysa/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.happysa.org</link>
	<description>做快乐的系统管理员</description>
	<lastBuildDate>Sun, 13 Nov 2011 14:30:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://blog.happysa.org/?pushpress=hub'/>
		<item>
		<title>perl下的时间处理</title>
		<link>http://blog.happysa.org/tips/time_in_perl.html</link>
		<comments>http://blog.happysa.org/tips/time_in_perl.html#comments</comments>
		<pubDate>Sat, 20 Jun 2009 02:11:46 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[时间]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=200</guid>
		<description><![CDATA[获得unix时间： 1 2 3 4 5 #!/usr/bin/perl use strict; use warnings; &#160; print time; 获得当前系统时间： 1 print scalar localtime&#40;&#41;; 这里localtime()可带一个时间参数，默认是以当前的unix时间为参数，若要得到unix时间100秒的具体时间，可以用localtime(100)。 unix时间转换成普通的日期时间： 1 my &#40;$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst&#41; = localtime&#40;time&#41;; $sec &#8211;> 秒 $min &#8211;> 分 $hour &#8211;> 时 $mday &#8211;> 当月的第几天（1..31） $mon &#8211;> 月（0.11） $year &#8211;> 年（1900..，从1900年开始，所以得加上1900才能得到当前年份） $wday &#8211;> 一周中的第几天（0是星期天，然后1..6代表周一到周六） $yday &#8211;> 一年中的第几天（0..365） $isdst &#8211;> 夏令时标志，如果当前时间正在使用夏令时，则$isdst为1，否则为0。 执行localtime函数得到的就是由上面这些值所组成的一个字符串。 普通的日期时间转换成unix时间 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>获得unix时间：</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl </span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #000066;">time</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>获得当前系统时间：</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">print</span> <span style="color: #000066;">scalar</span> <span style="color: #000066;">localtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>这里localtime()可带一个时间参数，默认是以当前的unix时间为参数，若要得到unix时间100秒的具体时间，可以用<strong>localtime(100)</strong>。</p>
<p><strong>unix时间转换成普通的日期时间：</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sec</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$min</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mday</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mon</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$year</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$wday</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$yday</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$isdst</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">localtime</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>$sec     &#8211;>    秒<br />
$min    &#8211;>    分<br />
$hour   &#8211;>    时<br />
$mday  &#8211;>    当月的第几天（1..31）<br />
$mon   &#8211;>    月（0.11）<br />
$year    &#8211;>    年（1900..，从1900年开始，所以得加上1900才能得到当前年份）<br />
$wday  &#8211;>    一周中的第几天（0是星期天，然后1..6代表周一到周六）<br />
$yday   &#8211;>    一年中的第几天（0..365）<br />
$isdst   &#8211;>    <a href="http://zh.wikipedia.org/w/index.php?title=%E5%A4%8F%E4%BB%A4%E6%97%B6&#038;variant=zh-cn">夏令时</a>标志，如果当前时间正在使用夏令时，则$isdst为1，否则为0。<br />
执行localtime函数得到的就是由上面这些值所组成的一个字符串。</p>
<p><strong>普通的日期时间转换成unix时间</strong><br />
有时候为了得到两次时间间隔，把普通日期时间转换成unix时间处理起来就方便多了。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">Local</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$time</span> <span style="color: #339933;">=</span> timelocal<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sec</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$min</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mday</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mon</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$year</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;"># replace 'timelocal' with 'timegm' if your input date is GMT/UTC</span></pre></td></tr></table></div>

<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>2009-09-09 -- <a href="http://blog.happysa.org/perl/perl_stat.html" title="perl里的stat函数">perl里的stat函数</a> (6)</li><li>2009-06-03 -- <a href="http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html" title="perl中去除数组里的重复元素">perl中去除数组里的重复元素</a> (2)</li><li>2009-05-30 -- <a href="http://blog.happysa.org/tips/easy_index_for_tips.html" title="命令行下简单的检索">命令行下简单的检索</a> (9)</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/tips/time_in_perl.html">Permalink</a> |
<a href="http://blog.happysa.org/tips/time_in_perl.html#comments">5 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/tips/time_in_perl.html&title=perl下的时间处理">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/perl" rel="tag">perl</a>, <a href="http://blog.happysa.org/tag/time" rel="tag">time</a>, <a href="http://blog.happysa.org/tag/%e6%97%b6%e9%97%b4" rel="tag">时间</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/tips/time_in_perl.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>perl中去除数组里的重复元素</title>
		<link>http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html</link>
		<comments>http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html#comments</comments>
		<pubDate>Tue, 02 Jun 2009 16:15:19 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=193</guid>
		<description><![CDATA[方法很多，先介绍下我自己的方法，通过hash的键唯一性来得到不重复的元素列表，代码如下： 1 2 3 4 5 6 7 8 #!/usr/bin/perl use warnings; use strict; &#160; my @array = &#40;&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;a&#34;,&#34;d&#34;,&#34;c&#34;&#41;; my %hash; $hash&#123;$_&#125;++ foreach &#40;@array&#41;; print sort keys %hash; 下面是网上看到的一个方法，通过grep函数来获得不重复的元素： 1 2 3 4 5 6 7 8 #!/usr/bin/perl use warnings; use strict; &#160; my @array = &#40;&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;a&#34;,&#34;d&#34;,&#34;c&#34;&#41;; my %hash; my @out = grep &#40;!$hash&#123;$_&#125;++, @array&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>方法很多，先介绍下我自己的方法，通过hash的键唯一性来得到不重复的元素列表，代码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl </span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@array</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;d&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;d&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%hash</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$hash</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">++</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #000066;">sort</span> <span style="color: #000066;">keys</span> <span style="color: #0000ff;">%hash</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>下面是网上看到的一个方法，通过grep函数来获得不重复的元素：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@array</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;d&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;d&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%hash</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@out</span> <span style="color: #339933;">=</span> <span style="color: #000066;">grep</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$hash</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">++,</span> <span style="color: #0000ff;">@array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #0000ff;">@out</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>该方法的意思是：当第一次碰到某元素$_时，$hash{$_}的值为0，!$hash{$_}为真，于是把元素$_加到数组@out中，然后把$hash{$_}值加1，这样下次再碰到同样的元素时由于!$hash{$_}此时为假，就不会写入@out数组里了，从而达到去掉重复元素的目的。<br />
两种方法从运行效率上来看应该差不多，不过第二个感觉更炫一点。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>2009-09-09 -- <a href="http://blog.happysa.org/perl/perl_stat.html" title="perl里的stat函数">perl里的stat函数</a> (6)</li><li>2009-06-20 -- <a href="http://blog.happysa.org/tips/time_in_perl.html" title="perl下的时间处理">perl下的时间处理</a> (5)</li><li>2009-05-30 -- <a href="http://blog.happysa.org/tips/easy_index_for_tips.html" title="命令行下简单的检索">命令行下简单的检索</a> (9)</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html">Permalink</a> |
<a href="http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html&title=perl中去除数组里的重复元素">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/perl" rel="tag">perl</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/tips/remove_duplicate_elements_in_perl.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>70码</title>
		<link>http://blog.happysa.org/blog/70yard.html</link>
		<comments>http://blog.happysa.org/blog/70yard.html#comments</comments>
		<pubDate>Tue, 12 May 2009 23:25:52 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[70码]]></category>
		<category><![CDATA[杭州]]></category>
		<category><![CDATA[飙车]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/blog/70%e7%a0%81.html</guid>
		<description><![CDATA[注：此图来自internet，非原创。版权没有，翻印不究。 相关文章：2010-07-18 -- 西湖荷花 (0) © happysa for Happy SA, 2009. &#124; Permalink &#124; 2 comments &#124; Add to del.icio.us Post tags: 70码, 杭州, 飙车 Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-179" title="70码" src="http://happysa.org/blog/wp-content/uploads/2009/05/23562797579.jpg" alt="70码" width="544" height="544" /></p>
<p><em>注：此图来自internet，非原创。版权没有，翻印不究。</em></p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>2010-07-18 -- <a href="http://blog.happysa.org/blog/lotus-of-xihu.html" title="西湖荷花">西湖荷花</a> (0)</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/blog/70yard.html">Permalink</a> |
<a href="http://blog.happysa.org/blog/70yard.html#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/blog/70yard.html&title=70码">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/70%e7%a0%81" rel="tag">70码</a>, <a href="http://blog.happysa.org/tag/%e6%9d%ad%e5%b7%9e" rel="tag">杭州</a>, <a href="http://blog.happysa.org/tag/%e9%a3%99%e8%bd%a6" rel="tag">飙车</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/blog/70yard.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>细节决定成败</title>
		<link>http://blog.happysa.org/blog/detail_is_the_key_of_success.html</link>
		<comments>http://blog.happysa.org/blog/detail_is_the_key_of_success.html#comments</comments>
		<pubDate>Sun, 10 May 2009 02:53:44 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[细节]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=167</guid>
		<description><![CDATA[      话说今天学校里体育达标测试中某女生替别人跑800被抓出来了，究其原因，我觉得很大程度上是细节没处理好，还有就是没有看清当时的形势。 登记名字的时候把学号写错了。 可能是一开始习惯性地把自己的学号写上去了，后来发现不对，于是把原来的划掉重新写了另一个学号。当时老师看到就问了一句，“你怎么学号都给写错了，不会是替考的吧？”之后就在她跑的过程中拿起她的学生证仔细看了起来，于是发现学生证上的照片是后来贴上去的，照片上甚至没有本来应该有的钢印。 跑得太快了，实力很明显。听老师的意思说，那种跑得很慢，或者跑完后还很痛苦的一般都不会是替人跑的，因为跑得慢还去替人跑一点意义都没有。跑得快的就难说了，看那女的很轻松地跑完了800米，再加上前面的一些事情，更加怀疑她是在替考的。       最后跑完登记成绩的时候老师让她去拿一卡通来，因为上面的照片是印上去的改不掉，结果她一去不复返了。       细节决定成败，如果她在一开始的时候没有把学号写错，或者先看清楚当时的形势，或许情况会好一点。因为当时是下午2点很热的时候，跑的一共就三个女生，要混水摸鱼比较难，而且学生证是在跑完后登记成绩的时候给老师看一眼就好了，那个时候一般不会很仔细看，而她却在一开始的时候就把学生证递上去了，这就给了老师更多的时间来研究学生证，结果就露馅了。而在早上就有很多女生在跑，如果她选择早上来或者第二天早上再来，那可能就成功了。       最后如果确定她的替跑属实的话，那可能等待她和被替考那位同学的就是一次记过或者警告处分了，敢做就要敢当，但愿她们不要因为这个而耽误了学业。 相关文章：暂无相关日志 © happysa for Happy SA, 2009. &#124; Permalink &#124; 9 comments &#124; Add to del.icio.us Post tags: 细节 Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-171" title="detail" src="http://happysa.org/blog/wp-content/uploads/2009/05/detail.jpg" alt="detail" width="100" height="60" />      话说今天学校里体育达标测试中某女生替别人跑800被抓出来了，究其原因，我觉得很大程度上是细节没处理好，还有就是没有看清当时的形势。</p>
<ul>
<li>登记名字的时候把学号写错了。 可能是一开始习惯性地把自己的学号写上去了，后来发现不对，于是把原来的划掉重新写了另一个学号。当时老师看到就问了一句，“你怎么学号都给写错了，不会是替考的吧？”之后就在她跑的过程中拿起她的学生证仔细看了起来，于是发现学生证上的照片是后来贴上去的，照片上甚至没有本来应该有的钢印。</li>
<li>跑得太快了，实力很明显。听老师的意思说，那种跑得很慢，或者跑完后还很痛苦的一般都不会是替人跑的，因为跑得慢还去替人跑一点意义都没有。跑得快的就难说了，看那女的很轻松地跑完了800米，再加上前面的一些事情，更加怀疑她是在替考的。</li>
</ul>
<p>      最后跑完登记成绩的时候老师让她去拿一卡通来，因为上面的照片是印上去的改不掉，结果她一去不复返了。</p>
<p>      细节决定成败，如果她在一开始的时候没有把学号写错，或者先看清楚当时的形势，或许情况会好一点。因为当时是下午2点很热的时候，跑的一共就三个女生，要混水摸鱼比较难，而且学生证是在跑完后登记成绩的时候给老师看一眼就好了，那个时候一般不会很仔细看，而她却在一开始的时候就把学生证递上去了，这就给了老师更多的时间来研究学生证，结果就露馅了。而在早上就有很多女生在跑，如果她选择早上来或者第二天早上再来，那可能就成功了。</p>
<p>      最后如果确定她的替跑属实的话，那可能等待她和被替考那位同学的就是一次记过或者警告处分了，敢做就要敢当，但愿她们不要因为这个而耽误了学业。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>暂无相关日志</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/blog/detail_is_the_key_of_success.html">Permalink</a> |
<a href="http://blog.happysa.org/blog/detail_is_the_key_of_success.html#comments">9 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/blog/detail_is_the_key_of_success.html&title=细节决定成败">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/%e7%bb%86%e8%8a%82" rel="tag">细节</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/blog/detail_is_the_key_of_success.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>给grep上色</title>
		<link>http://blog.happysa.org/linux/grep_color.html</link>
		<comments>http://blog.happysa.org/linux/grep_color.html#comments</comments>
		<pubDate>Sat, 02 May 2009 11:09:51 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[颜色]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=142</guid>
		<description><![CDATA[功能类似于vim里的hlsearch，把匹配的东西高亮显示出来，易于定位，如图 这里用到grep的一个参数&#8211;color，color有三个值供选择：never、always、auto。always和auto的区别就是，always会在任何情况下都给匹配字段加上颜色标记，当通过管道或重定向时就会多出一些控制字符，结果会变成 export ^[[1;32m^[[KGREP^[[m^[[K_OPTIONS=&#8217;&#8211;color=always&#8217; export ^[[1;32m^[[KGREP^[[m^[[K_COLOR=&#8217;1;32&#8242; 而auto则只在输出到终端时才加上颜色。 可以在.bashrc里加上 export GREP_OPTIONS=&#8217;&#8211;color=auto&#8217; 来实现高亮匹配，具体用什么颜色，可以通过 export GREP_COLOR=&#8217;a;b&#8217; #默认是1;31，即高亮的红色 来设置，其中: a可以选择:【0,1,4,5,7,8】 0 关闭所有属性 1 设置高亮度 4 下划线 5 闪烁 7 反显 8 消隐 b可以选择:【30-37或40-47】 30 black 31 red 32 green 33 yellow 34 blue 35 purple 36 cyan 37 white 30 &#8212; 37 设置前景色 40 &#8212; 47 设置背景色 一些参考 grep的man文档 [...]]]></description>
			<content:encoded><![CDATA[<p>功能类似于vim里的hlsearch，把匹配的东西高亮显示出来，易于定位，如图</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-162" title="grep_color" src="http://happysa.org/blog/wp-content/uploads/2009/05/grep_color3.jpg" alt="grep_color" width="647" height="296" /></p>
<p>这里用到grep的一个参数&#8211;color，color有三个值供选择：never、always、auto。always和auto的区别就是，always会在任何情况下都给匹配字段加上颜色标记，当通过管道或重定向时就会多出一些控制字符，结果会变成<br />
export ^[[1;32m^[[KGREP^[[m^[[K_OPTIONS=&#8217;&#8211;color=always&#8217;<br />
export ^[[1;32m^[[KGREP^[[m^[[K_COLOR=&#8217;1;32&#8242;<br />
而auto则只在输出到终端时才加上颜色。<br />
可以在.bashrc里加上<br />
export GREP_OPTIONS=&#8217;&#8211;color=auto&#8217;<br />
来实现高亮匹配，具体用什么颜色，可以通过<br />
export GREP_COLOR=&#8217;a;b&#8217;   #<em>默认是1;31，即高亮的红色</em><br />
来设置，其中:<br />
a可以选择:【0,1,4,5,7,8】</p>
<p>0 关闭所有属性<br />
1 设置高亮度<br />
4 下划线<br />
5 闪烁<br />
7 反显<br />
8 消隐</p>
<p>b可以选择:【30-37或40-47】</p>
<p>30	black<br />
31	red<br />
32	green<br />
33	yellow<br />
34	blue<br />
35	purple<br />
36	cyan<br />
37	white<br />
30 &#8212; 37 设置前景色<br />
40 &#8212; 47 设置背景色</p>
<p>一些参考<br />
<a href="http://linux.die.net/man/1/grep">grep的man文档</a><br />
<a href="http://www.linux.com/articles/54514">GNU grep&#8217;s new features</a><br />
<a href="http://www.ccs.neu.edu/home/katz/unix-colors.html">Howto colorize Unix/Linux stuff</a></p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>2009-08-07 -- <a href="http://blog.happysa.org/linux/ieee8021x_on_linux.html" title="linux下通过802.1x协议连公司内网">linux下通过802.1x协议连公司内网</a> (3)</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/linux/grep_color.html">Permalink</a> |
<a href="http://blog.happysa.org/linux/grep_color.html#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/linux/grep_color.html&title=给grep上色">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/color" rel="tag">color</a>, <a href="http://blog.happysa.org/tag/grep" rel="tag">grep</a>, <a href="http://blog.happysa.org/tag/linux" rel="tag">linux</a>, <a href="http://blog.happysa.org/tag/%e9%a2%9c%e8%89%b2" rel="tag">颜色</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/linux/grep_color.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>在google map上看猪流感疫情分布图（顺便普及下流感常识）</title>
		<link>http://blog.happysa.org/internet/h1n1_on_google_map.html</link>
		<comments>http://blog.happysa.org/internet/h1n1_on_google_map.html#comments</comments>
		<pubDate>Tue, 28 Apr 2009 16:21:04 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[google map]]></category>
		<category><![CDATA[猪流感]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=129</guid>
		<description><![CDATA[互联网越来越密切地融入到人们的生活中了，从这个google map的猪流感疫情分布图就可见一斑。 这个以「猪流感」为主的 Google Map 叫 「H1N1 Swine Flu 猪流感疫情分步图」，它会依据实际情況在不同的国家及地区标示各种不同类型的「猪流感」怀疑、确诊、死亡个案。每个泡泡代表一个通报病例，不同颜色代表不同意义。具体如下： 粉红色　　　　　　代表　　怀疑为猪流感 紫色　　　　　　　代表　　确定为猪流感 泡泡上无黑点者　　代表　　即为死亡病例。 黃色　　　　　　　代表　　检验后为H1N1阴性（即已经排除的病例） 点击查看H1N1猪流感Google地图： 1、2009 Swine Flu (H1N1) Outbreak Map 2、H1N1 Swine Flu 好像韩国已经发现疑似病例了，不知道会不会传到国内，希望不要发展到当年的非典那样，满大街的口罩，草木皆兵。 普及一下科普知识，以下是转自sohu网的关于猪流感、禽流感以及普通流感之间的一些对比 猪流感 传播途径：该病毒非常活跃，可由人传染给猪，猪传染给人，也可在人群间传播。人群间传播主要是以感染者的咳嗽和喷嚏为媒介。 症状：人类感染猪流感的最明显症状是“最初出现类似普通流感症状，但体温突然超过39度，肌肉酸痛感明显增强，伴随有眩晕、头疼、腹泻、呕吐等症状或其中部分症状。 潜伏期：新型猪流感病毒可能在人体潜伏7天后才表现出病症。 死亡率：猪流感的死亡率为6.77%，比一般流感要高，其高致死率的主要原因有两个：一是病毒来势凶猛；二是民众起初对新疾病不重视，以为是普通感冒，很多人自己随便吃些药，错过了发病初72小时的最佳救治期。 易感染人群：猪流感致死的患者年龄绝大多数在20岁至45岁之间，属于青壮年。 防治疫苗：人类已研制出的所有流感疫苗对于猪流感都无效，但人感染猪流感是可防、可控、可治的。 禽流感 传播途径：禽流感病毒迄今只能通过禽传染给人，不能通过人传染给人。 症状：感染后的症状主要表现为高热、咳嗽、流涕、肌痛等，多数伴有严重的肺炎，严重者心、肾等多种脏器衰竭导致死亡。 潜伏期：人禽流感潜伏期一般为1～3天,通常在7天以内。 死亡率：人患禽流感死亡率达60%。 易感染人群：在已发现的感染病例中，13岁以下儿童所占比例较高，病情较重，其属于易感人群。 防治疫苗：各国已在研制预防禽流感的疫苗。 普通流感 传播途径：人际传播，空气飞沫传播为主，流感患者及隐性感染者为主要传染源。发病后1~7天有传染性，病初2~3天传染性最强。 症状：普通人流感与人感染猪流感后的症状相似。 潜伏期：流感的潜伏期为1-4天，平均为2天。 死亡率：普通流感可致死，但死亡率较低。 易感染人群：四类最易感染流感的人群，分别是：老年人，患有肝脏、肾脏、心脏等慢性病的人群，经常接触流感人群的医护人员，儿童。 防治疫苗：已研制出可预防流感的疫苗，接种时间多为每年10-11月中旬，每年接种1次。 相关文章：2010-03-29 -- where am I(充分利用google手机的GPS功能) (2) © happysa [...]]]></description>
			<content:encoded><![CDATA[<p>互联网越来越密切地融入到人们的生活中了，从这个google map的猪流感疫情分布图就可见一斑。</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-165" title="2009-04-28_2351291" src="http://happysa.org/blog/wp-content/uploads/2009/04/2009-04-28_2351291.jpg" alt="2009-04-28_2351291" width="614" height="424" /></p>
<p>这个以「猪流感」为主的 Google Map 叫 「<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;t=p&amp;msa=0&amp;msid=106484775090296685271.0004681a37b713f6b5950&amp;ll=32.650649,-116.139221&amp;spn=2.062781,3.99353&amp;z=8">H1N1 Swine Flu 猪流感疫情分步图</a>」，它会依据实际情況在不同的国家及地区标示各种不同类型的「猪流感」怀疑、确诊、死亡个案。每个泡泡代表一个通报病例，不同颜色代表不同意义。具体如下：</p>
<p>粉红色　　　　　　代表　　怀疑为猪流感<br />
紫色　　　　　　　代表　　确定为猪流感<br />
泡泡上无黑点者　　代表　　即为死亡病例。<br />
黃色　　　　　　　代表　　检验后为H1N1阴性（即已经排除的病例）</p>
<p>点击查看H1N1猪流感Google地图：<br />
1、<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=109496610648025582911.0004686892fbefe515012&amp;ll=14.502511,-104.201202&amp;spn=90,-76.390686&amp;source=embed">2009 Swine Flu (H1N1) Outbreak Map</a><br />
2、<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;t=p&amp;msa=0&amp;msid=106484775090296685271.0004681a37b713f6b5950&amp;ll=32.639375,-110.390625&amp;spn=15.738151,25.488281&amp;source=embed">H1N1 Swine Flu</a></p>
<p>好像韩国已经发现疑似病例了，不知道会不会传到国内，希望不要发展到当年的非典那样，满大街的口罩，草木皆兵。</p>
<p>普及一下科普知识，以下是转自<a href="http://it.sohu.com/20090428/n263670704.shtml">sohu</a>网的关于猪流感、禽流感以及普通流感之间的一些对比</p>
<p><strong>猪流感</strong></p>
<p>传播途径：该病毒非常活跃，可由人传染给猪，猪传染给人，也可在人群间传播。人群间传播主要是以感染者的咳嗽和喷嚏为媒介。</p>
<p>症状：人类感染猪流感的最明显症状是“最初出现类似普通流感症状，但体温突然超过39度，肌肉酸痛感明显增强，伴随有眩晕、头疼、腹泻、呕吐等症状或其中部分症状。</p>
<p>潜伏期：新型猪流感病毒可能在人体潜伏7天后才表现出病症。</p>
<p>死亡率：猪流感的死亡率为6.77%，比一般流感要高，其高致死率的主要原因有两个：一是病毒来势凶猛；二是民众起初对新疾病不重视，以为是普通感冒，很多人自己随便吃些药，错过了发病初72小时的最佳救治期。</p>
<p>易感染人群：猪流感致死的患者年龄绝大多数在20岁至45岁之间，属于青壮年。</p>
<p>防治疫苗：人类已研制出的所有流感疫苗对于猪流感都无效，但人感染猪流感是可防、可控、可治的。</p>
<p><strong>禽流感</strong></p>
<p>传播途径：禽流感病毒迄今只能通过禽传染给人，不能通过人传染给人。</p>
<p>症状：感染后的症状主要表现为高热、咳嗽、流涕、肌痛等，多数伴有严重的肺炎，严重者心、肾等多种脏器衰竭导致死亡。</p>
<p>潜伏期：人禽流感潜伏期一般为1～3天,通常在7天以内。</p>
<p>死亡率：人患禽流感死亡率达60%。</p>
<p>易感染人群：在已发现的感染病例中，13岁以下儿童所占比例较高，病情较重，其属于易感人群。</p>
<p>防治疫苗：各国已在研制预防禽流感的疫苗。</p>
<p><strong>普通流感</strong></p>
<p>传播途径：人际传播，空气飞沫传播为主，流感患者及隐性感染者为主要传染源。发病后1~7天有传染性，病初2~3天传染性最强。</p>
<p>症状：普通人流感与人感染猪流感后的症状相似。</p>
<p>潜伏期：流感的潜伏期为1-4天，平均为2天。</p>
<p>死亡率：普通流感可致死，但死亡率较低。</p>
<p>易感染人群：四类最易感染流感的人群，分别是：老年人，患有肝脏、肾脏、心脏等慢性病的人群，经常接触流感人群的医护人员，儿童。</p>
<p>防治疫苗：已研制出可预防流感的疫苗，接种时间多为每年10-11月中旬，每年接种1次。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>2010-03-29 -- <a href="http://blog.happysa.org/android/where_am_i.html" title="where am I(充分利用google手机的GPS功能)">where am I(充分利用google手机的GPS功能)</a> (2)</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/internet/h1n1_on_google_map.html">Permalink</a> |
<a href="http://blog.happysa.org/internet/h1n1_on_google_map.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/internet/h1n1_on_google_map.html&title=在google map上看猪流感疫情分布图（顺便普及下流感常识）">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/google-map" rel="tag">google map</a>, <a href="http://blog.happysa.org/tag/%e7%8c%aa%e6%b5%81%e6%84%9f" rel="tag">猪流感</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/internet/h1n1_on_google_map.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>永远的支青三代</title>
		<link>http://blog.happysa.org/blog/yong_yuan_de_zhiqingsandai.html</link>
		<comments>http://blog.happysa.org/blog/yong_yuan_de_zhiqingsandai.html#comments</comments>
		<pubDate>Mon, 20 Apr 2009 16:17:35 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[学习]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=106</guid>
		<description><![CDATA[说实话，刚开始参加培训时听宝儿说前一届毕业分开的那天很多人都哭了，我还有点怀疑，短短的一个半月时间，感情真的能那么好吗？现在我相信了。 文笔有限，就把所有美好的回忆都留在心里，还是那句口号： 支青三代，人人可爱； 支青三代，永不言败。 愿支青三代的每一位同学都有美好的前程，认真生活，快乐工作。 相关文章：暂无相关日志 © happysa for Happy SA, 2009. &#124; Permalink &#124; 5 comments &#124; Add to del.icio.us Post tags: 学习 Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p>    <img src="http://happysa.org/blog/wp-content/uploads/2009/04/2009-04-21_175933-150x150.jpg" alt="2009-04-21_175933" title="2009-04-21_175933" width="100" height="100" class="alignright size-thumbnail wp-image-116" /> 说实话，刚开始参加培训时听宝儿说前一届毕业分开的那天很多人都哭了，我还有点怀疑，短短的一个半月时间，感情真的能那么好吗？现在我相信了。<br />
     文笔有限，就把所有美好的回忆都留在心里，还是那句口号：<br />
支青三代，人人可爱；<br />
支青三代，永不言败。<br />
愿支青三代的每一位同学都有美好的前程，认真生活，快乐工作。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>暂无相关日志</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/blog/yong_yuan_de_zhiqingsandai.html">Permalink</a> |
<a href="http://blog.happysa.org/blog/yong_yuan_de_zhiqingsandai.html#comments">5 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/blog/yong_yuan_de_zhiqingsandai.html&title=永远的支青三代">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/%e5%ad%a6%e4%b9%a0" rel="tag">学习</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/blog/yong_yuan_de_zhiqingsandai.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>wordpress下解决godaddy免费空间feed出错的问题</title>
		<link>http://blog.happysa.org/blog/solve_the_feed_problem_of_godaddy.html</link>
		<comments>http://blog.happysa.org/blog/solve_the_feed_problem_of_godaddy.html#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:57:23 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=44</guid>
		<description><![CDATA[问题描述： 在浏览器里打开feed地址，不能像正常的feed订阅那样出来订阅的页面，在firefox下是直接以纯文本形式显示，IE7下显示“已取消到该网页的导航”，而直接通过google reader等倒是能正常订阅。在Feed Validator上检查feed文件的正确性，问题如下： This feed does not validate. line 1, column 1: Blank line before XML declaration [help] line 42, column 1: XML parsing error: :42:1: not well-formed (invalid token) [help] 虽然对于我这blog来说feed订阅这东西短期内基本上是拿来摆设的，不过有这问题心里总是不爽，于是乎网上搜寻解决办法，皇天不负有心人，最后顺利解决问题了，下面就介绍一下我的解决方法（方法非原创，参考了SAM LESHER）。 先说说引起这个问题的原因：godaddy的免费空间（CreatingDrew），因为godaddy会自动加上一段广告代码，所以在feed的XML文件输出时也在文件的最后两行给加上了广告代码，并在最前面加了一个空行，这就是上面检查出的问题，所以只要去了这个空行和广告代码就OK了，步骤大致如下： 1. 根据wordpress输出feed的默认地址下载feed文件到本地，这个文件是包含广告代码的 2. 写脚本，使用sed对文件进行过滤，把开头的空行和广告给删除掉 3. 通过修改后的feed文件输出feed订阅信息 4. 在godaddy管理页面上建一条cron任务，每隔一定时间执行一遍脚本，使更新后的feed地址也是正常的 可以把feed文件下载和过滤都写到一个脚本里，修改feed地址则可以使用插件来完成。 下面是实现脚本： #!/bin/sh BLOGADDRESS=&#34;http://blog.happysa.org&#34; #blog地址，用于下载feed文件 FEEDPATH=/var/www/home/happysa/domains/happysa.org/public_html/feed #下载后的feed文件存放地址，路径根据具体情况修改 FEEDFILE=$FEEDPATH/feed.xml RSSFILE=$FEEDPATH/rss.xml RDFFILE=$FEEDPATH/rdf.xml ATOMFILE=$FEEDPATH/atom.xml COMMENTSFILE=$FEEDPATH/comments.xml [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-94" title="128px-feed-icon_svg" src="http://happysa.org/blog/wp-content/uploads/2009/04/128px-feed-icon_svg.png" alt="128px-feed-icon_svg" width="80" height="80" />问题描述：<br />
在浏览器里打开feed地址，不能像正常的feed订阅那样出来订阅的页面，在firefox下是直接以纯文本形式显示，IE7下显示“已取消到该网页的导航”，而直接通过google reader等倒是能正常订阅。在<a href="http://feedvalidator.org">Feed Validator</a>上检查feed文件的正确性，问题如下：</p>
<blockquote><p>This feed does not validate.<br />
line 1, column 1: Blank line before XML declaration [help]<br />
line 42, column 1: XML parsing error: :42:1: not well-formed (invalid token) [help]</p></blockquote>
<p>虽然对于我这blog来说feed订阅这东西短期内基本上是拿来摆设的，不过有这问题心里总是不爽，于是乎网上搜寻解决办法，皇天不负有心人，最后顺利解决问题了，下面就介绍一下我的解决方法（方法非原创，参考了<a href="http://www.samlesher.com/code/fix-broken-wordpress-rss-in-godaddy-free-hosting-accounts">SAM LESHER</a>）。</p>
<p>先说说引起这个问题的原因：godaddy的免费空间（<a href="http://creatingdrew.com/2008/04/wordpress-feeds-and-godaddy-problem-and-solution/">CreatingDrew</a>），因为godaddy会自动加上一段广告代码，所以在feed的XML文件输出时也在文件的最后两行给加上了广告代码，并在最前面加了一个空行，这就是上面检查出的问题，所以只要去了这个空行和广告代码就OK了，步骤大致如下：</p>
<blockquote><p>1. 根据wordpress输出feed的默认地址下载feed文件到本地，这个文件是包含广告代码的<br />
2. 写脚本，使用sed对文件进行过滤，把开头的空行和广告给删除掉<br />
3. 通过修改后的feed文件输出feed订阅信息<br />
4. 在godaddy管理页面上建一条cron任务，每隔一定时间执行一遍脚本，使更新后的feed地址也是正常的</p></blockquote>
<p>可以把feed文件下载和过滤都写到一个脚本里，修改feed地址则可以使用插件来完成。</p>
<p>下面是实现脚本：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">BLOGADDRESS</span>=<span style="color: #ff0000;">&quot;http://blog.happysa.org&quot;</span> <span style="color: #666666; font-style: italic;">#blog地址，用于下载feed文件</span>
<span style="color: #007800;">FEEDPATH</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>happysa<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>happysa.org<span style="color: #000000; font-weight: bold;">/</span>public_html<span style="color: #000000; font-weight: bold;">/</span>feed <span style="color: #666666; font-style: italic;">#下载后的feed文件存放地址，路径根据具体情况修改</span>
<span style="color: #007800;">FEEDFILE</span>=<span style="color: #007800;">$FEEDPATH</span><span style="color: #000000; font-weight: bold;">/</span>feed.xml
<span style="color: #007800;">RSSFILE</span>=<span style="color: #007800;">$FEEDPATH</span><span style="color: #000000; font-weight: bold;">/</span>rss.xml
<span style="color: #007800;">RDFFILE</span>=<span style="color: #007800;">$FEEDPATH</span><span style="color: #000000; font-weight: bold;">/</span>rdf.xml
<span style="color: #007800;">ATOMFILE</span>=<span style="color: #007800;">$FEEDPATH</span><span style="color: #000000; font-weight: bold;">/</span>atom.xml
<span style="color: #007800;">COMMENTSFILE</span>=<span style="color: #007800;">$FEEDPATH</span><span style="color: #000000; font-weight: bold;">/</span>comments.xml
<span style="color: #666666; font-style: italic;">#GDSTRING1=&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;!</span>-- adsok --<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #ff0000;">&quot;
#GDSTRING2=&quot;</span><span style="color: #000000; font-weight: bold;">&lt;</span>script <span style="color: #007800;">src</span>=<span style="color: #ff0000;">&quot;https://a12.alphagodaddy.com/hosting_ads/gd01.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;&lt;!</span>--mce:<span style="color: #000000;">0</span>--<span style="color: #000000; font-weight: bold;">&gt;&lt;/</span>script<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #ff0000;">&quot;
&nbsp;
if [ -f <span style="color: #007800;">$FEEDFILE</span> ]; #删除老的feed文件
then
    rm -f <span style="color: #007800;">$FEEDFILE</span>
fi
wget -q <span style="color: #007800;">$BLOGADDRESS</span>/feed -O <span style="color: #007800;">$FEEDFILE</span> #下载feed文件
sed -i '/!-- adsok --/d;/alphagodaddy/d;1d' <span style="color: #007800;">$FEEDFILE</span> #过滤广告代码和最前面的空行，过滤条件可根据具体情况作改动
sed -i 's/blog.happysa.org\/feed<span style="color: #000099; font-weight: bold;">\&quot;</span>\( rel=<span style="color: #000099; font-weight: bold;">\&quot;</span>self<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>application\/rss+xml<span style="color: #000099; font-weight: bold;">\&quot;</span> \/&amp;gt;\)/feed.happysa.org\/<span style="color: #000099; font-weight: bold;">\&quot;</span>\1/' <span style="color: #007800;">$FEEDFILE</span> #修改订阅地址
&nbsp;
if [ -f <span style="color: #007800;">$RSSFILE</span> ];
then
    rm -f <span style="color: #007800;">$RSSFILE</span>
fi
wget -q <span style="color: #007800;">$BLOGADDRESS</span>/feed/rss -O <span style="color: #007800;">$RSSFILE</span>
sed -i '/!-- adsok --/d;/alphagodaddy/d;1d' <span style="color: #007800;">$RSSFILE</span>
&nbsp;
if [ -f <span style="color: #007800;">$RDFFILE</span> ];
then
    rm -f <span style="color: #007800;">$kRDFFILE</span>
fi
wget -q <span style="color: #007800;">$BLOGADDRESS</span>/feed/rdf -O <span style="color: #007800;">$RDFFILE</span>
sed -i '/!-- adsok --/d;/alphagodaddy/d;1d' <span style="color: #007800;">$RDFFILE</span>
&nbsp;
if [ -f <span style="color: #007800;">$ATOMFILE</span> ];
then
    rm -f <span style="color: #007800;">$ATOMFILE</span>
fi
wget -q <span style="color: #007800;">$BLOGADDRESS</span>/feed/atom -O <span style="color: #007800;">$ATOMFILE</span>
sed -i '/!-- adsok --/d;/alphagodaddy/d;1d' <span style="color: #007800;">$ATOMFILE</span>
sed -i 's/blog.happysa.org\/feed\/atom<span style="color: #000099; font-weight: bold;">\&quot;</span> \/&amp;gt;/feed.happysa.org\/atom.xml<span style="color: #000099; font-weight: bold;">\&quot;</span> \/&amp;gt;/' <span style="color: #007800;">$ATOMFILE</span>
&nbsp;
if [ -f <span style="color: #007800;">$COMMENTSFILE</span> ];
then
   rm -f <span style="color: #007800;">$COMMENTSFILE</span>
fi
wget -q <span style="color: #007800;">$BLOGADDRESS</span>/comments/feed -O <span style="color: #007800;">$COMMENTSFILE</span>
sed -i '/!-- adsok --/d;/alphagodaddy/d;1d' <span style="color: #007800;">$COMMENTSFILE</span>
sed -i 's/blog.happysa.org\/feed\/comments<span style="color: #000099; font-weight: bold;">\&quot;</span>\( rel=<span style="color: #000099; font-weight: bold;">\&quot;</span>self<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>application\/rss+xml<span style="color: #000099; font-weight: bold;">\&quot;</span> \/&amp;gt;\)/feed.happysa.org\/comments.xml<span style="color: #000099; font-weight: bold;">\&quot;</span>\1/' <span style="color: #007800;">$COMMENTSFILE</span></span></pre></div></div>

<p>以上代码新建一个脚本feed.sh，在空间下放哪都可以，之后在空间根目录下建立feed文件夹，用于存放feed文件。</p>
<p>好像免费空间没有ssh帐号的，有些东西设置就会麻烦一点，首先要打开ftp客户端登陆后在脚本文件上右击修改属性，使之有可执行权限。接着就是利用cron建立一个自动执行计划，让脚本每隔多少时间执行一次，在Hosting Control Center上Content下的Cron manager，如图：</p>
<p><img class="alignnone size-full wp-image-56" title="2009-04-17_213114" src="http://happysa.org/blog/wp-content/uploads/2009/04/2009-04-17_213114.jpg" alt="2009-04-17_213114" width="406" height="302" /></p>
<p>Create Cron Job，主要是Command，时间勾上Run twice an hour，这样可以更新频繁一点，之后保存。</p>
<p><img class="alignnone size-full wp-image-57" title="2009-04-17_213705" src="http://happysa.org/blog/wp-content/uploads/2009/04/2009-04-17_213705.jpg" alt="2009-04-17_213705" width="753" height="315" /></p>
<p>接下来就是设置feed地址了，只要feed正常了，怎么用就很简单了，网上的方法也很多，比如可以使用<a href="http://blog.slaven.net.au/wordpress-plugins/wordpress-feed-locations-plugin/">wp-feedlocations</a>，安装后在里面设置feed地址</p>
<p><img class="alignnone size-full wp-image-58" title="2009-04-17_215302" src="http://happysa.org/blog/wp-content/uploads/2009/04/2009-04-17_215302.jpg" alt="2009-04-17_215302" width="733" height="242" /></p>
<p>上面有个地方用到空间的绝对路径，查看绝对路径可以利用php的system函数，同时如果没到cron的时间而想手动执行脚本也可以利用这个，并且可以用这个来输出信息进行调试，我的方法是空间下新建一个php文件，如foo.php，写入如下代码：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>?php
    <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pwd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sh /var/www/home/happysa/domains/happysa.org/public_html/scripts/feed.sh  --&gt;log 2&amp;gt;&amp;amp;1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>然后在浏览器里访问http://happysa.org/foo.php，就可以看到绝对路径并手动执行脚本了。</p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-7925255475832884";
/* 横幅 */
google_ad_slot = "6774942116";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>2009-05-30 -- <a href="http://blog.happysa.org/tips/easy_index_for_tips.html" title="命令行下简单的检索">命令行下简单的检索</a> (9)</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/blog/solve_the_feed_problem_of_godaddy.html">Permalink</a> |
<a href="http://blog.happysa.org/blog/solve_the_feed_problem_of_godaddy.html#comments">31 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/blog/solve_the_feed_problem_of_godaddy.html&title=wordpress下解决godaddy免费空间feed出错的问题">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/feed" rel="tag">feed</a>, <a href="http://blog.happysa.org/tag/godaddy" rel="tag">godaddy</a>, <a href="http://blog.happysa.org/tag/shell" rel="tag">shell</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/blog/solve_the_feed_problem_of_godaddy.html/feed</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>记在开头</title>
		<link>http://blog.happysa.org/blog/begin.html</link>
		<comments>http://blog.happysa.org/blog/begin.html#comments</comments>
		<pubDate>Mon, 13 Apr 2009 15:39:39 +0000</pubDate>
		<dc:creator>happysa</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[happysa]]></category>

		<guid isPermaLink="false">http://blog.happysa.org/?p=31</guid>
		<description><![CDATA[很早就想自己搞个博客了，一来是好玩，生命在于折腾嘛，另一个原因则是希望能记录下自己学习当中的点点滴滴。 关于happysa.org这个域名，顾名思义，To be a happy SA.  系统管理员的工作经常会比较繁琐而且容易受到外界干扰，保持一个良好的心态、快乐的心情，我认为是很有必要的。 很快就要毕业参加工作了，希望有个好的开始。 相关文章：暂无相关日志 © happysa for Happy SA, 2009. &#124; Permalink &#124; One comment &#124; Add to del.icio.us Post tags: blog, happysa Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-35" title="heckert_gnusmall" src="http://happysa.org/blog/wp-content/uploads/2009/04/heckert_gnusmall.png" alt="heckert_gnusmall" width="145" height="140" />很早就想自己搞个博客了，一来是好玩，生命在于折腾嘛，另一个原因则是希望能记录下自己学习当中的点点滴滴。</p>
<p>关于happysa.org这个域名，顾名思义，To be a happy SA.  系统管理员的工作经常会比较繁琐而且容易受到外界干扰，保持一个良好的心态、快乐的心情，我认为是很有必要的。</p>
<p>很快就要毕业参加工作了，希望有个好的开始。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li>暂无相关日志</li></ul><hr />
<p><small>© happysa for <a href="http://blog.happysa.org">Happy SA</a>, 2009. |
<a href="http://blog.happysa.org/blog/begin.html">Permalink</a> |
<a href="http://blog.happysa.org/blog/begin.html#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.happysa.org/blog/begin.html&title=记在开头">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.happysa.org/tag/blog" rel="tag">blog</a>, <a href="http://blog.happysa.org/tag/happysa" rel="tag">happysa</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.happysa.org/blog/begin.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

