<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" version="2.0"><channel><atom:link href="http://feed.feedsky.com/january" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/january" type="application/rss+xml"></fs:self_link><lastBuildDate>Tue, 02 Sep 2008 07:09:27 GMT</lastBuildDate><title>Jan'uary</title><description>Jan\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\</description><link>http://jan.ycool.com/</link><pubDate>Tue, 02 Sep 2008 17:09:37 GMT</pubDate><image><title>Jan'uary</title><url>http://sta.yculblog.com/images/logo/general-88x31.gif</url><link>http://jan.ycool.com/</link></image><item><title>So... the fairest chart of Beijing Olympic 2008</title><link>http://item.feedsky.com/~feedsky/january/~5933233/110303282/4061657/1/item.html</link><description>Read the full article &lt;a href=&quot;http://tartarus.org/simon/2008-olympics-hasse/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Seems this chart is another proof of that fairest is useless? It still doesn't tell us anything about the most concerned: China vs US, who did better?&lt;br /&gt;
&lt;br /&gt;
The algorithm is based on only 2 rules:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * We must consider more medals to be better than fewer, other things being equal. If country A has at least as many gold, at least as many silver and at least as many bronze as country B, then we must surely consider it to have done at least as well.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * We must consider the higher medals to be better than the lower. If country C has one more silver than country D but one fewer bronze, we must surely consider it to have done unambiguously better by any sensible ranking, because it has the score country D would have had if one of their bronze medallists had done a little better and won silver instead. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.ycool.com/photo.php?uid=1035631&amp;amp;paid=99614&amp;amp;id=26947143&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://node2.foto.ycstatic.com/200809/02/7/26947143.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;...</description><category>beijing</category><category>2008</category><category>graph</category><category>olympic</category><category>hasse</category><pubDate>Tue, 02 Sep 2008 15:09:27 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3051776.html</guid><fs:srclink>http://jan.ycool.com/post.3051776.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/110303282/4061657</fs:itemid></item><item><title>Fairness</title><link>http://item.feedsky.com/~feedsky/january/~5933233/110303283/4061657/1/item.html</link><description>&amp;quot;Unfortunately, it is possible to prove that one cannot physically construct a fair arbiter that works 100% of the time unless one allows the arbiter an arbitrarily long time to make its decision. The fundamental phenomenon here was originally observed by the fourteenth-century French philosopher Jean Buridan in his commentary on Aristotle's De caelo. Buridan argued that a perfectly rational dog placed between two equally attractive sources of food will starve to death, because it is incapable of deciding which to go to first.&amp;quot;...</description><category>fairness</category><pubDate>Tue, 02 Sep 2008 14:09:48 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3051732.html</guid><fs:srclink>http://jan.ycool.com/post.3051732.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/110303283/4061657</fs:itemid></item><item><title>Add awesome like layout to WMII</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812923/4061657/1/item.html</link><description>&lt;a href=&quot;http://awesome.naquadah.org&quot;&gt;Awesome&lt;/a&gt; is another &lt;a href=&quot;http://en.wikipedia.org/wiki/Tiling_window_manager&quot;&gt;tiling window manager&lt;/a&gt; which has many users on this planet (maybe more than &lt;a href=&quot;http://www.suckless.org/wmii/&quot;&gt;wmii&lt;/a&gt; users?) It's very similar to &lt;a href=&quot;http://xmonad.org&quot;&gt;xmonad&lt;/a&gt;(both use vim-style key-bindings), the main difference between them is awesome's configuration is written in a simple self-defined syntax instead of &lt;a href=&quot;http://haskell.org&quot;&gt;haskell&lt;/a&gt; which used by xmonad.&lt;br /&gt;
&lt;br /&gt;
Simple syntax for configuration means easy to use, but its possibility of customization may be less than wmii and xmonad, that's why I still use wmii now. However, awesome(and xmonad) has an useful concept named 'layout' which wmii lack of. User is always working in a certain layout. Usually layout is composed of a main window who occupies the most area and other windows. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.ycool.com/photo.php?uid=1035631&amp;amp;paid=99614&amp;amp;id=26940270&quot;&gt;&lt;img border=&quot;0&quot; alt=&quot;&quot; src=&quot;http://node0.foto.ycstatic.com/200808/31/e/26940270.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Screenshot is an example of layout: vim is now the main window. Awesome will move the new create window to the right area (the second picture shows the screen after I created a new terminal in wmii with awesome layout support), so you can do some temporary work or tail a log there then come back to main window. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.ycool.com/photo.php?uid=1035631&amp;amp;paid=99614&amp;amp;id=26940362&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://node2.foto.ycstatic.com/200809/01/a/26940362.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;  &lt;br /&gt;
&lt;br /&gt;
In the contrast, wmii always open new window in the same column, make your main workarea smaller, and you have to manually move it to a new column (the last picture shows the screen after I created a new terminal in normal wmii).&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.ycool.com/photo.php?uid=1035631&amp;amp;paid=99614&amp;amp;id=26940363&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://node2.foto.ycstatic.com/200809/01/b/26940363.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
That's why I wrote this piece of code to simulate the behavior of awesome in wmii. I think the code is self-explaination enough. It must be used with &lt;a href=&quot;http://eigenclass.org/hiki.rb?wmii+ruby&quot;&gt;ruby-wmii&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
First create a new file named jan-plugin.rb (or whatever name you like) in $HOME/.wmii-3.5/plugins dir.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Plugin.define &amp;quot;jan&amp;quot;&amp;nbsp; do&lt;br /&gt;
&amp;nbsp; author '&amp;quot;Jan X&amp;quot; &amp;lt;jan.h.xie@gmail.com&amp;gt;'&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; layouts = {:default =&amp;gt; nil,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # keep left column as main area&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; :right_main =&amp;gt; lambda do |wmii, id|&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wmii.write '/tag/sel/ctl', 'send sel right' &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; :left_main =&amp;gt; lambda do |wmii, id|&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns = wmii.read('/tag/sel/index').split(&amp;quot;\n&amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; has_only_one_column = (columns.find_all{|l| l =~ /^#/}.size &amp;lt; 3)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur = columns.find{|l| l =~ /#{id}/}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # the strategy used here:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 1. do nothing to screen terminal&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 2. when there's only one column, create new column at right, move new window to the column&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 3. when there's multi column, if the new window is created in column 1, move it to right column&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 4. else, do nothing&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wmii.write '/tag/sel/ctl', 'send sel right' if cur &amp;amp;&amp;amp; (cur =~ /urxvt:URxvt/) &amp;amp;&amp;amp; !(cur =~ /urxvt:URxvt:screen/) &amp;amp;&amp;amp; (has_only_one_column || (cur[0..0] == '1'))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; bar_applet('layout', 999) do |wmii, bar|&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rules = wmii.plugin_config['jan:layout']['rules'] || {}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tag = wmii.read('/tag/sel/ctl').split(&amp;quot;\n&amp;quot;)[0]&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # bar action&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; switch = lambda do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; wmii.on_key(*([wmii.plugin_config[&amp;quot;jan:layout&amp;quot;][&amp;quot;layout_toggle_keys&amp;quot;] || [&amp;quot;MODKEY-/&amp;quot;]]).flatten, &amp;amp;switch) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; bar.on_click(&amp;amp;switch)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; bar.data = rules[tag] || &amp;quot;Default&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.new do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open(&amp;quot;|wmiir read /event&amp;quot;) do |is|&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case is.gets&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when /CreateClient (.*)/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id = &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tag = wmii.read('/tag/sel/ctl').split(&amp;quot;\n&amp;quot;)[0]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layouts[rules[tag]].call(wmii, id) if rules[tag] &amp;amp;&amp;amp; layouts[rules[tag]]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when /FocusTag (.*)/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bar.data = rules[] || &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp; end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;/blockquote&gt; &lt;br /&gt;
Extend WMII::Configuration in your wmiirc-config.rb:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;class WMII::Configuration&lt;br /&gt;
&amp;nbsp; def colrules(*val)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if val[0].nil?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ixp_conn.read(&amp;quot;/colrules&amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ixp_conn.write &amp;quot;/colrules&amp;quot;, val[0]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp; end&lt;br /&gt;
end&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
Set colrules in wmiirc-config:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;WMII:Configuration.define do&lt;br /&gt;
...&lt;br /&gt;
&amp;nbsp; colrules &amp;lt;&amp;lt;EOF&lt;br /&gt;
/www/ -&amp;gt; 70+30&lt;br /&gt;
/.*/ -&amp;gt; 60+40&lt;br /&gt;
EOF&lt;br /&gt;
...&lt;br /&gt;
end&lt;br /&gt;
&lt;/blockquote&gt; Now the new created column in www tag will has a width equal to 30% of screen width. Finally set applet params and use the new applet:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&amp;nbsp; plugin_config[&amp;quot;jan:layout&amp;quot;][&amp;quot;rules&amp;quot;] = {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;www&amp;quot; =&amp;gt; :left_main&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
&lt;blockquote&gt;&amp;nbsp; from &amp;quot;jan&amp;quot; do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; use_bar_applet &amp;quot;acpi&amp;quot;, 850&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; use_bar_applet &amp;quot;layout&amp;quot;, 950 # here we tell ruby-wmii to use the new defined layout applet&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; use_binding &amp;quot;open-document&amp;quot; # this's another extension I made, I'll post it later when I have time&lt;br /&gt;
&amp;nbsp; end&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
Then you'll have a awesome like layout in wmii!&lt;br /&gt;
&lt;br /&gt;
ps. Notice how cool is ruby's kernel#open method? In the script I pass it a string &amp;quot;|wmiir read /event&amp;quot;, then it will read &amp;quot;wmiir read /event&amp;quot;'s output from pipe! So smart. If we don't add &amp;quot;|&amp;quot; before the string the call will block, because read /event will never get EOF. kernel#open can do more than this, you can even pass a url to it and it will fetch the resource for you by using open-uri lib....</description><category>awesome</category><category>wmii</category><category>layout</category><category>ruby</category><pubDate>Sun, 31 Aug 2008 23:08:26 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3050935.html</guid><fs:srclink>http://jan.ycool.com/post.3050935.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812923/4061657</fs:itemid></item><item><title>For ultimate hacker: glterminal</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812925/4061657/1/item.html</link><description>&lt;a href=&quot;http://ldopa.net/2006/01/14/glterminal/&quot;&gt;&amp;quot;GLTerminal emulates a 1970\u2019s terminal monitor, complete with flaws in brightness, warped display curvature, and flicker. It even simulates baud rate lag. And! for extra verisimilitude, the character colors can be green or amber. &amp;quot;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.ycool.com/photo.php?uid=1035631&amp;amp;paid=99614&amp;amp;id=26920746&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://node1.foto.ycstatic.com/200808/27/a/26920746.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;...</description><category>glterminal</category><pubDate>Wed, 27 Aug 2008 23:08:49 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3048676.html</guid><fs:srclink>http://jan.ycool.com/post.3048676.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812925/4061657</fs:itemid></item><item><title>Ubiquty: a fantastic product from Mozilla lab</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812924/4061657/1/item.html</link><description>Imaging you can use a shell to control your firefox ... Everyone should try it.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_User_Tutorial&quot;&gt;https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_User_Tutorial&lt;/a&gt;...</description><category>firefox</category><category>ubiquity</category><pubDate>Wed, 27 Aug 2008 23:08:24 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3048694.html</guid><fs:srclink>http://jan.ycool.com/post.3048694.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812924/4061657</fs:itemid></item><item><title>zz如何像个男人一样自杀</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812926/4061657/1/item.html</link><description>&lt;a href=&quot;http://www.yeeyan.com/articles/view/imacg4/12969&quot;&gt;http://www.yeeyan.com/articles/view/imacg4/12969&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;&lt;span style=&quot;font-size: large;&quot;&gt;吃一浴缸豆子&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：8，有型指数：4，牛逼指数：8，混乱指数：5&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img width=&quot;550&quot; alt=&quot;&quot; src=&quot;http://www.thebestpageintheuniverse.net/images/tub_fin2.gif&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：浴缸一只，可装满上述浴缸的豆子&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：甩开牙帮子 就行了，你这矮肥的豆丁！一直吃到再也吃不下之后，再吃一些。你会肝肠俱裂，粪发涂墙。本方法最酷的一点是不只打扫起来让人恶心，而且你可能因为豆子（顺 便提一下，要用Van Camp's豆子，或者你喜欢档汗腌豆子味儿的话可以用Bush's豆子）造成的膨胀而装不进棺材，除非进行整形手术。猜猜谁来为手术结账？没错：你的朋 友和家人。开玩笑啦。你又没朋友。&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;&lt;span style=&quot;font-size: large;&quot;&gt;掐死自己&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：9，有型指数：4，牛逼指数：4，混乱指数：0&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img width=&quot;271&quot; height=&quot;261&quot; alt=&quot;&quot; src=&quot;http://www.thebestpageintheuniverse.net/images/strangle5.gif&quot; style=&quot;vertical-align: middle;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：双手。&lt;img width=&quot;150&quot; height=&quot;194&quot; alt=&quot;&quot; src=&quot;http://www.thebestpageintheuniverse.net/images/vincent_strangle2.jpg&quot; style=&quot;border: 0pt none ; margin: 5px 10px; float: right;&quot; /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：掐死自己一 直被认为是不可能的，因为当你身体缺氧时，你会昏迷并恢复正常呼吸。自杀时昏迷纯属武大郎摔断腿矬上加矬。在救护人员发现你倒在自己那摊口水里的蠢相后， 他们会吝啬地把你带回医院，里面的大夫可能失望到派出一人亲自掐死你，这时的尴尬你可都得自己解决。如果他们不愿意掐，给我打个电话；我去掐。连刚去世的 Vincent Price都把自己掐死了。要么就是得肺癌死的，反正我懒得查了。死去吧你。&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;&lt;span style=&quot;font-size: large;&quot;&gt;憋死自己&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：9，有型指数：3，牛逼指数：8，混乱指数：0&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：侠气&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：本方法和掐死自己类似，但是块更硬的骨头。比儿童游乐园的牧师还硬。&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;步骤一：屏住呼吸。&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;步骤二：坚持10分钟，前往步骤三。&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;步骤三：如果你读到了这里，说明你又矬掉了。&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;&lt;span style=&quot;font-size: large;&quot;&gt;刀片&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：5，有型指数：2，牛逼指数：8，混乱指数：7&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img width=&quot;125&quot; height=&quot;125&quot; alt=&quot;&quot; src=&quot;http://www.thebestpageintheuniverse.net/images/razor2.gif&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：刀片，脖子。&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：你已经试图 用刀片割腕自杀后被告知&amp;ldquo;年轻人，你这儿剪指甲哪&amp;rdquo;几次了？然后你听从劝告往胳膊肘上划，跟那些自己正干什么都不知道的小脑残一样。你男朋友踹了你。你活 不下去了，因为你是人类史上被踹第一人、这是连续活过14年的人类个体遭遇的最大痛苦，事到如今只有斩首给你带来最后的慰藉了。记得一直切到颈椎为止。&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;strong&gt;吉百利惊喜&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：9，有型指数：8，牛逼指数：12，混乱指数：8&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img width=&quot;300&quot; height=&quot;249&quot; alt=&quot;&quot; src=&quot;http://www.thebestpageintheuniverse.net/images/cadbury8.jpg&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：冰淇淋勺，吉百利奶油蛋&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：用冰淇淋挖 出眼睛，放上吉百利复活节奶油蛋。然后使用上述任何一种方法，自杀。你的家人可能讨厌自杀，但是大家都爱吉百利奶油蛋！干嘛非用你一成不变的无聊双眼再烦 你的家人，而不是用巧克力给他们带来惊喜呢？！尽量在复活节前后完成。孩子们会为了找到最后两颗糖度过几小时的快乐时光。&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;&lt;span style=&quot;font-size: large;&quot;&gt;死磕人行道&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：10，有型指数：3，牛逼指数：10，混乱指数：4&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：一条人行道。&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt; 步骤一：把头砸向人行道&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt; 步骤二：重复。&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;拿头撞可能是有史以来最&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;的行为了。其不仅有助于自杀，还是和女友分手的不二妙招。例如，我当时找不到语言来告诉我前女友我们的关系结束了，于是有一天一起看电视的时候我一头撞向她前胸。然后我拿起外套就走了。没有尴尬的道别，没有&amp;ldquo;还是朋友&amp;rdquo;的废话。只有一对青紫的奶子和矬掉的恋情。我牛。&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;&lt;strong&gt;&lt;span style=&quot;font-size: large;&quot;&gt;舔妓女的屁股&lt;/span&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E7%94%B7%E4%BA%BA&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;男人&lt;/em&gt;&lt;/a&gt;指数：0，有型指数：1，牛逼指数：1，混乱指数：10&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;所需道具&lt;/strong&gt;&lt;/em&gt;：妓女一名，{post.abstract}.75&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;em&gt;&lt;strong&gt;执行步骤&lt;/strong&gt;&lt;/em&gt;：找个妓女， 让她提供&amp;ldquo;屁股自助&amp;rdquo;。她要是不知道，揍她。她要是知道你在说什么，就不应为舔她屁股收费高于75美分。你甚至可以不花钱办事儿，因为技术上这不是性（除 非你是同性恋，但我不知道跟女的到底算不算）。郑重奉告：不给妓女付钱等于入店行窃。完成该（不端）行为后，你可能想赶紧喝点儿酒。一定要找点儿有松节油 那么带劲的东西，因为你将满嘴恶臭且妓女根据客户需求可能不会正常排便。你嘴里的刺痛感标志着疾病正在发作。现在可以坐好放松，等待阴茎脱落浑身出疹了。 再过几个月，如果别的病没先发作，艾滋就该来了。这自杀多贱啊！只需75美分，你根本不会杀不起自己！&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;就到这里吧。切记：这是你的&lt;a href=&quot;http://www.yeeyan.com/articles/tag/%E8%87%AA%E6%9D%80&quot; target=&quot;_blank&quot; class=&quot;bodytag&quot;&gt;&lt;em&gt;自杀&lt;/em&gt;&lt;/a&gt;，好好享受。&lt;/span&gt;&lt;/p&gt;...</description><category>howto</category><category>selfkilling</category><pubDate>Wed, 27 Aug 2008 09:08:40 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3048143.html</guid><fs:srclink>http://jan.ycool.com/post.3048143.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812926/4061657</fs:itemid></item><item><title>Olympic 2008 Medals</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812927/4061657/1/item.html</link><description>http://www.symworld.com/medals/index.php&lt;br /&gt;
&lt;br /&gt;
其实全世界人民都喜爱精神胜利法。...</description><category>olympic</category><category>medals</category><pubDate>Tue, 26 Aug 2008 11:08:06 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3047420.html</guid><fs:srclink>http://jan.ycool.com/post.3047420.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812927/4061657</fs:itemid></item><item><title>The best background processing lib for Rails</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812928/4061657/1/item.html</link><description>In many case you need to deal with something in the background. In background means you do the things in a process or thread other than the one Rails is running in. One example is file uploading, if you don't do it in background your Rails will be blocked in the entire uploading period and won't be able to process any request. (For file uploading, in-background is not the only solution, &lt;a href=&quot;http://jan.ycool.com/post.3043158.html&quot;&gt;check the more cooler one here&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
There's many libraries to help ppl do things in background such as &lt;a href=&quot;http://backgroundrb.rubyforge.org/&quot;&gt;BackgrounDRB&lt;/a&gt; and &lt;a href=&quot;http://agilewebdevelopment.com/plugins/bj&quot;&gt;BackgroundJob&lt;/a&gt;(BJ). BackgrounDRB has been rewritten and it's stable enough now, but it's VERY complicated for simple task. You need lots of configuration files and daemons to make it run. BackgroundJob is much more simpler, that's why it exists. Here's &lt;a href=&quot;http://jan.ycool.com/post.3026036.html&quot;&gt;a great summary on this two probject&lt;/a&gt; by Ezra, author of merb framework.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, BJ can't work with aged rails, like rails 1.1.6. The main reason is that they all depend on a class named OrderedHash. Rails 1.1.6 implement its own OrderedHash while BJ depends on orderedhash gem. In latest rails the OrderedHash used by rails itself is wrapped in a namespace so there won't be any problem.&lt;br /&gt;
&lt;br /&gt;
So if you want to use BJ in an old rails version like me, try the &lt;a href=&quot;http://bj-on-old-rails.rubyforge.org&quot;&gt;modified BJ&lt;/a&gt;, it contains the source of all depends,&amp;nbsp; including a modified version of orderedhash. Just install as rails plugin like normal BJ library.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;script/install http://bj-on-old-rails.rubyforge.org/svn/&lt;br /&gt;
&lt;/blockquote&gt; &lt;br /&gt;
And if you're patient enough to reach here, aha, you're lucky :). What I want to say is neither BDRB or BJ is the best solution for simple task, &lt;a href=&quot;http://rubyforge.org/projects/spawn/&quot;&gt;Spwan&lt;/a&gt; is. It will just fork()(on UNIX platform) or Thread.new()(on Windows or JRuby) for your background job, zero configuration, no daemon, work perfect and compatible with old rails....</description><category>spawn</category><category>backgroundrb</category><category>backgroundjob</category><category>rails</category><pubDate>Mon, 25 Aug 2008 15:08:28 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3046922.html</guid><fs:srclink>http://jan.ycool.com/post.3046922.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812928/4061657</fs:itemid></item><item><title>wmii + urxvt + screen</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812929/4061657/1/item.html</link><description>&lt;a href=&quot;http://en.wikipedia.org/wiki/Wmii&quot;&gt;WMII&lt;/a&gt; is a tiling window manager that every ruby/rails programmer should try. It can be easily configurated with ruby scripts. WMII has a 'tag' concept, that every X window will be related to a tag, such as 'web', 'database' etc.&lt;br /&gt;
&lt;br /&gt;
I'm a heavy keyboard user who relys on urxvt and screen. Many times when I'm working in&amp;nbsp; a view, like 'web', I want to temporarily do something in console or look on something in my screen session, but the screen window is opened in the other view, like 'database'. I don't want to switch to 'database' view to use screen, it's what we try to avoid by using a tiling window manager.&lt;br /&gt;
&lt;br /&gt;
So I write this piece of code to resolve the problem, it follow these rules:&lt;br /&gt;
&lt;br /&gt;
1. there will always be only one screen window &lt;br /&gt;
2. if no detached screen session, create a new one&lt;br /&gt;
3. if there's a detached screen session, reuse it in urxvt&lt;br /&gt;
4. if the screen window is in another view, bring it to current view&lt;br /&gt;
&lt;br /&gt;
Now I has a more smart urxvt+screen window which I can use in any view with my METAKEY+RETURN.&lt;br /&gt;
&lt;br /&gt;
(the code is based on &lt;a href=&quot;http://eigenclass.org/hiki.rb?wmii+ruby&quot;&gt;ruby-wmii&lt;/a&gt;, you should add it into your wmiirc-config.rb)&lt;br /&gt;
&lt;blockquote&gt;&amp;nbsp; on_key(&amp;quot;MODKEY-Return&amp;quot;) do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; file = `wmiir ls /client`.split(&amp;quot;\n&amp;quot;).map{|x| x[%r{[^/]+}]}.find {|c| read(&amp;quot;/client/#{c}/label&amp;quot;)[0,6] == 'screen'}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if file&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; write &amp;quot;/client/#{file}/tags&amp;quot;, &amp;quot;!&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # replace jan with your username&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd = Dir.glob(&amp;quot;/tmp/screens/S-jan/*&amp;quot;).size &amp;gt; 0 ? &amp;quot;screen -r&amp;quot; : &amp;quot;screen&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system &amp;quot;urxvt -title screen -e #{cmd} &amp;amp;&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp; end &lt;br /&gt;
&lt;/blockquote&gt;...</description><category>urxvt</category><category>screen</category><category>wmii</category><pubDate>Sun, 24 Aug 2008 17:08:19 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3046258.html</guid><fs:srclink>http://jan.ycool.com/post.3046258.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812929/4061657</fs:itemid></item><item><title>Ruby vs Python</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812930/4061657/1/item.html</link><description>Seems most ppl(include me) agreed on that&amp;nbsp; the major diff of ruby and python is on their cultrue. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://news.ycombinator.com/item?id=283639&quot;&gt;http://news.ycombinator.com/item?id=283639&lt;/a&gt;...</description><category>python</category><category>ruby</category><pubDate>Fri, 22 Aug 2008 22:08:24 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3045234.html</guid><fs:srclink>http://jan.ycool.com/post.3045234.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812930/4061657</fs:itemid></item><item><title>Use Merb to handle file upload for Rails</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812931/4061657/1/item.html</link><description>As you know Rails does bad on handling file upload, a large file will block your Rails app a long while, make it busy on receiving the file and can't give response to other visitors, make them upset and leave you alone.&lt;br /&gt;
&lt;br /&gt;
One solution is using merb to handle file upload for rails. The latest Merb that build on Rack(a cool framework who help you dealing with all kinds of http servers) does a really good job on uploading.&lt;br /&gt;
&lt;br /&gt;
First, install merb:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo gem i merb&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
Second, create a merb app in your rails dir:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;merb-gen app uploader&lt;br /&gt;
cd uploader&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
You can ignore all other files except config/rack.rb, this is the only file we need to modify. Currently there's only one line in the file: &lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;run Merb::Rack::Application.new&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
this line will ask merb to handle the http request come from rack. Let us change this:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;require 'cgi'&lt;br /&gt;
&lt;br /&gt;
class File&lt;br /&gt;
&amp;nbsp; def to_s&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; path&lt;br /&gt;
&amp;nbsp; end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# build a new handler to handler rack's request&lt;br /&gt;
&amp;nbsp; class Uploader&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def call(env)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # leverage merb's utility to parse the request. &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Merb will save the file to a tempfile and save the tempfile's path in request's param&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; request = Merb::Request.new(env)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params = request.params&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pass the params directly to the real (rails) app&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = post(&amp;quot;http://someplace.com/api&amp;quot;, hash_to_params(params)).split(&amp;quot;\n&amp;quot;)[-1] &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # processing result or just ignore it ...&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def post(url, params=&amp;quot;&amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curl_cmd = &amp;quot;curl -H \&amp;quot;Content-type: application/x-www-form-urlencoded\&amp;quot; #{url} -d \&amp;quot;#{params}\&amp;quot;&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; puts &amp;quot;curl_cmd = #{curl_cmd}&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = IO.popen(curl_cmd +&amp;quot; 2&amp;gt;&amp;amp;1&amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = f.read&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def hash_to_params(hash)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hash.map do |k, v| &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if v.kind_of? Hash&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h = {}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v.each { |kk, vv| h[&amp;quot;#{k}[#{kk}]&amp;quot;] = vv }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hash_to_params h&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;#{k}=#{CGI.escape v.to_s}&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end.join(&amp;quot;&amp;amp;&amp;quot;) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; end&lt;br /&gt;
&lt;br /&gt;
run Uploader.new&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
At last,&amp;nbsp; run merb up (&amp;quot;merb -p 1234 -c 1 -e production -d&amp;quot;) and config your apache/whatever to redirect all request to /uploader to port 1234(Your merb uploader is listening here!).&lt;br /&gt;
&lt;br /&gt;
Pretty easy, isn't it?...</description><category>merb</category><category>uploader</category><category>rails</category><pubDate>Tue, 19 Aug 2008 15:08:45 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3043158.html</guid><fs:srclink>http://jan.ycool.com/post.3043158.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812931/4061657</fs:itemid></item><item><title>Only 200k windows servers on the earth?</title><link>http://item.feedsky.com/~feedsky/january/~5933233/109812932/4061657/1/item.html</link><description>&lt;a href=&quot;http://www.istartedsomething.com/20080812/microsoft-enviroment-video-reveals-server-numbers-power/&quot;&gt;http://www.istartedsomething.com/20080812/microsoft-enviroment-video-reveals-server-numbers-power/&lt;/a&gt;...</description><category>windows</category><category>server</category><pubDate>Fri, 15 Aug 2008 18:08:59 +0800</pubDate><guid isPermaLink="false">http://jan.ycool.com/post.3041000.html</guid><fs:srclink>http://jan.ycool.com/post.3041000.html</fs:srclink><fs:srcfeed>http://jan.yculblog.com/rss.xml</fs:srcfeed><fs:itemid>feedsky/january/~5933233/109812932/4061657</fs:itemid></item></channel></rss>