<?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>DannyNotes</title>
	<atom:link href="http://dannyli.net/feed" rel="self" type="application/rss+xml" />
	<link>http://dannyli.net</link>
	<description>Danny&#039;s Trivial Thoughts &#38; Notes</description>
	<lastBuildDate>Fri, 30 Dec 2011 11:20:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>如何使用 Endnote 和 LaTeX/BibTeX 建立论文的参考文献</title>
		<link>http://dannyli.net/494/using-endnote-latex-bibtex</link>
		<comments>http://dannyli.net/494/using-endnote-latex-bibtex#comments</comments>
		<pubDate>Mon, 31 Oct 2011 13:26:22 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[研究 Research]]></category>
		<category><![CDATA[Endnote]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=494</guid>
		<description><![CDATA[Endnote X4 是整理论文参考资料的绝佳工具。如果能把 Endnote 与 LaTeX 结合使用是再好不过了。这里介绍一种将 Endnote 内的书目导出为 LaTeX 可用的 BibTeX 格式的方法。 假设 Endnote X4 里已经整理好了一些参考资料的信息。 Endnote 的配置 下载这个文件，然后把它放到 Endnote 安装文件夹下的 styles 子文件夹中； 打开 Endnote X4，从菜单栏里选取 Edit -> Output Styles -> Open Style Manager 找到并勾选第一步中的 BibTeX_Export，关闭该窗口 从菜单栏中 Edit -> Output Styles 选刚增加的 BibTeX_Export 编辑条目：双击需要引用的参考资料，在 Label 一栏里填一个唯一标识符, 如 danny11 在 Endnote 主窗口中选中所有需要引用的参考资料，菜单 File -> Export，Output [...]]]></description>
			<content:encoded><![CDATA[<p>Endnote X4 是整理论文参考资料的绝佳工具。如果能把 Endnote 与 LaTeX 结合使用是再好不过了。这里介绍一种将 Endnote 内的书目导出为 LaTeX 可用的 BibTeX 格式的方法。<br />
假设 Endnote X4 里已经整理好了一些参考资料的信息。</p>
<h3>Endnote 的配置</h3>
<ol>
<li>下载<a class="external" rel="external" href="http://www.rhizobia.co.nz/downloads/BibTeX_Export.ens">这个文件</a>，然后把它放到 Endnote 安装文件夹下的 styles 子文件夹中；</li>
<li>打开 Endnote X4，从菜单栏里选取 <strong>Edit -> Output Styles -> Open Style Manager</strong></li>
<li>找到并勾选第一步中的 BibTeX_Export，关闭该窗口</li>
<li>从菜单栏中 <strong>Edit -> Output Styles</strong> 选刚增加的 BibTeX_Export</li>
<li>编辑条目：双击需要引用的参考资料，在 Label 一栏里填一个唯一标识符, 如 danny11</li>
<li>在 Endnote 主窗口中选中所有需要引用的参考资料，菜单 File -> Export，Output Style 选 BibTeX_Export，保存为一个 txt 文档到 LaTeX 的工作目录中。然后更改文件后缀名为 .bib，如 mybib.bib；</li>
</ol>
<h3>CTeX 中使用 BibTeX</h3>
<p>建立好 .bib 文件后就可以按照常规使用 BibTeX 的方式建立文献参考了。</p>
<ol>
<li>编写 LaTeX 代码；</li>
<li>在结尾前加入 BibTeX 相关代码，如
<div class="codecolorer-container latex mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #800000; font-weight: normal;">\bibliographystyle</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">plain<span style="color: #E02020; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\bibliography</span>{mybib</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% mybib是Endnote导出的文件名</span></div></td></tr></tbody></table></div>
</li>
<li>正文中需要引用的地方就可以加入
<div class="codecolorer-container latex mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #E02020; ">\</span><span style="color: #800000;">cite</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">danny11</span><span style="color: #E02020; ">}</span> <span style="color: #2C922C; font-style: italic;">% danny11 是 之前在 Endnote 中设置的 label</span></div></td></tr></tbody></table></div>
</li>
</ol>
<div class="references">
<h3>References</h3>
<ul>
<li><a class="external" rel="external" href="http://www.rhizobia.co.nz/latex/convert.html">Step-by-step guide to using EndNote with LaTeX and BibTeX</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/494/using-endnote-latex-bibtex/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我所用的 Google Chrome 扩展插件</title>
		<link>http://dannyli.net/487/my-google-chrome-extensions</link>
		<comments>http://dannyli.net/487/my-google-chrome-extensions#comments</comments>
		<pubDate>Sun, 23 Oct 2011 06:15:33 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[软件 Software]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[扩展]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=487</guid>
		<description><![CDATA[全面转向 Google Chrome 后，一个明显的好处就是由于内建的书签同步，高效的搜索等功能可以明显减少插件的数量。下面是我常用的 Chrome 扩展插件 (extensions)。 浏览网页+日常事务 Adblock Plus 屏蔽网页广告。 Delicious Tools 收藏网页链接。 Mail Checker Plus for Google Mail 支持多账户 Gmail 消息提醒的插件。 RSS Subscription Extension 提供 RSS 订阅按钮。 Download Assistant 用来选择默认的下载器。 迅雷、快车、旋风专用链自动破解 破解 thunder/flashget/qqdl 链接，方便下载。 Last.fm Scrobbler 可以记录你在视频网站看 MV 的歌曲信息。 网页开发 Firebug Lite 网页调试，Firefox 上神器的移植版本。 Ultimate Chrome Flag 显示网页信息包括服务器 IP、所在国家、PageRank 等等。 Screen Capture 网页截屏。 [...]]]></description>
			<content:encoded><![CDATA[<p>全面转向 Google Chrome 后，一个明显的好处就是由于内建的书签同步，高效的搜索等功能可以明显减少插件的数量。下面是我常用的 Chrome 扩展插件 (extensions)。</p>
<h3>浏览网页+日常事务</h3>
<ul>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb">Adblock Plus</a></h4>
<p>屏蔽网页广告。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/gclkcflnjahgejhappicbhcpllkpakej">Delicious Tools</a></h4>
<p>收藏网页链接。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/hflijhiplopgohlabbkednoilbnflddk">Mail Checker Plus for Google Mail</a></h4>
<p>支持多账户 Gmail 消息提醒的插件。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/nlbjncdgjeocebhnmkbbbdekmmmcbfjd">RSS Subscription Extension</a></h4>
<p>提供 RSS 订阅按钮。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/mfjkgbjaikamkkojmakjclmkianficch">Download Assistant</a></h4>
<p>用来选择默认的下载器。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/gmpllenfapkfpdkahamlbmbichihpmmg">迅雷、快车、旋风专用链自动破解</a></h4>
<p>破解 thunder/flashget/qqdl 链接，方便下载。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/hhinaapppaileiechjoiifaancjggfjm">Last.fm Scrobbler</a></h4>
<p>可以记录你在视频网站看 MV 的歌曲信息。</li>
</ul>
<h3>网页开发</h3>
<ul>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/bmagokdooijbeehmkpknfglimnifench">Firebug Lite</a></h4>
<p>网页调试，Firefox 上神器的移植版本。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/dbpojpfdiliekbbiplijcphappgcgjfn">Ultimate Chrome Flag</a></h4>
<p>显示网页信息包括服务器 IP、所在国家、PageRank 等等。</li>
<li>
<h4><a class="external" rel="external" href="https://chrome.google.com/webstore/detail/cpngackimfmofbokmjmljamhdncknpmg">Screen Capture</a></h4>
<p>网页截屏。</li>
</ul>
<p>现在缺少的几个插件包括：检测网络媒体文件工具，Twitter 工具，搜索引擎备份同步工具。</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/487/my-google-chrome-extensions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dropbox Hosts 文件修改方法（2011年9月更新）</title>
		<link>http://dannyli.net/430/dropbox-hosts-file-2011</link>
		<comments>http://dannyli.net/430/dropbox-hosts-file-2011#comments</comments>
		<pubDate>Fri, 23 Sep 2011 01:29:46 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[网络 Internet]]></category>
		<category><![CDATA[Dropbox]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=430</guid>
		<description><![CDATA[Dropbox 是个非常好的文件同步工具。可是不知怎么的在国内不能正常使用。解决的方法是修改操作系统的 hosts 文件。 Mac OS X 下 hosts 文件位于 /private/etc/hosts。用类似 TextMate 的文本编辑软件打开这个文件，然后添加以下内容： 123208.43.202.50 www.dropbox.com 174.129.11.212 dl.dropbox.com 184.73.163.57 dl-web.dropbox.com 然后就可以正常使用了。 Windows 下的 hosts 文件位于 C:\Windows\system32\drivers\etc\ References http://shhx2005.gotoip3.com/2011/01/02/dropbox.html http://hjp.jimdo.com/2011/01/02/dropbox/]]></description>
			<content:encoded><![CDATA[<p>Dropbox 是个非常好的文件同步工具。可是不知怎么的在国内不能正常使用。解决的方法是修改操作系统的 hosts 文件。</p>
<p>Mac OS X 下 hosts 文件位于 <tt>/private/etc/hosts</tt>。用类似 TextMate 的文本编辑软件打开这个文件，然后添加以下内容：</p>
<div class="codecolorer-container bash mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">208.43.202.50 www.dropbox.com<br />
174.129.11.212 dl.dropbox.com<br />
184.73.163.57 dl-web.dropbox.com</div></td></tr></tbody></table></div>
<p>然后就可以正常使用了。</p>
<p>Windows 下的 hosts 文件位于 <tt>C:\Windows\system32\drivers\etc\</tt></p>
<div class="references">
<h3>References</h3>
<ul>
<li><a class="external" rel="external" href="http://shhx2005.gotoip3.com/2011/01/02/dropbox.html">http://shhx2005.gotoip3.com/2011/01/02/dropbox.html</a></li>
<li><a class="external" rel="external" href="http://hjp.jimdo.com/2011/01/02/dropbox/">http://hjp.jimdo.com/2011/01/02/dropbox/</a></li>
<ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/430/dropbox-hosts-file-2011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>苹果笔记本电池保养策略</title>
		<link>http://dannyli.net/483/%e5%85%b3%e4%ba%8e%e8%8b%b9%e6%9e%9c%e7%ac%94%e8%ae%b0%e6%9c%ac%e7%94%b5%e6%b1%a0%e4%bf%9d%e5%85%bb</link>
		<comments>http://dannyli.net/483/%e5%85%b3%e4%ba%8e%e8%8b%b9%e6%9e%9c%e7%ac%94%e8%ae%b0%e6%9c%ac%e7%94%b5%e6%b1%a0%e4%bf%9d%e5%85%bb#comments</comments>
		<pubDate>Mon, 19 Sep 2011 09:09:39 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[Lifehack]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[Macbook]]></category>
		<category><![CDATA[电池]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=483</guid>
		<description><![CDATA[只需稍加注意，你就可最大限度地利用你笔记本电脑电池的使用时间(即在电池必须充电前的使用时间)及电池寿命。 我 2008 年的第一台小白，电池不到两年便膨胀起来，后来挤压触摸板，无奈只有拆下电池，一直接外接电源适配器使用。谁都知道要电池保养，但是往往没有坚持，事情一多就懒的注意了。 使用次数：锂电池需要经常使用，锂电池长时间不用会大大减少使用寿命，所以也不要把电池取下来。 定期维护：利用 iCal 每月提醒。 温度要求：最好运行在 10° 到 35° C 之间。最优化温度是 22° C。 节能：关闭不用的硬件，如蓝牙，Airport；取出 DVD；调暗屏幕；关闭不用的程序。 长期不用：充电到 50%，取出电池存放再干燥阴凉的地方。 http://dannyli.net/bookmarks?tag=apple+battery]]></description>
			<content:encoded><![CDATA[<blockquote><p>只需稍加注意，你就可最大限度地利用你笔记本电脑电池的使用时间(即在电池必须充电前的使用时间)及电池寿命。</p></blockquote>
<p>我 2008 年的第一台小白，电池不到两年便膨胀起来，后来挤压触摸板，无奈只有拆下电池，一直接外接电源适配器使用。谁都知道要电池保养，但是往往没有坚持，事情一多就懒的注意了。</p>
<ul>
<li>使用次数：锂电池需要经常使用，锂电池长时间不用会大大减少使用寿命，所以也不要把电池取下来。</li>
<li>定期维护：利用 iCal 每月提醒。</li>
<li>温度要求：最好运行在 10° 到 35° C 之间。最优化温度是 22° C。</li>
<li>节能：关闭不用的硬件，如蓝牙，Airport；取出 DVD；调暗屏幕；关闭不用的程序。</li>
<li>长期不用：充电到 50%，取出电池存放再干燥阴凉的地方。</li>
</ul>
<p><a href="http://dannyli.net/bookmarks?tag=apple+battery">http://dannyli.net/bookmarks?tag=apple+battery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/483/%e5%85%b3%e4%ba%8e%e8%8b%b9%e6%9e%9c%e7%ac%94%e8%ae%b0%e6%9c%ac%e7%94%b5%e6%b1%a0%e4%bf%9d%e5%85%bb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 加入自动判断外部链接功能</title>
		<link>http://dannyli.net/481/wordpress-auto-external-links</link>
		<comments>http://dannyli.net/481/wordpress-auto-external-links#comments</comments>
		<pubDate>Sun, 18 Sep 2011 02:36:07 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[架站 WebDev]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=481</guid>
		<description><![CDATA[关于 target=”_blank” 的争论充斥着互联网，很多人提倡不要使用 target=”_blank” 因为这个不符合 XHTML-strict 和 XHMTL 1.1 的标准。但是我真的不太想让人一点击文章中的外部链接就离开原网站了。解决的方法是使用 rel=”external”。另一个问题是，每次手动加这个标签都比较繁琐，这里介绍一种方法能自动判断文章里的链接是指向站外还是站内，如果是站外则添加一个小箭头指示，并自动加上 rel=”external” 标签，不用手动一个一个去加。 一、添加 da_auto_external_link() 函数 在 functions.php 文件中添加以下内容 12345678function da_auto_external_link&#40;$text&#41; &#123; &#160; &#160; $newtext = str_replace&#40;'&#60;a href=', '&#60;a class=&#34;external&#34; rel=&#34;external&#34; href=', $text&#41;; &#160; &#160; $newtext = str_replace&#40;'&#60;a class=&#34;external&#34; rel=&#34;external&#34; href=&#34;'.home_url&#40;&#41;, '&#60;a href=&#34;'.home_url&#40;&#41;, $newtext&#41;; &#160; &#160; $newtext = str_replace&#40;'&#60;a class=&#34;external&#34; rel=&#34;external&#34; href=&#34;#', '&#60;a href=&#34;#', $newtext&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>关于 target=”_blank” 的争论充斥着互联网，很多人提倡不要使用 target=”_blank” 因为这个不符合 XHTML-strict 和 XHMTL 1.1 的标准。但是我真的不太想让人一点击文章中的外部链接就离开原网站了。解决的方法是使用 rel=”external”。另一个问题是，每次手动加这个标签都比较繁琐，这里介绍一种方法能自动判断文章里的链接是指向站外还是站内，如果是站外则添加一个小箭头指示，并自动加上 rel=”external” 标签，不用手动一个一个去加。</p>
<h3>一、添加 da_auto_external_link() 函数</h3>
<p>在 <tt>functions.php</tt> 文件中添加以下内容</p>
<div class="codecolorer-container php mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> da_auto_external_link<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$newtext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;a href='</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a class=&quot;external&quot; rel=&quot;external&quot; href='</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$newtext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;'</span><span style="color: #339933;">.</span>home_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span>home_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newtext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$newtext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;#'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;a href=&quot;#'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newtext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$newtext</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'da_auto_external_link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//应用于文章区域</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'da_auto_external_link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//应用于评论区域</span></div></td></tr></tbody></table></div>
<p>这个函数先把文章里的所有链接加上 external 的标识，然后再把站内链接的 external 标识给去掉。</p>
<h3>二、添加 rel=”external” 识别</h3>
<p>在模版文件 <tt>header.php</tt> 中的 head 区域内添加以下内容</p>
<div class="codecolorer-container javascript mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> <span style="color: #339933;">&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/* External Links */</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span> externalLinks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> anchors <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>anchors.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> anchor <span style="color: #339933;">=</span> anchors<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>anchor.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchor.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rel&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;external&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchor.<span style="color: #660066;">target</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;_blank&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> externalLinks<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<h3>三、添加小图标及其样式</h3>
<p>在样式表文件 <tt>style.css</tt> 中添加以下内容</p>
<div class="codecolorer-container css mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.external</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">11px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'img/external-link.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>然后上传一个文件名为 external-link.png 小图标到主题目录下的 img 子目录。当然路径和文件名你可以自己改。</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/481/wordpress-auto-external-links/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SimPowerSystems 异步电动机标么值转换问题</title>
		<link>http://dannyli.net/480/simulink-simpowersystems-pu-si-error</link>
		<comments>http://dannyli.net/480/simulink-simpowersystems-pu-si-error#comments</comments>
		<pubDate>Fri, 16 Sep 2011 13:49:06 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[研究 Research]]></category>
		<category><![CDATA[SimPowerSystems]]></category>
		<category><![CDATA[Simulink]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=480</guid>
		<description><![CDATA[Simulink SimPowerSystems 里的异步电机元件分 SI（国际标准）和 pu（标么值）两种。它们之间是等效的，但是转换的方式讲的不是很清楚。参考官方 MATLAB 的文档，可以知道原来这里的基准值取得比较特殊，和大多数的工程参考书籍上的不太一样：基准功率取的单相额定功率，基准电压取的相电压的有效值。但是通过仿真比较我却发现元件的实际构造与文档里的说明不太一样。 已知 SI 单位下的 Pn, Vn, fn 以及 Rs, Lls, Rr, Llr, Lm, J, F, p，正确的基准值取法应该如下： 基准功率：三相功率 Sb = Pn 基准电压：额定相电压的峰值 Vb = Vn/sqrt(3)*sqrt(2) 基准电流：Ib = Pn/Vn 基准阻抗：Zb = Vb/Ib 基准角速度：wb = 2*pi*fn 基准电感：Lb = Zb/wb 基准磁链：phib = vb/wb 基准转矩：Tb = Pn/(wb/p) 基准阻尼系数：Fb = Tb/(wb/p) pu 元件中所使用的参数值只要按照 “标么值=有名值/基准值” 的公式进行计算就可以，比如下面的 [...]]]></description>
			<content:encoded><![CDATA[<p>Simulink SimPowerSystems 里的异步电机元件分 SI（国际标准）和 pu（标么值）两种。它们之间是等效的，但是转换的方式讲的不是很清楚。参考官方 MATLAB 的文档，可以知道原来这里的基准值取得比较特殊，和大多数的工程参考书籍上的不太一样：基准功率取的<strong>单相</strong>额定功率，基准电压取的<strong>相</strong>电压的<strong>有效值</strong>。但是通过仿真比较我却发现元件的实际构造与文档里的说明不太一样。</p>
<p>已知 SI 单位下的 Pn, Vn, fn 以及 Rs, Lls, Rr, Llr, Lm, J, F, p，正确的基准值取法应该如下：</p>
<p>基准功率：<strong>三相</strong>功率 Sb = Pn<br />
基准电压：额定相电压的<strong>峰值</strong>  Vb = Vn/sqrt(3)*sqrt(2)<br />
基准电流：Ib = Pn/Vn<br />
基准阻抗：Zb = Vb/Ib<br />
基准角速度：wb = 2*pi*fn<br />
基准电感：Lb = Zb/wb<br />
基准磁链：phib = vb/wb<br />
基准转矩：Tb = Pn/(wb/p)<br />
基准阻尼系数：Fb = Tb/(wb/p)</p>
<p>pu 元件中所使用的参数值只要按照 “标么值=有名值/基准值” 的公式进行计算就可以，比如下面的 m 文件代码：</p>
<div class="codecolorer-container matlab mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Rs_pu = Rs/Zb &nbsp; &nbsp; &nbsp; <span style="color: #228B22;">% 定子电阻</span><br />
Lls_pu = Lls/Lb &nbsp; &nbsp; <span style="color: #228B22;">% 定子漏电感</span><br />
Rr_pu = Rr/Zb &nbsp; &nbsp; &nbsp; <span style="color: #228B22;">% 转子电阻</span><br />
Llr_pu = Llr/Lb &nbsp; &nbsp; <span style="color: #228B22;">% 转子漏电感</span><br />
Lm_pu = Lm/Lb &nbsp; &nbsp; &nbsp; <span style="color: #228B22;">% 励磁电感</span><br />
H = <span style="color: #33f;">0.5</span>*<span style="color: #0000FF;">J</span>*<span style="color: #080;">&#40;</span>wb/p<span style="color: #080;">&#41;</span>^<span style="color: #33f;">2</span>/Pn &nbsp; <span style="color: #228B22;">% 转动惯量/时间常数</span><br />
F_pu = F/Fb &nbsp; &nbsp; <span style="color: #228B22;">% 阻尼系数</span></div></td></tr></tbody></table></div>
<p>对于 pu 元件，其输入和测量值也是采用的标么值。可以在信号线上加入相应的 gain 环节就可以转换为 SI 信号，比如</p>
<div class="codecolorer-container matlab mac-classic" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="matlab codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #228B22;">% 输入</span><br />
Tm_pu = Tm/Tb<br />
<br />
<span style="color: #228B22;">% 测量值</span><br />
Te = Te_pu*Tb<br />
wm = wm_pu*<span style="color: #080;">&#40;</span>wb/p<span style="color: #080;">&#41;</span><br />
<span style="color: #0000FF;">I</span> = I_pu*Ib<br />
V = V_pu*Vb</div></td></tr></tbody></table></div>
<p>这种标么值的表示方法和 Prabha Kunder 的<a class="external" rel="external" href="http://www.amazon.cn/%E7%94%B5%E5%8A%9B%E7%B3%BB%E7%BB%9F%E7%A8%B3%E5%AE%9A%E4%B8%8E%E6%8E%A7%E5%88%B6-%E6%98%86%E5%BE%B7/dp/B00116L7SG">《电力系统稳定与控制》</a>一书第 199 页中感应电动机模型标么值的表示方法是完全一样的。</p>
<div class="references">
<h3>References</h3>
<ul>
<li><a class="external" rel="external" href="http://www.mathworks.com/help/toolbox/physmod/powersys/ref/f11-6759.html">MATLAB Product Documentation: Per Unit::Technical Conventions (SymPowerSystems)</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/480/simulink-simpowersystems-pu-si-error/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X 下修改文件属性：创建时间、修改时间</title>
		<link>http://dannyli.net/477/change-modified-created-date-in-macosx</link>
		<comments>http://dannyli.net/477/change-modified-created-date-in-macosx#comments</comments>
		<pubDate>Sun, 11 Sep 2011 18:30:32 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[软件 Software]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=477</guid>
		<description><![CDATA[格式 YYYY 四位数年 MM 两位数月 DD 两位数日 hh 两位数小时 mm 两位数分钟 修改文件的“修改时间” 打开 Terminal，首先输入以下内容，不要回车： touch -mt YYYYMMDDhhmm 其中 YYYYMMDDhhmm 要替换成期望的时间，比如 201112310101。 打开 Finder，进入需修改的文件所在的文件夹，把改文件拖到 Terminal 窗口，这时文件的路径自动加到了刚才输入的内容的后面，例如 touch -mt 201112310101 /Volumes/MacHD/Pictures/somefile.jpg 当然你可以自己手动输入文件路径。回车即完成修改。 修改文件的“创建时间” 步骤和上面修改“修改时间”基本相同，只是把参数 -mt 改成 -t，例如 touch -t 201112310101 /Volumes/MacHD/Pictures/somefile.jpg 还有批量修改文件日期的方法可以参考文章链接。]]></description>
			<content:encoded><![CDATA[<h3>格式</h3>
<ul>
<li>YYYY 四位数年</li>
<li>MM 两位数月</li>
<li>DD 两位数日</li>
<li>hh 两位数小时</li>
<li>mm 两位数分钟</li>
</ul>
<h3>修改文件的“修改时间”</h3>
<p>打开 Terminal，首先输入以下内容，不要回车：</p>
<blockquote><p>touch -mt YYYYMMDDhhmm</p></blockquote>
<p>其中 YYYYMMDDhhmm 要替换成期望的时间，比如 201112310101。<br />
打开 Finder，进入需修改的文件所在的文件夹，把改文件拖到 Terminal 窗口，这时文件的路径自动加到了刚才输入的内容的后面，例如</p>
<blockquote><p>touch -mt 201112310101 /Volumes/MacHD/Pictures/somefile.jpg</p></blockquote>
<p>当然你可以自己手动输入文件路径。回车即完成修改。</p>
<h3>修改文件的“创建时间”</h3>
<p>步骤和上面修改“修改时间”基本相同，只是把参数 -mt 改成 -t，例如</p>
<blockquote><p>touch -t 201112310101 /Volumes/MacHD/Pictures/somefile.jpg</p></blockquote>
<p>还有批量修改文件日期的方法可以参考文章链接。</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/477/change-modified-created-date-in-macosx/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aperture 3 显示对焦点功能 bug for Canon EOS 500D</title>
		<link>http://dannyli.net/467/canon-eos500d-bug-of-showing-focal-points-in-aperture</link>
		<comments>http://dannyli.net/467/canon-eos500d-bug-of-showing-focal-points-in-aperture#comments</comments>
		<pubDate>Thu, 08 Sep 2011 13:22:52 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[摄影 Photography]]></category>
		<category><![CDATA[Aperture]]></category>
		<category><![CDATA[Canon EOS 500D]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=467</guid>
		<description><![CDATA[Aperture 中有显示照片对焦点的功能。如下图，在 Inspector 的 Metadata 中，有一个九点对焦样式的按钮，点击便可在图片上显示对焦点信息。 但是有个问题，我看到的照片中的对焦框有好几种类型: 白色细框 白色粗框 红色细框 红色粗框 参看下面两幅照片： 它们到底有什么区别？我搜索了一下，说明书里没有相关的介绍，网上倒是很多人有同样的问题，比如这里。 很不幸的是，有人在 dpreview 反应这个情况很可能是一个 bug&#8230; 因为通常情况下只会出现两种情况：合上焦的点是红色粗框，没合上点的是白色细框。反映这个问题的基本上都是佳能 500D 用户，其他机型用户表示没有遇见这种情况。而且同一次照的一批图片的对焦点显示总有相似的特点，比如某个对焦点总是红色。 这个问题最早去年就出现，但是直到现在也没有发现问题被解决。首先这到底是 500D 的问题还是 Aperture 的问题？如果是 500D 硬件问题是否能通过更新 Firmwire 的方式来解决呢？至少我刚升级了 500D 1.1.1 的 Firmware (2011/07/24)，Aperture 也更新到了最新的支持 Lion 的版本，没有任何改变。 其实也有临时的解决办法，那就是不要看颜色，只看框的粗细，粗的是合焦点，细的是非合焦点。]]></description>
			<content:encoded><![CDATA[<p>Aperture 中有显示照片对焦点的功能。如下图，在 Inspector 的 Metadata 中，有一个九点对焦样式的按钮，点击便可在图片上显示对焦点信息。</p>
<p><img src="http://dannyli.net/beta/wp-content/uploads/2011/09/focal_point1.png" alt="Focal point" title="Focal point" width="319" height="146" class="aligncenter size-full wp-image-469" /></p>
<p>但是有个问题，我看到的照片中的对焦框有好几种类型:</p>
<ol>
<li>白色细框</li>
<li>白色粗框</li>
<li>红色细框</li>
<li>红色粗框</li>
</ol>
<p>参看下面两幅照片：</p>
<p><img src="http://dannyli.net/beta/wp-content/uploads/2011/09/focal_point_eg1.png" alt="" title="focal_point_eg1" width="568" height="377" class="aligncenter size-full wp-image-470" /><br />
<img src="http://dannyli.net/beta/wp-content/uploads/2011/09/focal_point_eg2.png" alt="" title="focal_point_eg2" width="570" height="378" class="aligncenter size-full wp-image-471" /></p>
<p>它们到底有什么区别？我搜索了一下，说明书里没有相关的介绍，网上倒是很多人有同样的问题，比如<a class="external" rel="external" href="http://photo.stackexchange.com/questions/6286/show-focus-points-in-aperture">这里</a>。</p>
<p>很不幸的是，有人在 dpreview 反应这个情况很可能<a class="external" rel="external" href="http://forums.dpreview.com/forums/readflat.asp?forum=1031&#038;message=35694723&#038;changemode=1">是一个 bug&#8230;</a> 因为通常情况下只会出现两种情况：合上焦的点是红色粗框，没合上点的是白色细框。反映这个问题的基本上都是佳能 500D 用户，其他机型用户表示没有遇见这种情况。而且同一次照的一批图片的对焦点显示总有相似的特点，比如某个对焦点总是红色。</p>
<p>这个问题最早去年就出现，但是直到现在也没有发现问题被解决。首先这到底是 500D 的问题还是 Aperture 的问题？如果是 500D 硬件问题是否能通过更新 Firmwire 的方式来解决呢？至少我刚升级了 500D 1.1.1 的 Firmware (2011/07/24)，Aperture 也更新到了最新的支持 Lion 的版本，没有任何改变。</p>
<p>其实也有临时的解决办法，那就是不要看颜色，只看框的粗细，<strong>粗的是合焦点，细的是非合焦点</strong>。</p>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/467/canon-eos500d-bug-of-showing-focal-points-in-aperture/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MATLAB 常用配置</title>
		<link>http://dannyli.net/463/matlab-configurations</link>
		<comments>http://dannyli.net/463/matlab-configurations#comments</comments>
		<pubDate>Tue, 23 Aug 2011 02:30:28 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[研究 Research]]></category>
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=463</guid>
		<description><![CDATA[默认以管理员身份运行 桌面右键 MATLAB 程序图标，在弹出菜单中选择 Properties； 单击 Compatibility 选项卡，最下面 Run this program as an administrator 打勾 点击 OK 按钮确定。 修改默认起始目录 桌面右键 MATLAB 程序图标，在弹出菜单中选择 Properties； 单击 Shortcut 选项卡，在 Start in 里填写指定起始目录路径； 点击 OK 按钮确定。]]></description>
			<content:encoded><![CDATA[<h3>默认以管理员身份运行</h3>
<ol>
<li>桌面右键 MATLAB 程序图标，在弹出菜单中选择 Properties；</li>
<li>单击 Compatibility 选项卡，最下面 Run this program as an administrator 打勾</li>
<li>点击 OK 按钮确定。</li>
</ol>
<h3>修改默认起始目录</h3>
<ol>
<li>桌面右键 MATLAB 程序图标，在弹出菜单中选择 Properties；</li>
<li>单击 Shortcut 选项卡，在 Start in 里填写指定起始目录路径；</li>
<li>点击 OK 按钮确定。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/463/matlab-configurations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X 上开启 Apache 的 URL 静态重写功能</title>
		<link>http://dannyli.net/461/getting-rewrite-mod-working-on-mac-os-x</link>
		<comments>http://dannyli.net/461/getting-rewrite-mod-working-on-mac-os-x#comments</comments>
		<pubDate>Wed, 27 Jul 2011 02:37:31 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[架站 WebDev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://dannyli.net/?p=461</guid>
		<description><![CDATA[URL 重写 (Rewriting) 简单来讲就是将动态网页地址规则化便于人们访问，例如某网页的原始地址是 http://www.abc.com/index.php?year=2011&#038;month=01&#038;day=02，通过重写使得人们看到和访问该页的地址变为 http://www.abc.com/2011/01/02。 重写网页地址的规则是人编写的，这种规则被称为正则表达式 (Regular Expression, RE)。 Mac OS X 下的 Apache HTTP Server 默认并没有配置好 URL 重写功能。下面是开启和配置重写功能的步骤： 打开 Apache 主配置文件 —— 位于 /private/etc/apache2 下的 httpd.conf 文件； 搜寻以下内容并将前面的 # 号去掉： 1#LoadModule rewrite_module libexec/apache2/mod_rewrite.so 打开用户配置文件 —— 位于 /private/etc/apache2/users 下的 [你的用户名].conf 文件，将内容修改成下面的样子（其中的 [你的用户名] 要替换成你自己 Mac OS 的账户名）。 123456&#60;Directory &#34;/Users/[你的用户名]/Sites/&#34;&#62; &#160; &#160; Options Indexes FollowSymLinks &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>URL 重写 (Rewriting) </strong>简单来讲就是将动态网页地址规则化便于人们访问，例如某网页的原始地址是 <tt>http://www.abc.com/index.php?year=2011&#038;month=01&#038;day=02</tt>，通过重写使得人们看到和访问该页的地址变为 <tt>http://www.abc.com/2011/01/02</tt>。<br />
重写网页地址的规则是人编写的，这种规则被称为<strong>正则表达式 (Regular Expression, RE)</strong>。</p>
<p>Mac OS X 下的 Apache HTTP Server 默认并没有配置好 URL 重写功能。下面是开启和配置重写功能的步骤：</p>
<ol>
<li>打开 Apache 主配置文件 —— 位于 <tt>/private/etc/apache2</tt> 下的 <strong>httpd.conf</strong> 文件；</li>
<li>搜寻以下内容并将前面的 # 号去掉：
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">#</span>LoadModule rewrite_module libexec<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>mod_rewrite.so</div></td></tr></tbody></table></div>
</li>
<li>打开用户配置文件 —— 位于 <tt>/private/etc/apache2/users</tt> 下的 <strong>[你的用户名].conf</strong> 文件，将内容修改成下面的样子（其中的 [你的用户名] 要替换成你自己 Mac OS 的账户名）。
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #ff0000;">&quot;/Users/[你的用户名]/Sites/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; Options Indexes FollowSymLinks<br />
&nbsp; &nbsp; AllowOverride All<br />
&nbsp; &nbsp; Order allow,deny<br />
&nbsp; &nbsp; Allow from all<br />
<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>其中的 <strong>AllowOverride</strong> 就是负责开启 URL 静态重写的；</p>
</li>
<li>重启 Apache：在终端里输入以下内容，然后输入密码回车；
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apachectl restart</span></div></td></tr></tbody></table></div>
</li>
<li>这时 .htaccess 文件就生效了，在里面写入相应的重写规则就可以用了。例如，一个常用的 WordPress 重写规则如下
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_rewrite.c<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; RewriteEngine On<br />
&nbsp; &nbsp; RewriteBase <span style="color: #000000; font-weight: bold;">/</span><br />
&nbsp; &nbsp; RewriteRule ^index\.php$ - <span style="color: #7a0874; font-weight: bold;">&#91;</span>L<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>REQUEST_FILENAME<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>-f<br />
&nbsp; &nbsp; RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>REQUEST_FILENAME<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>-d<br />
&nbsp; &nbsp; RewriteRule . <span style="color: #000000; font-weight: bold;">/</span>index.php <span style="color: #7a0874; font-weight: bold;">&#91;</span>L<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
</li>
</ol>
<div class="references">
<h3>References</h3>
<ul>
<li><a class="external" rel="external" href="http://httpd.apache.org/docs/2.2/rewrite/">Apache HTTP Server 官方文档：mod_rewrite</a></li>
<li><a class="external" rel="external" href="http://httpd.apache.org/docs/2.2/mod/core.html#options">Options 指令</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dannyli.net/461/getting-rewrite-mod-working-on-mac-os-x/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

