<?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://mcfog.com/feed" rel="self" type="application/rss+xml" /><link>http://mcfog.com</link> <description>某雾自言自语的小小天地</description> <lastBuildDate>Wed, 26 Oct 2011 16:21:30 +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://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>流水账</title><link>http://mcfog.com/p781/%e6%b5%81%e6%b0%b4%e8%b4%a6.fog</link> <comments>http://mcfog.com/p781/%e6%b5%81%e6%b0%b4%e8%b4%a6.fog#comments</comments> <pubDate>Wed, 26 Oct 2011 16:21:30 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[心]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=781</guid> <description><![CDATA[一不小心又是一年多没有写这个分类了，随便翻翻前面，按短的算我入宅都有3年了……这个分类最早从高考前的月经贴开始，而我现在已经在开始头疼能不能正常毕业了……
不知道是不是一边上学一边实习的缘故，总觉得最近的状态没有暑假的时候的好了，工作方面开始出现一些差错和不足了，在公司抽不出时间来看新番了，自信心似乎也没以前那么强了
学校这边还要还挂科的债，而且大四这帮课竟然充满了PJ，实在是没有天理（顺带一提这周一我翘了一个PJ的检查，昨天下午去找了助教演示那个残缺的PJ被鄙视了，今天上午还要再去）
找工作方面，我越来越佩服那些玩海投战术的同志了……我就投了俩，其中支付宝还渺无音讯呢，都觉得焦头烂额了……不过我还是坚持自己的做法，投的少&#038;准，希望这周末的面试能果断拿下一个offer先吧……
PS，我发现这个分类其实可以改名叫黑历史了……
PS2，准备尝试实施GTD了……]]></description> <content:encoded><![CDATA[<p>一不小心又是一年多没有写这个分类了，随便翻翻前面，按短的算我入宅都有3年了……这个分类最早从高考前的月经贴开始，而我现在已经在开始头疼能不能正常毕业了……</p><p>不知道是不是一边上学一边实习的缘故，总觉得最近的状态没有暑假的时候的好了，工作方面开始出现一些差错和不足了，在公司抽不出时间来看新番了，自信心似乎也没以前那么强了</p><p>学校这边还要还挂科的债，而且大四这帮课竟然充满了PJ，实在是没有天理（顺带一提这周一我翘了一个PJ的检查，昨天下午去找了助教演示那个残缺的PJ被鄙视了，今天上午还要再去）</p><p>找工作方面，我越来越佩服那些玩海投战术的同志了……我就投了俩，其中支付宝还渺无音讯呢，都觉得焦头烂额了……不过我还是坚持自己的做法，投的少&#038;准，希望这周末的面试能果断拿下一个offer先吧……</p><p>PS，我发现这个分类其实可以改名叫黑历史了……<br
/> PS2，准备尝试实施GTD了……</p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p781/%e6%b5%81%e6%b0%b4%e8%b4%a6.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>又见拖延症</title><link>http://mcfog.com/p770/%e5%8f%88%e8%a7%81%e6%8b%96%e5%bb%b6%e7%97%87.fog</link> <comments>http://mcfog.com/p770/%e5%8f%88%e8%a7%81%e6%8b%96%e5%bb%b6%e7%97%87.fog#comments</comments> <pubDate>Thu, 16 Jun 2011 16:10:46 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[无类别扯谈]]></category> <category><![CDATA[monolog]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=770</guid> <description><![CDATA[唔……还有5门考试和4篇文章，今天下午还就有一门压根还没还没看的期末，睡觉前还应该交掉一篇文章，我却还在各种拖……
希望这不是第一万五千四百九十八次六月底Orz]]></description> <content:encoded><![CDATA[<p>唔……还有5门考试和4篇文章，今天下午还就有一门压根还没还没看的期末，睡觉前还应该交掉一篇文章，我却还在各种拖……</p><p>希望这不是第一万五千四百九十八次六月底Orz</p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p770/%e5%8f%88%e8%a7%81%e6%8b%96%e5%bb%b6%e7%97%87.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>小黑X220入手，上果照</title><link>http://mcfog.com/p760/%e5%b0%8f%e9%bb%91x220%e5%85%a5%e6%89%8b%ef%bc%8c%e4%b8%8a%e6%9e%9c%e7%85%a7.fog</link> <comments>http://mcfog.com/p760/%e5%b0%8f%e9%bb%91x220%e5%85%a5%e6%89%8b%ef%bc%8c%e4%b8%8a%e6%9e%9c%e7%85%a7.fog#comments</comments> <pubDate>Sun, 05 Jun 2011 09:46:56 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[无类别扯谈]]></category> <category><![CDATA[点滴]]></category> <category><![CDATA[gadget]]></category> <category><![CDATA[真相]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=760</guid> <description><![CDATA[港行，i5-2410M,2G,320G,蓝指六，6.5K送货上门
等去学校了再搞个内存条就行了
<a
href="http://i.imgur.com/CHALOl.jpg" rel="lightbox"><img
rel="lightbox" src="http://i.imgur.com/CHALOl.jpg" alt="" width="420" height="560" /></a> <a
href="http://i.imgur.com/DInLVl.jpg" rel="lightbox"><img
rel="lightbox" src="http://i.imgur.com/DInLVl.jpg" alt="" width="420" height="315" /></a>]]></description> <content:encoded><![CDATA[<p>港行，i5-2410M,2G,320G,蓝指六，6.5K送货上门</p><p>等去学校了再搞个内存条就行了<br
/> <a
href="http://i.imgur.com/CHALOl.jpg" rel="lightbox"><img
rel="lightbox" src="http://i.imgur.com/CHALOl.jpg" alt="" width="420" height="560" /></a><br
/> <a
href="http://i.imgur.com/DInLVl.jpg" rel="lightbox"><img
rel="lightbox" src="http://i.imgur.com/DInLVl.jpg" alt="" width="420" height="315" /></a></p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p760/%e5%b0%8f%e9%bb%91x220%e5%85%a5%e6%89%8b%ef%bc%8c%e4%b8%8a%e6%9e%9c%e7%85%a7.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>申腾讯实习记</title><link>http://mcfog.com/p752/%e7%94%b3%e8%85%be%e8%ae%af%e5%ae%9e%e4%b9%a0%e8%ae%b0.fog</link> <comments>http://mcfog.com/p752/%e7%94%b3%e8%85%be%e8%ae%af%e5%ae%9e%e4%b9%a0%e8%ae%b0.fog#comments</comments> <pubDate>Thu, 19 May 2011 08:45:18 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[无类别扯谈]]></category> <category><![CDATA[点滴]]></category> <category><![CDATA[腾讯]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=752</guid> <description><![CDATA[上周末面完最后一面，据HR说这个礼拜就会有结果，但今天还没收到offer，心情不可避免地有些忐忑
<a
href="http://i.imgur.com/fZPff.jpg" rel="lightbox"><img
src="http://i.imgur.com/fZPff.jpg" alt="" width="420" height="265.285714286" /></a> 面试的风格么，非常急，几次短信基本都是凌晨收到当天的面试通知，据说是因为有外地来面的所以希望迅速搞定，于是HR全力各种加班……
&#160;<h2>笔试</h2> 比起深度和难度更注重广度的一份卷子，难度低下（编程题比大一的程设期末还简单N多），后面分方向的部分我做了2个方向的(PHP和JS)，PHP的题目比较基础，甚至涉及整型变量范围这样的；JS题目比较实际，要求码一段实现某某交互的代码，用jQuery简单写了下<h2>一面</h2> 笔试N千人，其中技术的一千多，一面六百多人，比通知的时间晚了一个小时左右才轮到我
一面主要是技术，也是比起深度更在乎广度的面试，面试官很年轻，气氛很轻松，这里问排序算法的问题没答到最好（堆排）……遗憾……
其他还有关于HTTP，TCP的，关于浏览器、缓存、OS、环境部署等等各个方面的问题，但都问得不深，正中本人下怀
据说有的面试官会给你看你的笔试卷子，我也没看到，有点好奇……<h2>二面</h2> 二面的消息倒是提前了一天发给我(不过还是凌晨)，后来得知二面叫boss面，我的面试官是上海这边的开发总监(?)。嘛，一看就是个boss了，广东口音的美帝海龟，说英文比说中文沟通更有效率（不过好处是感觉紧张的时候可以装作听不懂广东话来缓解一下）
技术方面问题比一面少一些但也难一些，另外还问了一些关于TeamWork，关于Communication之类方面的问题，说实话这类问题都是唱得容易做起来难，我只希望以后我工作的时候真能做到我说的那些就已经很好了(汗)，和一面的共同点就是可以反问问题，不仅能获得关于问题的更详细的描述，也能获得一些提示，也能整理一下自己的思路，另外最后还有个智力题，不需要看任何面经什么的我觉的正常人都看到过的（3个人住旅馆30块老板退5块服务生扣2块下略）
和简历相关的问题也是例行公事，反正简历没有水分，如实即可，另外还问了关于失败经历的问题，这种问题只要回答成『我从那次失败中学到了N多』就行<h2>三面</h2> 三面是HR的面试，比前两次时间上都短，HR不问任何技术问题，主要还是看个人性格、兴趣，还有对腾讯的看法等等之类，虽然去之前有点紧张（碰到一坨研究生和某研究生大牛），但其实是最水的一面了，后来还宣传了一下腾讯内部的员工待遇什么的
&#160;<hr
/> <strong>刚才收到一面面试官owen的消息说我进了他们组，QQ团购，撒花</strong> 嘛，忐忑是不忐忑了，还是等HR的通知到了再去日西吧]]></description> <content:encoded><![CDATA[<p>上周末面完最后一面，据HR说这个礼拜就会有结果，但今天还没收到offer，心情不可避免地有些忐忑<br
/> <a
href="http://i.imgur.com/fZPff.jpg" rel="lightbox"><img
src="http://i.imgur.com/fZPff.jpg" alt="" width="420" height="265.285714286" /></a><br
/> 面试的风格么，非常急，几次短信基本都是凌晨收到当天的面试通知，据说是因为有外地来面的所以希望迅速搞定，于是HR全力各种加班……</p><p>&nbsp;</p><h2>笔试</h2><p>比起深度和难度更注重广度的一份卷子，难度低下（编程题比大一的程设期末还简单N多），后面分方向的部分我做了2个方向的(PHP和JS)，PHP的题目比较基础，甚至涉及整型变量范围这样的；JS题目比较实际，要求码一段实现某某交互的代码，用jQuery简单写了下</p><h2>一面</h2><p>笔试N千人，其中技术的一千多，一面六百多人，比通知的时间晚了一个小时左右才轮到我</p><p>一面主要是技术，也是比起深度更在乎广度的面试，面试官很年轻，气氛很轻松，这里问排序算法的问题没答到最好（堆排）……遗憾……</p><p>其他还有关于HTTP，TCP的，关于浏览器、缓存、OS、环境部署等等各个方面的问题，但都问得不深，正中本人下怀</p><p>据说有的面试官会给你看你的笔试卷子，我也没看到，有点好奇……</p><h2>二面</h2><p>二面的消息倒是提前了一天发给我(不过还是凌晨)，后来得知二面叫boss面，我的面试官是上海这边的开发总监(?)。嘛，一看就是个boss了，广东口音的美帝海龟，说英文比说中文沟通更有效率（不过好处是感觉紧张的时候可以装作听不懂广东话来缓解一下）</p><p>技术方面问题比一面少一些但也难一些，另外还问了一些关于TeamWork，关于Communication之类方面的问题，说实话这类问题都是唱得容易做起来难，我只希望以后我工作的时候真能做到我说的那些就已经很好了(汗)，和一面的共同点就是可以反问问题，不仅能获得关于问题的更详细的描述，也能获得一些提示，也能整理一下自己的思路，另外最后还有个智力题，不需要看任何面经什么的我觉的正常人都看到过的（3个人住旅馆30块老板退5块服务生扣2块下略）</p><p>和简历相关的问题也是例行公事，反正简历没有水分，如实即可，另外还问了关于失败经历的问题，这种问题只要回答成『我从那次失败中学到了N多』就行</p><h2>三面</h2><p>三面是HR的面试，比前两次时间上都短，HR不问任何技术问题，主要还是看个人性格、兴趣，还有对腾讯的看法等等之类，虽然去之前有点紧张（碰到一坨研究生和某研究生大牛），但其实是最水的一面了，后来还宣传了一下腾讯内部的员工待遇什么的</p><p>&nbsp;</p><hr
/> <strong>刚才收到一面面试官owen的消息说我进了他们组，QQ团购，撒花</strong><br
/> 嘛，忐忑是不忐忑了，还是等HR的通知到了再去日西吧</p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p752/%e7%94%b3%e8%85%be%e8%ae%af%e5%ae%9e%e4%b9%a0%e8%ae%b0.fog/feed</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>【神鼠绘】我的“紧张感”曲线</title><link>http://mcfog.com/p746/%e3%80%90%e7%a5%9e%e9%bc%a0%e7%bb%98%e3%80%91%e6%88%91%e7%9a%84%e2%80%9c%e7%b4%a7%e5%bc%a0%e6%84%9f%e2%80%9d%e6%9b%b2%e7%ba%bf.fog</link> <comments>http://mcfog.com/p746/%e3%80%90%e7%a5%9e%e9%bc%a0%e7%bb%98%e3%80%91%e6%88%91%e7%9a%84%e2%80%9c%e7%b4%a7%e5%bc%a0%e6%84%9f%e2%80%9d%e6%9b%b2%e7%ba%bf.fog#comments</comments> <pubDate>Mon, 09 May 2011 13:18:55 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[无类别扯谈]]></category> <category><![CDATA[点滴]]></category> <category><![CDATA[神鼠绘]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=746</guid> <description><![CDATA[嘛，人在面临重要时间节点的时候心理上都难免出现波动，这样的波动因人而异，下面这个可能是比较通常的一种
<a
href="http://ih.mcfog.com/di-14130494610910.png" rel="lightbox"><img
src="http://ih.mcfog.com/di-14130494610910.png" alt="" width="420" height="288.166666667" /></a> 可惜我不是一般人，也不是二班的人，我来自一个神奇的班级，即使在那个神奇的班级里我也算一个神奇的角色了，下面是我自评自己在重要事件来临时的心理紧张程度曲线 <a
href="http://ih.mcfog.com/di-10130494611016.png" rel="lightbox"><img
src="http://ih.mcfog.com/di-10130494611016.png" alt="" width="420" height="288.166666667" /></a><ul><li>1：被以前的同学称为『高中的一个梦想之一就是过一天他这样的日子』的堕落日常</li><li>2：发现竟然要XXX了，我却完全不知道X是个啥，陷入恐慌中约一天至三秒的时间</li><li>3：三秒或一天后发现慌也是没用的，于是听天由命了</li><li>4：事件发生的时候进入一种很神奇的量子态，按照<a
href="http://www.hudong.com/wiki/%E5%AE%87%E5%AE%99%E5%8E%86%E5%8F%B2%E6%B1%82%E5%92%8C" target="_blank">费因曼求和</a>来说应该是表现为紧张感0，按照事件的大小还有一定概率让我陷入Seed的状态</li><li>5：虽然结束后马上就会开始恢复堕落的日常，但还是会有几天玩得没有平时那么尽兴，嘛，但也仅此而已了</li></ul><hr
/> 嘛，其实今天的情况是这样的：我去南极洲找企鹅面试，等面试的过程中无聊开PSP低头闷玩，面试过程中找回了上个礼拜不小心丢掉了的自信心，面试结束后感觉世界比以前要鲜艳一些]]></description> <content:encoded><![CDATA[<p>嘛，人在面临重要时间节点的时候心理上都难免出现波动，这样的波动因人而异，下面这个可能是比较通常的一种<br
/> <a
href="http://ih.mcfog.com/di-14130494610910.png" rel="lightbox"><img
src="http://ih.mcfog.com/di-14130494610910.png" alt="" width="420" height="288.166666667" /></a></p><p>可惜我不是一般人，也不是二班的人，我来自一个神奇的班级，即使在那个神奇的班级里我也算一个神奇的角色了，下面是我自评自己在重要事件来临时的心理紧张程度曲线<br
/> <a
href="http://ih.mcfog.com/di-10130494611016.png" rel="lightbox"><img
src="http://ih.mcfog.com/di-10130494611016.png" alt="" width="420" height="288.166666667" /></a></p><ul><li>1：被以前的同学称为『高中的一个梦想之一就是过一天他这样的日子』的堕落日常</li><li>2：发现竟然要XXX了，我却完全不知道X是个啥，陷入恐慌中约一天至三秒的时间</li><li>3：三秒或一天后发现慌也是没用的，于是听天由命了</li><li>4：事件发生的时候进入一种很神奇的量子态，按照<a
href="http://www.hudong.com/wiki/%E5%AE%87%E5%AE%99%E5%8E%86%E5%8F%B2%E6%B1%82%E5%92%8C" target="_blank">费因曼求和</a>来说应该是表现为紧张感0，按照事件的大小还有一定概率让我陷入Seed的状态</li><li>5：虽然结束后马上就会开始恢复堕落的日常，但还是会有几天玩得没有平时那么尽兴，嘛，但也仅此而已了</li></ul><hr
/><p>嘛，其实今天的情况是这样的：我去南极洲找企鹅面试，等面试的过程中无聊开PSP低头闷玩，面试过程中找回了上个礼拜不小心丢掉了的自信心，面试结束后感觉世界比以前要鲜艳一些</p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p746/%e3%80%90%e7%a5%9e%e9%bc%a0%e7%bb%98%e3%80%91%e6%88%91%e7%9a%84%e2%80%9c%e7%b4%a7%e5%bc%a0%e6%84%9f%e2%80%9d%e6%9b%b2%e7%ba%bf.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>技术文章固然不错</title><link>http://mcfog.com/p740/%e6%8a%80%e6%9c%af%e6%96%87%e7%ab%a0%e5%9b%ba%e7%84%b6%e4%b8%8d%e9%94%99.fog</link> <comments>http://mcfog.com/p740/%e6%8a%80%e6%9c%af%e6%96%87%e7%ab%a0%e5%9b%ba%e7%84%b6%e4%b8%8d%e9%94%99.fog#comments</comments> <pubDate>Mon, 02 May 2011 17:07:55 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[无类别扯谈]]></category> <category><![CDATA[monolog]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=740</guid> <description><![CDATA[但还是扯谈的文章以后看起来会更有感触啊，で，McFog自言自语道
之前翻了一遍以前的扯谈文章心里还是有点淡淡的【哔—】的，以后还是多写写那种文章的罢……
话说GR里竟然有8个订阅者……有点好奇啊]]></description> <content:encoded><![CDATA[<p>但还是扯谈的文章以后看起来会更有感触啊，で，McFog自言自语道</p><p>之前翻了一遍以前的扯谈文章心里还是有点淡淡的【哔—】的，以后还是多写写那种文章的罢……</p><p>话说GR里竟然有8个订阅者……有点好奇啊</p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p740/%e6%8a%80%e6%9c%af%e6%96%87%e7%ab%a0%e5%9b%ba%e7%84%b6%e4%b8%8d%e9%94%99.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>[PY]复杂情况(GAE)下Django的模板搜寻顺序自定义</title><link>http://mcfog.com/p735/py%e5%a4%8d%e6%9d%82%e6%83%85%e5%86%b5gae%e4%b8%8bdjango%e7%9a%84%e6%a8%a1%e6%9d%bf%e6%90%9c%e5%af%bb%e9%a1%ba%e5%ba%8f%e8%87%aa%e5%ae%9a%e4%b9%89.fog</link> <comments>http://mcfog.com/p735/py%e5%a4%8d%e6%9d%82%e6%83%85%e5%86%b5gae%e4%b8%8bdjango%e7%9a%84%e6%a8%a1%e6%9d%bf%e6%90%9c%e5%af%bb%e9%a1%ba%e5%ba%8f%e8%87%aa%e5%ae%9a%e4%b9%89.fog#comments</comments> <pubDate>Sat, 30 Apr 2011 09:40:51 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[WebDev]]></category> <category><![CDATA[django]]></category> <category><![CDATA[gae]]></category> <category><![CDATA[Python]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=735</guid> <description><![CDATA[嘛，作为下定决心学习新技术系列，正式开始折腾Django了，作为<strong>不放到网上跑会死星人</strong>放和<strong>不折腾会死星人</strong>，以及<strong>没钱买VPS穷鳖星人</strong>果断选择了在GAE上搭Django环境来玩，多亏python系和google系的众多Geek，让我有很多已有的open-source的project可以引用（后附清单）
因为引用的东西很多，所以目录管理成了很重要的一个问题，模板目录是一个比较复杂的问题，因为众多app中既有引用的app，可能需要用公用的模板去覆盖（比如openid登录），也有自己的实际项目的app，需要覆盖掉公用的模板，所以我在根目录建立了templates_override和templates_fallback来区分，然后如何设置对应的settings.py就成了问题
翻手册翻文档翻源码，需要自定义一个类来解决这个问题，下面是settings.py的片段<pre lang="python">from django.template.loaders.filesystem import Loader as fsLoader
class settingsLoader(fsLoader):
    def __init__(self, dirs = None):
        self.dirs = dirs
    def load_template_source(self, template_name, template_dirs=None):
        if not template_dirs:
            template_dirs = self.dirs
        return super(settingsLoader, self).load_template_source(template_name, template_dirs)
TEMPLATE_LOADERS = (
    ('settings.settingsLoader', [os.path.join(os.path.dirname(__file__), 'templates_override')]),
    'django.template.loaders.app_directories.load_template_source',
    ('settings.settingsLoader', [os.path.join(os.path.dirname(__file__), 'templates_fallback')]),
)
</pre>目前来看Django还是比较顺手的，就是墙内部署GAE实在蛋疼……尤其是有这么多引用的app，文件数量很大……万幸GAE部署的时候不是一个个文件上传而是打包一炮上传的
&#160;
附录：目前引用的project清单<ul><li><a
href="http://www.allbuttonspressed.com/projects/django-nonrel" target="_blank">Django-nonrel</a> (noSql Django移植版)</li><li><a
href="http://www.allbuttonspressed.com/projects/djangoappengine" target="_blank">djangoappengine</a> (上述移植版的GAE接口)</li><li><a
href="http://www.allbuttonspressed.com/projects/django-mediagenerator" target="_blank">django-mediagenerator</a>(打包CSS/JS用Django app)</li><li><a
href="http://www.google.com/url?sa=t&#38;source=web&#38;cd=1&#38;ved=0CCYQFjAA&#38;url=http%3A%2F%2Fdeveloper.yahoo.com%2Fyui%2Fcompressor%2F&#38;ei=XtC7TZG7A4GcvgP3zfjOBQ&#38;usg=AFQjCNG_vcsyGjWMSfn9XJSRFSxPM-g7NA&#38;sig2=WNbb7h8DVliqKcRcb3hV2A" target="_blank">YUI Compressor</a> (这个不用说了吧……)</li><li><a
href="https://launchpad.net/django-openid-auth" target="_blank">django-openid-auth</a> (将OpenID整合至Django原生的认证)</li><li><a
href="http://openidenabled.com/python-openid/ " target="_blank">python-openid</a> (OpenID的python支持)</li></ul>]]></description> <content:encoded><![CDATA[<p>嘛，作为下定决心学习新技术系列，正式开始折腾Django了，作为<strong>不放到网上跑会死星人</strong>放和<strong>不折腾会死星人</strong>，以及<strong>没钱买VPS穷鳖星人</strong>果断选择了在GAE上搭Django环境来玩，多亏python系和google系的众多Geek，让我有很多已有的open-source的project可以引用（后附清单）</p><p>因为引用的东西很多，所以目录管理成了很重要的一个问题，模板目录是一个比较复杂的问题，因为众多app中既有引用的app，可能需要用公用的模板去覆盖（比如openid登录），也有自己的实际项目的app，需要覆盖掉公用的模板，所以我在根目录建立了templates_override和templates_fallback来区分，然后如何设置对应的settings.py就成了问题</p><p>翻手册翻文档翻源码，需要自定义一个类来解决这个问题，下面是settings.py的片段</p><div
class="wp_codebox_msgheader"><span
class="right"><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p735code1'); return false;">View Code</a> PYTHON</span><div
class="codebox_clear"></div></div><div
class="wp_codebox"><table><tr
id="p7351"><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td
class="code" id="p735code1"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span>.<span style="color: black;">loaders</span>.<span style="color: black;">filesystem</span> <span style="color: #ff7700;font-weight:bold;">import</span> Loader <span style="color: #ff7700;font-weight:bold;">as</span> fsLoader
<span style="color: #ff7700;font-weight:bold;">class</span> settingsLoader<span style="color: black;">&#40;</span>fsLoader<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, dirs = <span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">dirs</span> = dirs
    <span style="color: #ff7700;font-weight:bold;">def</span> load_template_source<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, template_name, template_dirs=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> template_dirs:
            template_dirs = <span style="color: #008000;">self</span>.<span style="color: black;">dirs</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>settingsLoader, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: black;">load_template_source</span><span style="color: black;">&#40;</span>template_name, template_dirs<span style="color: black;">&#41;</span>
TEMPLATE_LOADERS = <span style="color: black;">&#40;</span>
    <span style="color: black;">&#40;</span><span style="color: #483d8b;">'settings.settingsLoader'</span>, <span style="color: black;">&#91;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span>__file__<span style="color: black;">&#41;</span>, <span style="color: #483d8b;">'templates_override'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,
    <span style="color: #483d8b;">'django.template.loaders.app_directories.load_template_source'</span>,
    <span style="color: black;">&#40;</span><span style="color: #483d8b;">'settings.settingsLoader'</span>, <span style="color: black;">&#91;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span>__file__<span style="color: black;">&#41;</span>, <span style="color: #483d8b;">'templates_fallback'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>,
<span style="color: black;">&#41;</span></pre></td></tr></table></div><p>目前来看Django还是比较顺手的，就是墙内部署GAE实在蛋疼……尤其是有这么多引用的app，文件数量很大……万幸GAE部署的时候不是一个个文件上传而是打包一炮上传的<br
/> &nbsp;</p><p>附录：目前引用的project清单</p><ul><li><a
href="http://www.allbuttonspressed.com/projects/django-nonrel" target="_blank">Django-nonrel</a> (noSql Django移植版)</li><li><a
href="http://www.allbuttonspressed.com/projects/djangoappengine" target="_blank">djangoappengine</a> (上述移植版的GAE接口)</li><li><a
href="http://www.allbuttonspressed.com/projects/django-mediagenerator" target="_blank">django-mediagenerator</a>(打包CSS/JS用Django app)</li><li><a
href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CCYQFjAA&amp;url=http%3A%2F%2Fdeveloper.yahoo.com%2Fyui%2Fcompressor%2F&amp;ei=XtC7TZG7A4GcvgP3zfjOBQ&amp;usg=AFQjCNG_vcsyGjWMSfn9XJSRFSxPM-g7NA&amp;sig2=WNbb7h8DVliqKcRcb3hV2A" target="_blank">YUI Compressor</a> (这个不用说了吧……)</li><li><a
href="https://launchpad.net/django-openid-auth" target="_blank">django-openid-auth</a> (将OpenID整合至Django原生的认证)</li><li><a
href="http://openidenabled.com/python-openid/ " target="_blank">python-openid</a> (OpenID的python支持)</li></ul> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p735/py%e5%a4%8d%e6%9d%82%e6%83%85%e5%86%b5gae%e4%b8%8bdjango%e7%9a%84%e6%a8%a1%e6%9d%bf%e6%90%9c%e5%af%bb%e9%a1%ba%e5%ba%8f%e8%87%aa%e5%ae%9a%e4%b9%89.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>[PHP]微博用分割消息代码(避免分割URL等语素</title><link>http://mcfog.com/p731/php%e5%be%ae%e5%8d%9a%e7%94%a8%e5%88%86%e5%89%b2%e6%b6%88%e6%81%af%e4%bb%a3%e7%a0%81%e9%81%bf%e5%85%8d%e5%88%86%e5%89%b2url%e7%ad%89%e8%af%ad%e7%b4%a0.fog</link> <comments>http://mcfog.com/p731/php%e5%be%ae%e5%8d%9a%e7%94%a8%e5%88%86%e5%89%b2%e6%b6%88%e6%81%af%e4%bb%a3%e7%a0%81%e9%81%bf%e5%85%8d%e5%88%86%e5%89%b2url%e7%ad%89%e8%af%ad%e7%b4%a0.fog#comments</comments> <pubDate>Sat, 23 Apr 2011 04:57:27 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[WebDev]]></category> <category><![CDATA[bot]]></category> <category><![CDATA[mblog]]></category> <category><![CDATA[PHP]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=731</guid> <description><![CDATA[给自己的推特机器人用的代码，避免分割URL、@、#，另外会在后面表明消息总条数和当前编号，另外由于多数客户端都是新的在前面，所以逆向输出以方便阅读<pre lang="php">public function tweet($msg) {
	$msg = trim($msg);
	if(($len = mb_strlen($msg))>130) {
		if($len > 1200) gx::throw_('tooooo long msg x_x');
		$nonbreak = '%((?:@[a-zA-Z0-9_\-]+)&#124;(?:#[\S]+)&#124;(?:https?://[\w\s\.]+(?:/\S*)?))%';
		$units = preg_split($nonbreak, $msg,-1, PREG_SPLIT_DELIM_CAPTURE);
		$msgs = array();
		$buffer = '';
		while($u=array_shift($units)) {
			if(mb_strlen($buffer)+mb_strlen($u) > 120) {
				if(preg_match($nonbreak, $u)) {//this unit is non-break!
					$msgs[] = $buffer;
					$buffer = $u;
					continue;
				}
				//break words
				$buffer .= $u;
				while(mb_strlen($buffer)>120) {
					$msgs[] = mb_substr($buffer,0,120);
					$buffer = mb_substr($buffer,120);
				}
			} else {//not too long yet, wait for next unit
				$buffer .= $u;
			}
		}
		$now = $all = count($msgs);
		$objs = array();
		while($m = array_pop($msgs)) {//output in reversed order
			$objs[] = $this->tweet($m."($now/$all)");
			$now--;
		}
		return $objs;
	}
	list($code, $response) = $this->request('1/statuses/update.json', 'POST', array(
	  'status' => $msg
	));
	if ($code == 200) {
	  return json_decode($response);
	} else {
	  gx::throw_(htmlentities($response), $code);
	}
}</pre>]]></description> <content:encoded><![CDATA[<p>给自己的推特机器人用的代码，避免分割URL、@、#，另外会在后面表明消息总条数和当前编号，另外由于多数客户端都是新的在前面，所以逆向输出以方便阅读</p><div
class="wp_codebox_msgheader"><span
class="right"><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p731code2'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
class="wp_codebox"><table><tr
id="p7312"><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
</pre></td><td
class="code" id="p731code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> tweet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$len</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mb_strlen"><span style="color: #990000;">mb_strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">130</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$len</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1200</span><span style="color: #009900;">&#41;</span> gx<span style="color: #339933;">::</span><span style="color: #004000;">throw_</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tooooo long msg x_x'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$nonbreak</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'%((?:@[a-zA-Z0-9_\-]+)|(?:#[\S]+)|(?:https?://[\w\s\.]+(?:/\S*)?))%'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$units</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_split"><span style="color: #990000;">preg_split</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nonbreak</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> PREG_SPLIT_DELIM_CAPTURE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msgs</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$u</span><span style="color: #339933;">=</span><a href="http://www.php.net/array_shift"><span style="color: #990000;">array_shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$units</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mb_strlen"><span style="color: #990000;">mb_strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><a href="http://www.php.net/mb_strlen"><span style="color: #990000;">mb_strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$u</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">120</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nonbreak</span><span style="color: #339933;">,</span> <span style="color: #000088;">$u</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//this unit is non-break!</span>
					<span style="color: #000088;">$msgs</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$u</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #666666; font-style: italic;">//break words</span>
				<span style="color: #000088;">$buffer</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$u</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mb_strlen"><span style="color: #990000;">mb_strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">120</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$msgs</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mb_substr"><span style="color: #990000;">mb_substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">120</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mb_substr"><span style="color: #990000;">mb_substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buffer</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">120</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//not too long yet, wait for next unit</span>
				<span style="color: #000088;">$buffer</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$u</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$now</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$all</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msgs</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$objs</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$m</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_pop"><span style="color: #990000;">array_pop</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msgs</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//output in reversed order</span>
			<span style="color: #000088;">$objs</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tweet</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$m</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;(<span style="color: #006699; font-weight: bold;">$now</span>/<span style="color: #006699; font-weight: bold;">$all</span>)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$now</span><span style="color: #339933;">--;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$objs</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">request</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1/statuses/update.json'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'POST'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
	  <span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$msg</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	  <span style="color: #b1b100;">return</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	  gx<span style="color: #339933;">::</span><span style="color: #004000;">throw_</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/htmlentities"><span style="color: #990000;">htmlentities</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p731/php%e5%be%ae%e5%8d%9a%e7%94%a8%e5%88%86%e5%89%b2%e6%b6%88%e6%81%af%e4%bb%a3%e7%a0%81%e9%81%bf%e5%85%8d%e5%88%86%e5%89%b2url%e7%ad%89%e8%af%ad%e7%b4%a0.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>[PHP]QueryPath中的编码问题</title><link>http://mcfog.com/p728/phpquerypath%e4%b8%ad%e7%9a%84%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98.fog</link> <comments>http://mcfog.com/p728/phpquerypath%e4%b8%ad%e7%9a%84%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98.fog#comments</comments> <pubDate>Fri, 08 Apr 2011 20:50:58 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[WebDev]]></category> <category><![CDATA[技术]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[QueryPath]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=728</guid> <description><![CDATA[其实发现<a
href="http://querypath.org/">QueryPath</a>这个神奇的类库已经是几年前的事情了，QueryPath是一个PHP的DOM操作类库，仿jQuery风格。最近终于有机会来实战一把，却遇到了万恶的编码问题，根据API文档用convert_to_encoding来控制编码却一直失败（源码是UTF-8的），拿起了<a
href="http://coolshell.cn/articles/2058.html">传说中的霰弹枪</a>一顿乱打之后，还是在PHP官网的手册评论里面<a
href="http://www.php.net/manual/en/domdocument.loadhtml.php#74777">找到了答案</a>，嗯，来一段代码或许更清楚一些<pre lang="php">		return htmlqp($html, null,
			array(
				//'convert_from_encoding'=>'UTF-8',
				'convert_to_encoding'=>'HTML-ENTITIES'
			))->find('.tml_item')->text();
</pre>]]></description> <content:encoded><![CDATA[<p>其实发现<a
href="http://querypath.org/">QueryPath</a>这个神奇的类库已经是几年前的事情了，QueryPath是一个PHP的DOM操作类库，仿jQuery风格。最近终于有机会来实战一把，却遇到了万恶的编码问题，根据API文档用convert_to_encoding来控制编码却一直失败（源码是UTF-8的），拿起了<a
href="http://coolshell.cn/articles/2058.html">传说中的霰弹枪</a>一顿乱打之后，还是在PHP官网的手册评论里面<a
href="http://www.php.net/manual/en/domdocument.loadhtml.php#74777">找到了答案</a>，嗯，来一段代码或许更清楚一些</p><div
class="wp_codebox_msgheader"><span
class="right"><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p728code3'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
class="wp_codebox"><table><tr
id="p7283"><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code" id="p728code3"><pre class="php" style="font-family:monospace;">		<span style="color: #b1b100;">return</span> htmlqp<span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
			<a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
				<span style="color: #666666; font-style: italic;">//'convert_from_encoding'=&gt;'UTF-8',</span>
				<span style="color: #0000ff;">'convert_to_encoding'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'HTML-ENTITIES'</span>
			<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.tml_item'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p728/phpquerypath%e4%b8%ad%e7%9a%84%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>本站荣获GFW认证</title><link>http://mcfog.com/p705/%e6%9c%ac%e7%ab%99%e8%8d%a3%e8%8e%b7gfw%e8%ae%a4%e8%af%81.fog</link> <comments>http://mcfog.com/p705/%e6%9c%ac%e7%ab%99%e8%8d%a3%e8%8e%b7gfw%e8%ae%a4%e8%af%81.fog#comments</comments> <pubDate>Thu, 24 Feb 2011 06:35:54 +0000</pubDate> <dc:creator>McFog</dc:creator> <category><![CDATA[无类别扯谈]]></category> <guid
isPermaLink="false">http://mcfog.com/?p=705</guid> <description><![CDATA[2月20号下午2点起，本站正式荣获GFW认证，表现为域名mcfog.com遭DNS污染，今日上午约10点钟开始，购买的独立IP地址也被封，tracert结果停在上海电信骨干路由处
所幸独立IP被封，共享的IP还没有被封，所以只好切换到共享的IP(13刀水漂了)，然后绑hosts上<pre>173囧201囧98囧178 mcfog.com</pre>嘛，不知GFW这轮要疯到什么时候，还是一直这么下去了……可怜我的域名才续费了2年啊，特此问候方校长以及各个相关人士的女性家属一百遍
PS：记录一下不受污染的DNS查阅方法
nslookup -vc yourdomain.com 8.8.8.8
===========================================
后记：
Godaddy说：“GFW不疼你，爹疼你”，于是给了我一个新的独立IP地址173囧201囧98囧195～
好吧，共享一下经验：和我一样Godaddy虚拟主机+SSL证书的童鞋，可以在My Account里点Web Hosting，然后点域名出来的那个小窗里切域名到Share，然后去Rekey一下，然后站会一段时间不能访问，然后你就拥有了一个新的独立IP，但是这个IP只是帮你DNS修改好并且SSL正常可以HTTPS，在控制面板等处却看不见了，要自己保管好……嗯嗯
<a
href="http://i.imgur.com/0ZQ9q.jpg" rel="lightbox"><img
src="http://i.imgur.com/0ZQ9q.jpg" width="420" height="185.821474774" /></a>]]></description> <content:encoded><![CDATA[<p>2月20号下午2点起，本站正式荣获GFW认证，表现为域名mcfog.com遭DNS污染，今日上午约10点钟开始，购买的独立IP地址也被封，tracert结果停在上海电信骨干路由处</p><p>所幸独立IP被封，共享的IP还没有被封，所以只好切换到共享的IP(13刀水漂了)，然后绑hosts上</p><pre>173囧201囧98囧178 mcfog.com</pre><p>嘛，不知GFW这轮要疯到什么时候，还是一直这么下去了……可怜我的域名才续费了2年啊，特此问候方校长以及各个相关人士的女性家属一百遍</p><p>PS：记录一下不受污染的DNS查阅方法<br
/> nslookup -vc yourdomain.com 8.8.8.8</p><p>===========================================<br
/> 后记：<br
/> Godaddy说：“GFW不疼你，爹疼你”，于是给了我一个新的独立IP地址173囧201囧98囧195～<br
/> 好吧，共享一下经验：和我一样Godaddy虚拟主机+SSL证书的童鞋，可以在My Account里点Web Hosting，然后点域名出来的那个小窗里切域名到Share，然后去Rekey一下，然后站会一段时间不能访问，然后你就拥有了一个新的独立IP，但是这个IP只是帮你DNS修改好并且SSL正常可以HTTPS，在控制面板等处却看不见了，要自己保管好……嗯嗯<br
/> <a
href="http://i.imgur.com/0ZQ9q.jpg" rel="lightbox"><img
src="http://i.imgur.com/0ZQ9q.jpg" width="420" height="185.821474774" /></a></p> ]]></content:encoded> <wfw:commentRss>http://mcfog.com/p705/%e6%9c%ac%e7%ab%99%e8%8d%a3%e8%8e%b7gfw%e8%ae%a4%e8%af%81.fog/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Dynamic page generated in 6.792 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-02 04:32:13 -->
<!-- Compression = gzip -->
