<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>知易行难</title>
    <link>http://blog.ashchan.com/</link>
    <webMaster>ashchan@gmail.com James Chen</webMaster>
    <pubDate>2011-12-02T18:24:43+09:00</pubDate>
    <description>Developer in love with Ruby/Rails/Cocoa</description>
    
    <item>
      <title>Shoot yourself in the foot with Bundler and Capistrano</title>
      <link>http://blog.ashchan.com/archive/2011/12/02/shoot-yourself-in-the-foot-with-bundler-and-capistrano/</link>
      <pubDate>2011-12-02 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2011/12/02/shoot-yourself-in-the-foot-with-bundler-and-capistrano</guid>
      <content:encoded><![CDATA[<p>In which I explain why you should not set your system time manually.</p>

<p>I almost ruined my Friday by deploying to our production servers before the office hours ended.</p>

<p>The application is on Rails 3.0.x and we use Bundler and Capistrano - old fashion - to manage dependencies and deployment. Getting something fixed, I hit <code>bundle exec cap production deploy</code> wondering what great foods my wife would be preparing. Then BANG! I got alert telling me the api server (and of course the others) failed to start!</p>

<p>A quick check showed Bundler couldn't locate any installed gems. Going to the current release path I found there was no .bundle folder generated. I guessed Bundler had installed gems into a wrong place so reading the horrible capistrano outputs must help:</p>

<pre><code>executing "cd /var/www/example.com/releases/20111215140542 &amp;&amp; bundle install --gemfile /var/www/example.com/releases/20111215140542/Gemfile --path /var/www/example.com/shared/bundle --deployment --quiet --without development test"
</code></pre>

<p>Do you notice the problem? Bundler had actually installed all gems to the correct directory which was shared/bundle(that's the default behavior of bundler/capistrano). The problem was Bundler had ran install under the wrong directory! Today is Dec 2nd but that directory was like Dec 12th.</p>

<p>Since other symlink and assets complication tasks had ran against the correct release path probably there was something odd with Bundler. Let's check <a href="https://github.com/carlhuda/bundler/blob/master/lib/bundler/deployment.rb">https://github.com/carlhuda/bundler/blob/master/lib/bundler/deployment.rb</a>:</p>

<pre><code>current_release = context.fetch(:current_release)　# ln 44
</code></pre>

<p>Oh yeah if I recalled correctly many capistrano tasks use release_path to do jobs after deploy:finalize_update or deploy:update_code, but Bundler's recipe uses current_release.</p>

<p>It appeared someone had got this issue too, and he's kind enough to make a fix, unfortuately his pull request was rejected:</p>

<p><a href="https://github.com/sunaku/bundler/commit/a4633eec154af0bca9aa4ebdeffbf5d2bde5b3e3">https://github.com/sunaku/bundler/commit/a4633eec154af0bca9aa4ebdeffbf5d2bde5b3e3</a></p>

<p>Maybe we should have a look at what is current_release from capistrano, <a href="https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy.rb">https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy.rb</a>:</p>

<pre><code>_cset(:releases)          { capture("ls -x #{releases_path}", :except =&gt; { :no_release =&gt; true }).split.sort }     #60
_cset(:current_release)   { releases.length &gt; 0 ? File.join(releases_path, releases.last) : nil }
</code></pre>

<p>ls and sort, that gave us the newest directory by name, be it in the past or future.</p>

<p>I had to admit, this was really a user error, as the discussions implied here: <a href="https://github.com/capistrano/capistrano/issues/55">https://github.com/capistrano/capistrano/issues/55</a>.</p>

<p>My fault was I was playing with some local test a while ago, setting my Mac's time to the future. At the same time I deployed our application, which lead to a release path with a timestamp from the parallel universe.</p>

<p>If you use Bundler and Capistrano, don't set your system time manually, ever!</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Learn Ruby on Rails</title>
      <link>http://blog.ashchan.com/archive/2011/08/21/learn-ruby-on-rails/</link>
      <pubDate>2011-08-21 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2011/08/21/learn-ruby-on-rails</guid>
      <content:encoded><![CDATA[<p>I started to learn Ruby on Rails in 2006, when I was still a full time .NET developer. At that time many ASP.NET and C# projects had began to implement features borrowed from <a href="http://www.rubyonrails.org/">Rails</a>, since I had some Ruby experience back in 2003 I asked myself: why not try Rails. So I just dit it and never regret.</p>

<p>As many other developers I believe Rails should be quite easy to learn, especially if you have seen this ruby rails vs java web book stacks picture (you should have if you are a Rails developer from version 1.2 or earlier):</p>

<p><img src="https://lh3.googleusercontent.com/-Qo9x6YYyE6A/TlEgGlWfa9I/AAAAAAAAAfg/O0HB5Cwf0jQ/w500-h412-k/javaversusrubybooks.jpeg" title="learn ruby on rails vs java book stacks" alt="ruby rails vs java book stacks" /></p>

<p><small>image source: <a href="http://www.sleberknight.com/blog/sleberkn/entry/20080318">http://www.sleberknight.com/blog/sleberkn/entry/20080318</a></small></p>

<p>It's great one only needs to read two books to learn an amazing web framework, right? And it's even greater as I had already read <a href="http://amzn.to/programming-ruby">Programming Ruby</a> before!</p>

<p>So I bought <a href="http://amzn.to/agile-web-development-wi-rails">Agile Web Development with Rails</a> and started my journey, along which I learned that you have to master a lot of related technologies to keep yourself not off rails. I also realized I needed to buy TextMate (the author claimed we could get free upgrade to 2.0, maybe after Leopard's release I guessed ATM) and a MacBook Pro to kiss Windows goodbye.</p>

<p>Today, Rails is approaching 3.1 and every rubyist know 3.1 is big and the evolution of Rails during the last couple of years is huge. The learning curve for beginners hasn't changed as the related technologies have updated much just as Rails itself ☃.</p>

<p>Is two books still enough to learn Ruby on Rails now? I bought new editions of Programming Ruby and Agile Web Development with Rails. They are still two of a few books that one should not miss. But I'm pretty sure we have too many books to read - there are more than 25 Ruby books on <a href="http://pragprog.com/">The Pragmatic Bookshelf</a>, I have read most of these books from Pragmatic just because they offer discount from time to time &lt;3.</p>

<p>For those want to learn Rails 3, these three books are also must read in my opinion:</p>

<ul>
<li><a href="http://amzn.to/rails3-way">Rails 3 Way</a> - where there was Rails Way, there is Rails 3 Way.</li>
<li><a href="http://amzn.to/metaprogramming-ruby-pros">Metaprogramming Ruby: Program Like the Ruby Pros</a> - this one is actually on pure Ruby but it shows you many magics the Rails framework uses.</li>
<li><a href="http://amzn.to/nyIAmK">Crafting Rails Applications: Expert Practices for Everyday Rails Development</a> - oh this might a little bit difficult for beginners but the book was so good written in depth.</li>
</ul>


<p>I'm not talking that other books are not good. Many are just outdated if you want something covering Rails 3. I read all the above books I know they let you know Ruby 1.9 and Rails 3 better.</p>

<p>There are tons of free resources to arm you with Rails 3 too. I recommend this free Rails 3 tutorial to everyone: <a href="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book">Ruby on Rails Tutorial: Learn Rails by Example</a> by Michael Hartl. It teaches you step by step how to program in Rails 3. You will learn TDD and you might be able to create another twitter when you follow this awesome Rails 3 tutorial to the end!</p>

<p>And don't forget we have <a href="http://railscasts.com/">RailsCasts</a>, <a href="http://www.rubyflow.com/">RubyFlow</a>, <a href="http://ruby5.envylabs.com/">Ruby5</a>, just to name a few.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Path of Gmail Notifr</title>
      <link>http://blog.ashchan.com/archive/2011/07/27/path-of-gmail-notifr/</link>
      <pubDate>2011-07-27 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2011/07/27/path-of-gmail-notifr</guid>
      <content:encoded><![CDATA[<p>I started <a href="http://ashchan.com/projects/gmail-notifr">Gmail Notifr</a> in <a href="https://github.com/ashchan/gmail-notifr/commit/f8476708cfe584145ae2d84cf4029ad5f16c46ea">Oct 2008</a> to learn RubyCocoa and OS X Cocoa programming. From day one, I myself was an end user. I felt more productive when I was able to receive new gmail notifications at a longer interval - I don't need instance disturbing - that was the most important feature I wanted to build.</p>

<p>After a couple of long nights, I released v0.6.0 (Lion test build) and v0.6.1 (Lion compatible). It has been 11 months since the last release (v0.5.2)! Although no version has ever been released since 0.5.2, I've been refactoring the codebase actively. Not surprisingly, 0.6+ is a toy written in <a href="http://macruby.org/">MacRuby</a>, which needs no introduction.</p>

<p>v0.6.1 doesn't seem to run on Snow Leopard (oops, it's my bad). I have three Macs all having Lion installed. Need to get a Snow Leopard machine to work on the issue(it's Security.framework and BridgeSupport related).</p>

<p>Gmail Notifr has a simple path, it was originally written in RubyCocoa - at that time RubyCocoa seemed to be the best Cocoa framework for rubyists. Now it's totally in MacRuby. I don't plan to write it in Objective-C though, I could write as much Objective-C on iOS development &lt;3</p>

<p>The core of Gmail Notifr is very simple: it checks the gmail atom, then displays the result on menubar and through Growl.</p>

<p>So when it's time to check (either triggered by user, or the configured interval reaches), a background job starts. Along the path, I implemented the background job in three ways:</p>

<ul>
<li>The initial was an NSTask. It ran a subprocess (the actual checker) and monitored the execution.</li>
<li>Then NSOperation. So each checker was queued and executed.</li>
<li>Now Disptach::Queue (Grand Central Dispatch a.k.a GCD). Checkers run concurrently, results pushed to main thread queue. Simple yet works great.</li>
</ul>


<p>I don't think I have to add more features to this toy, but enchancing the codebase and learning new things is so fun I would like to keep it live.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>家人的在留资格通过了</title>
      <link>http://blog.ashchan.com/archive/2010/08/28/family-dependent/</link>
      <pubDate>2010-08-28 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2010/08/28/family-dependent</guid>
      <content:encoded><![CDATA[<p>收到了入管局寄来的老婆孩子的家族滞在在留资格。下周EMS回去，他们就可以去大使馆申请签证了。</p>

<p>我过来已经两个半月了。日语基本上还没入门，不过这边什么都方便，所以日常生活和工作都很顺利。同事朋友帮了无数的忙，今后恐怕还要经常劳烦他们。肉麻感谢的话就不说了，内心是十二分的感激的。</p>

<p>希望我妻子和孩子来这边后能开心平淡的生活。有些寂寞是可以预料也难免的，家里的长辈们肯定也会很挂念。不过，能把孩子暂时带出那片神奇的土地，真的是我做爸爸后最急迫的希望。</p>

<p>人生原本就很简单。努力工作，快乐生活。</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>消息一枚:东渡工作</title>
      <link>http://blog.ashchan.com/archive/2010/06/01/going-to-japan/</link>
      <pubDate>2010-06-01 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2010/06/01/going-to-japan</guid>
      <content:encoded><![CDATA[<p>几年来我一直在做 freelancing ，接的项目基本上都是 Rails 工程。虽然收入会有起伏，工作上也难免会有大大小小的烦恼，但比起窝在办公司里全职上班要舒服很多。我有更多的时间看书，学习感兴趣的东西，结交不同行业的新朋友，参加有意义的社区活动; 最重要的是，有更多的机会看着儿子出生、一天天调皮的长大。</p>

<p>因着 twitter 和 mac 开发，我结识了 <a href="http://twitter.com/xu_lele">乐乐 @xu_lele</a> 和 <a href="http://twitter.com/xuzhe">徐哲 @xuzhe</a>。他们在日本创业，公司 <a href="http://www.rakuraku-inc.com/">Rakuraku Technologies, Inc.</a> 目前主要从事教育行业 iPhone/iPad 软件开发和互联网应用开发。我们非常谈得来，我也慢慢的有了加入他们去日本全职工作的想法。</p>

<p>在乐乐及其夫人 <a href="http://twitter.com/xiaoxiaojing">@xiaoxiaojing</a> 的帮助下，终于在半个月前获得了一年期的技术在留资格并于昨天拿到签证。</p>

<p>今天我开心的告诉大家，我要东渡日本工作了。过去的三个月等在留资格的同时，我辞去了 <a href="http://www.theplant.jp">The Plant</a> 的兼职，交割了手上的客户项目。现在我可以停止 freelance 工作，开始投入新的全职工作中去了。</p>

<p>到了日本后我会停止接受 remote work，但是如果您是我的以往客户（如果是的话那么90%的机率您看不懂这篇中文文章，哈）并有新项目的话，我可以向您推荐其他非常出色的 Ruby/Rails/iPhone 开发者。</p>

<p>最后，我要谢谢很多人。</p>

<p>首先我要感谢国家！！！</p>

<p>谢谢父母的理解。我是一个喜欢待在家里的人，但高中后一直选择漂的生活。</p>

<p>谢谢乐乐和徐哲，我很开心加入你们从事自己喜欢的开发工作。谢谢乐乐夫人不辞辛苦为我办理在留、住房及其他琐事！</p>

<p>谢谢我的妻子和儿子，我要暂时离开你们。我相信为了更美好的明天，暂时告别去往完全陌生的地方从头开始打拼是完全值得的。</p>

<p>谢谢 The Plant 及各位同事。这份兼职工作不仅让我在自由工作的同时更好的养活自己，更重要的是，公司里的这帮家伙，我真的喜欢跟你们共事！</p>

<p>也谢谢我那些劝我别去日本和鼓励我去日本的朋友。</p>

<p>Update: 谢谢 bubu 送我一套日语教材！</p>

<p>最后我要感谢国家！！！</p>

<p>PS. 因相关知识匮乏，恕不接受技术签证、在留资格等相关问题咨询，请见谅。</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>如何轻松慢跑5公里</title>
      <link>http://blog.ashchan.com/archive/2010/04/21/running-the-way/</link>
      <pubDate>2010-04-21 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2010/04/21/running-the-way</guid>
      <content:encoded><![CDATA[<p>近来朋友中开始跑步锻炼的人越来越多了。我从去年秋天开始慢跑，锻炼两个月后（每周三次左右）能够不间断跑5公里，这在之前是自己不敢想象的。学生时代我就非常厌烦跑步，觉得这是一种既枯燥乏味又很辛苦折磨人的锻炼方式。临近30岁（现在已经30出头了，哈），突然发现自己喜欢的其他运动或锻炼方式（滑板，篮球）要么就是凑不到伙伴一起玩，要不就是太受条件限制无法坚持。</p>

<p>稍作“研究”后我发现慢跑是一种比较合适的体育锻炼方式──只要我能克服自己对它的无端厌烦情绪──有氧运动，不容易受伤，受条件限制少（主要是天气，下面会说到），既可以一个人玩也可以几个朋友一起进行、资金投入也不多。</p>

<p>跟其他任何事情一样，一个劲猛的扎进去不一定会失败，但也不大可能成功。我以前其实也尝试跑步过，但都没有坚持。念书的时候，学校离海边只有一公里多远，每天早上有很多漂亮健康的女生跑步去海边。有一阵子我觉得跑步很爽啊，又锻炼身体又能与美女同行。于是我也开始跑，跑了之后养成了一个好习惯：早上要是起得来（我一般睡懒觉），我就跟着她们往海边跑，然后在学校门外的早餐铺里停下来喝豆浆吃油条，吃完了美女们就从海边跑回来了，我再跟跑回学校。</p>

<p>我现在孩子都快能打酱油了，当然不能再做这种荒唐事了。为了保证锻炼效果，查阅了一些资料后，我决定照着一种在国外很流行的慢跑计划来训练，这种方式叫 C25K。</p>

<p>C25K 的全称是 Couch to 5K Plan，可以参考<a href="http://www.c25k.com">这个网站</a>（上面有中文翻译的链接）。Couch 不是教练的意思，而是沙发的意思。相信我，照着这份训练计划，即便你现在连 500 米也跑不动，只要坚持三个月，你也能够轻松地一口气跑 3-5 公里。</p>

<p>我不详细介绍 C25K 计划的训练表，而是谈谈我自己的心得：</p>

<ul>
<li>循序渐进，严格按照计划进行，千万不要觉得自己是超人，一开始就想跑几公里。</li>
<li>做好热身运动（快步走），防止受伤。</li>
<li>每次跑完后再步行走一会，这跟热身一样重要。</li>
<li>可以在跑时听音乐或想事情，以防止心理疲劳，但一定要小心跑道或道路状况。（我前两个月是听 C25K 的 podcast 来进行的，这样可以边吃音乐边接受锻炼提示）</li>
<li>坚持，隔一天跑一次是比较合适的频度。跑得次数少了效果要打折扣。</li>
</ul>


<p>到目前为止，我可以很轻松地跑 5-6 公里，时间为 35-40 分钟，即 pace（跑速）为每公里6分钟左右。我不想刻意去跑得更快，因为那不是我的目标。也不想刻意去增加距离（元旦那天跑了 10 公里庆祝新年），毕竟只是锻炼身体，而且跑到 6 公里以上就会觉得比较无聊。遇到连续天气晴好，我一周能跑 2-4 次。个人感觉天气是影响跑步锻炼的最大因素。春节到现在因为经常下雨，加上琐事较多，跑得并不勤快。希望慢慢能再恢复到隔一天跑一次。</p>

<p>关于装备，最重要的是有一双合适的鞋子。我还在使用 Nike+ 腕表计时，所以穿的是 Nike+ 的跑鞋。很多朋友推荐 Asics 的跑鞋，下次也弄一双穿。</p>

<p>另外，分享和交流也是促使自己坚持的动力。<a href="http://www.dailymile.com">dailymile</a> 是一个很不错的运动社交网站，在上面可以记录你的每一次锻炼情况，并与朋友交流，甚至是参加虚拟比赛。它还支持直接从 Nike+ 同步数据。我希望 dailymile 早点增加对 runkeeper 的支持，这样下次升级 iPhone 后可以使用 runkeeper 来记录了。我的 dailymile profile 是 <a href="http://www.dailymile.com/people/ashchan">http://www.dailymile.com/people/ashchan</a>，欢迎大家加我为好友，一起进步：）</p>

<p>连着下雨天气，已经一周没跑动。今天下午似乎天气会好些，又可以去锻炼一下了。</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>又至一年总结时</title>
      <link>http://blog.ashchan.com/archive/2009/12/27/2010-approaching/</link>
      <pubDate>2009-12-27 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/12/27/2010-approaching</guid>
      <content:encoded><![CDATA[<p>窗外飘着渐大的雪花，2010 马上就到了。年终嘛，似乎总该有些回顾。</p>

<p>又是平平常常的一年，对我说来，也是奔三踏入中年人行列的一年。</p>

<p>儿子满周岁了，长得胖胖的。很淘气，他奶奶天天照看一整天，还要管其他家务活，真的非常辛苦。孩子他妈也没闲着，白天上班，晚上哄儿子，后半夜要起来两趟喂奶或换尿布; 早上儿子起得很早，老婆就跟着起来，打点好一切。两位母亲，你们辛苦了。</p>

<p><a href="http://www.flickr.com/photos/ashchan/4217797850/"><img src="http://farm3.static.flickr.com/2577/4217797850_cefe230ecd.jpg" alt="豆豆、奶奶和妈妈" /></a></p>

<p>年纪一大，明显感觉体能不如以前了。滑板是玩不起来了，篮球也很难凑到足够的朋友一起打。于是乎开始了以前觉得很无聊的运动，跑步。照着 <a href="http://www.c25k.com/">couch to 5k</a> 计划跑了一个多月，居然也能每次跑 5KM 了。一周跑三次左右，每次跑都用 <a href="http://my.nike.com/ashchan">nike plus</a> 记录下来。</p>

<p>还买了辆捷安特山地车，几个好友逢周末天气好又有空便去西湖附近或钱塘江边溜达一圈。可惜现在是冬天了，不大适合骑车。等来年春上了，一定要多出去骑几趟。</p>

<p>工作上还比较顺心。继续 freelance ，接了几个小项目。<a href="http://theplant.jp">ThePlant</a> 来杭州建了个团队，我以兼职的身份加入了。这是个很有活力的 team ，几乎纯技术，由几个 Linux geek ，Vim 控和苹果 fan 组成。目前使用的工具嘛，无非是我们都大爱的 Ruby, Rails, Merb 之类。</p>

<p><a href="http://www.flickr.com/photos/ashchan/4217125391/"><img src="http://farm3.static.flickr.com/2761/4217125391_6a247b82e8.jpg" alt="theplant" /></a></p>

<p>起初每周三次去公司办公室上班，路上开车路程为 25 公里左右，不过由于杭州是东方小堵城，经常要开上一个多小时 (大部分时间是停在那的)。晚上回到家儿子一般都已经睡着了。老板和领导非常体贴，允许我国庆后改为在家工作，自由安排时间。这样，不用再受塞车之苦，原先路上浪费的时间还可以转化为看书和跑步。目前我的工作情况是，70% 远程供职于 ThePlant ，剩余时间偶尔自己接一些小项目做。很满意现状。</p>

<p><a href="http://www.flickr.com/photos/ashchan/3932454519/"><img src="http://farm3.static.flickr.com/2552/3932454519_541133bd53.jpg" alt="在家办公" /></a></p>

<p>每周在家写程序的时间为 60% 左右，剩余的时间在图书馆蹭空调。</p>

<p><a href="http://www.flickr.com/photos/ashchan/4217984298/"><img src="http://farm5.static.flickr.com/4054/4217984298_357148fbab.jpg" alt="萧山图书馆" /></a></p>

<p>这一年参加了数次上海和杭州的 Ruby 活动，认识了很多国内外的 Ruby 开发者。社区越来越壮大，这种现象很好。</p>

<p><a href="http://ashchan.com/projects/gmail-notifr">Gmail Notifr</a> 开发到比较稳定的阶段了，虽然还有些小问题，也有些尚待加入的功能，但基本上不大更新了。iPhone 开发一直停留在学习阶段，没有做出点东西来。倒是认识了一些这个行业中做得很不错的朋友。希望明年有机会可以做点东西吧，但愿。</p>

<p>2010 年的一些小愿望：</p>

<ul>
<li><p>儿子健康成长，少生病。父母和老婆身体健康生活快乐。</p></li>
<li><p>坚持跨步锻炼，目前来看，一年跑 1000KM 这么点距离对我来说尚难完成 (这个月因为感冒就停了十来天，下雨什么的话也不容易出去运动，这么一来要所保证隔一天跑一次还是比较困难的)。</p></li>
<li><p>多看些书，在 <a href="http://tinyurl.com/ya6ujbt">kindle</a> 上读 10 本以上英文小说 (刚购买了 twilight 的前两本)。如果有可能，考个雅思什么的。不过不作强制规划。</p></li>
<li><p>出去旅游几趟，远近皆可。</p></li>
<li><p>带老婆孩子去看看姥姥姥爷。</p></li>
<li><p>工作顺利。保持对 Ruby 的热情，iPhone 和 Cocoa 开发能再深入一些。</p></li>
</ul>

]]></content:encoded>
    </item>
    
    <item>
      <title>图书馆里的自由枪骑兵</title>
      <link>http://blog.ashchan.com/archive/2009/12/01/freelancer-at-library/</link>
      <pubDate>2009-12-01 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/12/01/freelancer-at-library</guid>
      <content:encoded><![CDATA[<p>据说很多搞计算机的自由职业者 (freelancer，如独立程序员、设计师等) 喜欢在咖啡馆里工作。我去年有一段时间也去这种场所，后来感觉不舒服，今年就改成周二至周五下午 ── 图书馆周一休息 ── 在萧山图书馆打发了。</p>

<p>相比咖啡馆，在图书馆“工作”有诸多好处，试举个人体会几例。</p>

<p>图书馆是免费的，不仅借书免费 (办借书证无需押金，所借的书过还书期限也不罚钱)，在阅览室或自习室找个边上带插座的位子用一天的电都没关系。更妙的是，馆外停车也不要钱。</p>

<p>环境好，安静，无人抽烟。夏天和冬天有空调，而且即便开了空调也不会把所有门窗关严。这些对于我这种对噪音和空气不流通超级敏感的人来说真是感觉惬意。</p>

<p>馆里经常有一些年轻漂亮的女孩子，阅览室的几个管理员MM就很可爱。养眼也是调节工作压力的好方式嘛。</p>

<p>如果自己不带水，可以在奶茶吧台买一杯五六块钱的咖啡，以我的水平 ── 在家里冲雀巢的人能什么水平 ── 喝不出跟咖啡馆里动辄 30、40 元的有多大差别。</p>

<p>累了可以找本杂志或图书看，甚至直接趴在桌上睡觉。(念大学时，在自习室里唯一会做的事就是睡觉）</p>

<p>如果说有什么不足之处的话，那就是桌椅对于用笔记本的人来说不算太舒服，久坐会觉得累。另外，听音乐时也不能把脚搁桌上，哈哈。</p>

<p>寒暑假时图书馆就不是适合去的地方了。学生放假，图书馆里每天都人爆满，要找个空位子都不容易，更别说找一张靠近电源插座的桌子了。</p>

<p>PS: 提到咖啡馆，上次 <a href="http://twitter.com/yedingding">@yedingding</a> 带 <a href="http://twitter.com/rakuraku_j">@rakuraku_j</a> 和我去黄龙附近的一家 noname 店，布置的很舒适，顾客不多，算是杭州适合 freelancer 窝点的极佳之处。</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Preview Color Tool in Snow Leopard</title>
      <link>http://blog.ashchan.com/archive/2009/09/20/preview-color-tool-in-snow-leopard/</link>
      <pubDate>2009-09-20 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/09/20/preview-color-tool-in-snow-leopard</guid>
      <content:encoded><![CDATA[<p>I used the Preview Color Tool a lot in Leopard, mainly for picking color from an image. For reason unknown Apple has removed the Color Tool menu from Preview.app in Snow Leopard. Since the Annotations Tool also uses the color we can still show the Colors Pane, here's how:</p>

<ol>
<li>If the Annotations Toolbar is hidden, show it by View → Show Annotations Toolbar (shortcut: command-shift-A).</li>
<li>Click Arrow (or Oval or Rectangle) to toggle on an annotation tool and enable the Color Menu icon.
<div class="thumbnail"><a href="http://skitch.com/ashchan/b96mm/color-tool"><img src="http://img.skitch.com/20090920-fgsa1eyn91kjcpj8sujeee76pf.preview.jpg" alt="color-tool" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div></li>
<li>Click the Color Menu icon to bring the Colors Pane up to front.</li>
<li>Now do whatever you want to in the Colors Pane.</li>
</ol>

]]></content:encoded>
    </item>
    
    <item>
      <title>使用wake on lan远程唤醒</title>
      <link>http://blog.ashchan.com/archive/2009/08/13/wake-on-lan-over-internet/</link>
      <pubDate>2009-08-13 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/08/13/wake-on-lan-over-internet</guid>
      <content:encoded><![CDATA[<p>客厅里的那台htpc，在无下片任务的时候，大部分时间里都在白白浪费电。主板是支持wake on lan的，把它弄成可以远程控制会比较经济。</p>

<p>首先要设置bios，将电源管理下的 Wake On Lan (或叫PME Event Wake Up) 启用。</p>

<p>然后在系统里对网卡进行设置(我的htpc跑的是windows xp sp2，网卡必须是支持Wake On Lan的，原本用的无线PCI网卡不支持，只好使用主板自带的网卡)，首先在"高级"中，将 Wake-On-Lan After Shutdown 的值设为 Enabled，将 Wake-On-Lan Capabilities 的值设为 Magick Packet:</p>

<div class="thumbnail"><a href="http://skitch.com/ashchan/b5fec/nic-advance"><img src="http://img.skitch.com/20090813-dkncuammpryh3tt14rr5qi26eq.preview.jpg" alt="nic-advance" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>然后在"电源管理"中，将"允许这台设备使计算机脱离待机状态。"选中（需要先将最上面那个选项选中才能选这个）。不过在测试中发现这个选项似乎不影响最终结果:</p>

<div class="thumbnail"><a href="http://skitch.com/ashchan/b5fex/nic-power"><img src="http://img.skitch.com/20090813-x72j64uj16j118np4kn522ufk4.preview.jpg" alt="nic-power" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>通过以上设置，这台PC已经可以在局域网内被唤醒了。接下去设置路由器。</p>

<p>首先需要使用动态域名，否则在外边游荡里不知道家里的宽带连接正在使用的IP。这一步不作说明。</p>

<p>我用的路由器是TP-LINK TL-WR340G，先加一个 Port Forward，将 UDP 端口7或9转发至198.168.1.254。这里假设子网是192.168.1.0。因为要唤醒的PC是待机状态的，使用它的IP是无效的，所以这里并不是将端口转发至目标PC的IP。如果路由器支持转发至整个子网，则这里填192.168.1.255便可。我这款路由器不支持，所以只好使用一个并不存在的192.168.1.254:</p>

<div class="thumbnail"><a href="http://skitch.com/ashchan/b5fjr/port-forward"><img src="http://img.skitch.com/20090813-acubdi4pj6ndwg6g2pwhkkkcf.preview.jpg" alt="port-forward" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>关键的一步到了，为了将 Wake On Lan 的包 (Magick Packet) 转发至整个子网从而到达目标PC，上面的设置将端口9转发至了192.168.1.254，那么如何让发往192.168.1.254的包到达目标PC呢？答案是臭名昭著的ARP。</p>

<p>在 IP &amp; Binding 中增加一条 ARP 记录，Mac地址填写要唤醒的目标PC的网卡Mac地址，IP地址填入192.168.1.254。</p>

<div class="thumbnail"><a href="http://skitch.com/ashchan/b5fj2/mac-arp"><img src="http://img.skitch.com/20090813-qbcaj5tkqg1u83awbj4ty897rk.preview.jpg" alt="mac-arp" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>通过以上设置，已经可以在任何地方唤醒我的HTPC了。当然还需要一个发送 Wake On Lane Magick Packet 包的工具，我用的是 <a href="http://www.readpixel.com/wakeonlan/">WakeOnLan</a>，添加一个新的host，IP/DNS填入路由器的动态域名，Mac址址填入目标PC的网卡Mac地址。</p>

<div class="thumbnail"><a href="http://skitch.com/ashchan/b5fks/wakeonlan-client"><img src="http://img.skitch.com/20090813-k5s5xuh2c6wkjsumdsn6sawqj8.preview.jpg" alt="wakeonlan-client" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>在HTPC上，设置电源管理让它在空闲15分钟时自动待机。修改电驴的设置，让电驴运行时禁用自动待机。</p>

<p>这样，平时不下片时HTPC是待机着的，我在外面想要下东西时，先将其远程唤醒，然后通过电驴内置的Web服务器添加下载任务。</p>

<p>PS:路由器的 Port Forward 真是非常有用。我家里的几台机器通过这个东东，都可以远程访问(ssh, Windows远程桌面, OS X Remote Management，电驴和BT Web管理端)。</p>

<p>PS PS:OS X如果是连在网线上的话，也可以唤醒。相关系统设置在 Energy Saver 下 (Wake for Ethernet network access)。</p>

<p>Update: Ubuntu 下设置方法: <a href="http://ubuntuforums.org/showthread.php?t=234588">HOWTO: Set your system up for Wake On LAN (WOL)</a></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Snow Leopard下使用华为天翼3G网卡</title>
      <link>http://blog.ashchan.com/archive/2009/08/10/snow-leopard-china-mobile-huawei-3g/</link>
      <pubDate>2009-08-10 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/08/10/snow-leopard-china-mobile-huawei-3g</guid>
      <content:encoded><![CDATA[<p>中国电信天翼3G搭配的网卡之一华为EC1260可以在OS X下使用，但是仅支持10.4和10.5。这款网卡在Snow Leopard上无法正常工作，运行MobileConnect程序会直接崩溃。</p>

<p>这也怪不得华为，毕竟这款网卡上市的时候离Snow Leopard的发布还远着呢。作为用户来说，我们当然也不能在未来的一年多时间里由于升级操作系统而放弃使用已经购买的3G网络服务。好在问题并不复杂。</p>

<p>这个程序第一次运行时会往系统里安装网卡驱动，因此要做的第一件事是把驱动装上，方法如下:</p>

<ol>
<li>进入ChinaTelecom（插入网卡后会以光盘形式自动挂载）</li>
<li>右击MobileConnect.app，选择"Show Package Contents"</li>
<li>进入Contents/Resources目录，运行Mobile_Connect_Drv_App.pkg</li>
</ol>


<p>非常幸运，这个安装包能正常安装。</p>

<p>安装后，MobileConnect仍然无法正常运行，我们直接绕开它，使用系统自带的连接工具便可:</p>

<ol>
<li>打开 Network Preferences</li>
<li>连接列表里会出现三个新连接，名字为HUAWEI Mobile，HUAWEI Mobile1和HUAWEI Mobile2（华为给CDMA，EVDO和Hybrid三种方式各建了一个连接？那哪个是哪个的？先不管这了，连得上是硬道理）</li>
<li>给HUAWEI Mobile填入设置参数，电话号码填#777，用户名和密码填CARD</li>
<li>点Connect试一下</li>
</ol>


<p>不出意外的话这样便可以连上了，有图为证:</p>

<div class="thumbnail"><a href="http://skitch.com/ashchan/b4as8/snow-leopard-3g-huawei"><img src="http://img.skitch.com/20090810-d4u7p677pcqwt9kdts7iyjcd8n.preview.jpg" alt="snow-leopard-3g-huawei" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>这样Snow Leopard也可以随时随地移动上网了。</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>VirtualBox NAT vs Bridged Adapter</title>
      <link>http://blog.ashchan.com/archive/2009/07/31/virtualbox-nat-vs-bridged-adapter/</link>
      <pubDate>2009-07-31 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/07/31/virtualbox-nat-vs-bridged-adapter</guid>
      <content:encoded><![CDATA[<p>I've encountered networking problem for VirtualBox guest OS (Windows XP) several times. It's very slow to access internet. It appears that the default NAT doesn't play very well. The problem was solved by attaching the network adapter to Bridged Adapter instead. To do so:</p>

<ol>
<li>Shut down the guest OS</li>
<li>Go to Settings - Network</li>
<li>From the Attached to drop down list, choose Bridged Adapter</li>
<li>Start the guest OS and try it</li>
</ol>


<div class="thumbnail"><a href="http://skitch.com/ashchan/b3s9q/virtualbox-adapter"><img src="http://img.skitch.com/20090731-k1bh5w3ba5jickfq7ikp4h9bgp.preview.jpg" alt="virtualbox-adapter" /></a><br /><span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080">Uploaded with <a href="http://plasq.com/">plasq</a>'s <a href="http://skitch.com">Skitch</a>!</span></div>


<p>I mainly use VirtualBox on a Mac. I have friends who run it on Arch Linux and they also have this issue.</p>

<p>Why Sun made the decision to attach a virtual machine a slower network adapter?</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Rename James Chan -> James Chen</title>
      <link>http://blog.ashchan.com/archive/2009/07/16/rename-james-chan-to-james-chen/</link>
      <pubDate>2009-07-16 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/07/16/rename-james-chan-to-james-chen</guid>
      <content:encoded><![CDATA[<p>I've been using James Chan as my English name for quite a long time. I did some search years ago (at that time there was even no Google) and found that people usually use Chan for my Chinese last name 陈, so I took it as mine too.</p>

<p>This confuse people a lot, especially for those from Mainland China Chan looks and sounds quite odd. Chan is used widely in Hong Kong, where 陈 is pronounced like that in Cantonese.</p>

<p>I speak Mandarin, so I decide to change it back to Chen, which is the Pinyin form of 陈. This one is more natural for me. Now I need to do many extra work to update my online profiles.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Migrate to jekyll</title>
      <link>http://blog.ashchan.com/archive/2009/06/15/migrate-to-jekyll/</link>
      <pubDate>2009-06-15 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/06/15/migrate-to-jekyll</guid>
      <content:encoded><![CDATA[<p>I'm migrating this blog from WordPress (self hosted) to <a href="http://github.com/mojombo/jekyll/tree/master">jekyll</a>, so in the future I don't need to worry about database backup, workpress upgrade and other house keeping anymore. The blog source will be on <a href="http://github.com/ashchan/blog.ashchan.com/tree/master">github</a>, and the generated static pages are hosted on my own vps. (github offers CNANE for paying account, which saves even more time and energy)</p>

<p>I've been publishing new blog entries with markdown for more than one year. This means most entries are safe to move. There might be some style or data lost, but that won't matter much. I've also imported most comments to <a href="http://disqus.com/">DISQUS</a>, which will be used as the comment system from now on.</p>

<p>I don't want to bother creating redirecting for old tags and pagination pages. I plan to delete them from google as these pages are filled with duplicated page links. Not so useful for human readers.</p>

<p>My blog was initially hosted on a provider from China, then on microsoft live space, on a <a href="http://subtextproject.com">Subtext</a> install, and on a self hosted wordpress install for the past two years.</p>

<p>I feel like publishing web pages in the very old-school way, only simpler and faster.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>计算机教育从娃娃抓起</title>
      <link>http://blog.ashchan.com/archive/2009/05/29/pc-baby/</link>
      <pubDate>2009-05-29 00:00:00 +0900</pubDate>
      <guid>http://blog.ashchan.com/archive/2009/05/29/pc-baby</guid>
      <content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/ashchan/3575105625/" title="计算机教育从娃娃抓起 by Ashchan, on Flickr"><img src="http://farm4.static.flickr.com/3355/3575105625_5f3f472e9a.jpg" width="500" height="322" alt="计算机教育从娃娃抓起" /></a></p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>


