<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>i5ting (i5ting)</title>
    <link>https://ruby-china.org/i5ting</link>
    <description>狼叔</description>
    <language>en-us</language>
    <item>
      <title>erd 实现有什么好的方法么？</title>
      <description>&lt;p&gt;目前看到的方案&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;graphviz&lt;/li&gt;
&lt;li&gt;jointjs&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mbostock/d3/wiki/Gallery" rel="nofollow" target="_blank"&gt;https://github.com/mbostock/d3/wiki/Gallery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;都不太理想，大家有什么好的建议么？&lt;/p&gt;

&lt;p&gt;补充&lt;/p&gt;

&lt;p&gt;&lt;a href="http://modeling-languages.com/javascript-drawing-libraries-diagrams/" rel="nofollow" target="_blank"&gt;http://modeling-languages.com/javascript-drawing-libraries-diagrams/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;最终方案 jsPlumb&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Wed, 12 Aug 2015 09:34:51 +0800</pubDate>
      <link>https://ruby-china.org/topics/26884</link>
      <guid>https://ruby-china.org/topics/26884</guid>
    </item>
    <item>
      <title>toml 有人用么？</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/toml-lang/toml" rel="nofollow" target="_blank"&gt;https://github.com/toml-lang/toml&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;有点意思，有点干掉 yaml 的意思&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ruby (&lt;a href="/jm" class="user-mention" title="@jm"&gt;&lt;i&gt;@&lt;/i&gt;jm&lt;/a&gt;) - &lt;a href="https://github.com/jm/toml" rel="nofollow" target="_blank"&gt;https://github.com/jm/toml&lt;/a&gt; (toml gem)&lt;/li&gt;
&lt;li&gt;Ruby (&lt;a href="/charliesome" class="user-mention" title="@charliesome"&gt;&lt;i&gt;@&lt;/i&gt;charliesome&lt;/a&gt;) - &lt;a href="https://github.com/charliesome/toml2" rel="nofollow" target="_blank"&gt;https://github.com/charliesome/toml2&lt;/a&gt; (toml2 gem)&lt;/li&gt;
&lt;li&gt;Ruby (&lt;a href="/sandeepravi" class="user-mention" title="@sandeepravi"&gt;&lt;i&gt;@&lt;/i&gt;sandeepravi&lt;/a&gt;) - &lt;a href="https://github.com/sandeepravi/tomlp" rel="nofollow" target="_blank"&gt;https://github.com/sandeepravi/tomlp&lt;/a&gt; (tomlp gem)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;看起来好像不是很感冒，最新版都没有跟上&lt;/p&gt;

&lt;p&gt;有人用么？&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Fri, 05 Jun 2015 11:54:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/25896</link>
      <guid>https://ruby-china.org/topics/25896</guid>
    </item>
    <item>
      <title>如何使用 Node.js 完成 SMS 相关业务?</title>
      <description>&lt;h2 id="node-sms"&gt;node-sms&lt;/h2&gt;
&lt;p&gt;sms 是短消息的意思，这部分主要讲的是如何使用 nodejs 完成 sms 相关业务&lt;/p&gt;
&lt;h2 id="场景"&gt;场景&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;验证码&lt;/li&gt;
&lt;li&gt;找回密码&lt;/li&gt;
&lt;li&gt;支付密码&lt;/li&gt;
&lt;li&gt;离线消息提醒&lt;/li&gt;
&lt;li&gt;变更提醒&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;你总能找个理由，必须用 sms，因为这样你就可以拿到手机号，各种运营手段，数据价值，此处就不八卦了。&lt;/p&gt;
&lt;h2 id="技术点"&gt;技术点&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;node 如何发送短信息？&lt;/li&gt;
&lt;li&gt;如何生成 6 位不同的码，并可以校验（大部分都是）？&lt;/li&gt;
&lt;li&gt;如何限制多长时间发一次？&lt;/li&gt;
&lt;li&gt;如果同时并发非常高怎么办？&lt;/li&gt;
&lt;li&gt;提供 http 接口，便于访问（express 封装一下就可以，不必要讲）&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="node如何发送短信息？"&gt;node 如何发送短信息？&lt;/h2&gt;
&lt;p&gt;我其实找了很多，有的太烂，有的不敢信，有的界面太丑。。。最后选了 luosimao，并写一个 node 模块&lt;/p&gt;

&lt;p&gt;它的好处&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;收到短信时间比较快，按它的模板的特别快，如果是其他的，是要人工审核的&lt;/li&gt;
&lt;li&gt;价格也还凑合，&lt;a href="http://luosimao.com/service/sms#sms-price" rel="nofollow" target="_blank"&gt;http://luosimao.com/service/sms#sms-price&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;提供的 http 接口，非常容易封装调用&lt;/li&gt;
&lt;li&gt;界面是 sms 里最不土的&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;node-sms-luosimao 是 node 发送短信模块，后台服务采用的是 luosimao.com 的服务&lt;/p&gt;

&lt;p&gt;&lt;a href="http://badge.fury.io/js/node-sms-luosimao" rel="nofollow" target="_blank" title=""&gt;&lt;img src="https://badge.fury.io/js/node-sms-luosimao.svg" title="" alt="npm version"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="install"&gt;install&lt;/h2&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save node-sms-luosimao
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="demo"&gt;demo&lt;/h2&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var sms = require("./index");

sms.key = process.env.LSM_KEY

sms.send('18612189310', '测试1~~【node发送短信模块】', function(error, res, body){
  console.log(body);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;说明&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sms.key 是 &lt;a href="https://sms-my.luosimao.com/api" rel="nofollow" target="_blank"&gt;https://sms-my.luosimao.com/api&lt;/a&gt; 里的 API KEY&lt;/li&gt;
&lt;li&gt;把 LSM_KEY 放到环境变量里，相对比较安全&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="如何生成6位不同的码，并可以校验（大部分都是）？"&gt;如何生成 6 位不同的码，并可以校验（大部分都是）？&lt;/h2&gt;
&lt;p&gt;OTP 全称叫 One-time Password，也称动态口令，是根据专门的算法每隔 60 秒生成一个与时间相关的、不可预测的随机数字组合，每个口令只能使用一次，每天可以产生 43200 个密码。&lt;/p&gt;

&lt;p&gt;它分 2 钟&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HOTP (counter based one time passwords) 基于一个加法计数器和一个静态的对称密钥&lt;/li&gt;
&lt;li&gt;TOTP (time based one time passwords).（基于时间的一次性密码算法）是支持时间作为动态因素基于 HMAC 一次性密码算法的扩展。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;对于短信码这种需求，哪种都可以的，如果是 60s 内不允许重新生成，totp 就足够了。&lt;/p&gt;

&lt;p&gt;下面给出具体实现，参见&lt;a href="https://github.com/guyht/notp" rel="nofollow" target="_blank"&gt;https://github.com/guyht/notp&lt;/a&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var notp = require('notp');

var opt = {
    window : 0,
};

var app = {
  encode: function(key) {
    // make sure we can not pass in opt
    return notp.totp.gen(key, opt);
  },
  decode: function(key, token) {
    var login = notp.totp.verify(token, key, opt);
    // invalid token if login is null
    if (!login) {
        console.log('Token invalid');
        return false;
    }

    // valid token
    // console.log('Token valid, sync value is %s', login.delta);
    return true;
  }
}


module.exports = app;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;在这里我写了一个 encode 和 decode 方法，即采用 totp 加解密，核心参数是 key。&lt;/p&gt;

&lt;p&gt;那么 key 怎么能保证唯一呢？其实很简单，我们的业务一般是根据手机号或用户绑定的，所以就很简单了。&lt;/p&gt;
&lt;h2 id="如何限制多长时间发一次？"&gt;如何限制多长时间发一次？&lt;/h2&gt;
&lt;p&gt;短信发送是按条收费的，不能乱发，那都是钱啊，于是有了各种限制，比如常见的 60s 内可以再发一次。每次验证码的有效期是 10 分钟或者其他时间。&lt;/p&gt;

&lt;p&gt;那么这些规则怎么实现更好呢？&lt;/p&gt;

&lt;p&gt;最简单也是最好的办法是利用 redis 的 expire 命令&lt;/p&gt;

&lt;p&gt;&lt;a href="http://redis.io/commands/expire" rel="nofollow" target="_blank"&gt;http://redis.io/commands/expire&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;expire 命令的原理是在 redis 里设置 key 的是 value，从设置开始，xx 秒之后，这个 key 就会被删除掉&lt;/p&gt;

&lt;p&gt;这样做的好处：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;redis 是内存数据库非常快&lt;/li&gt;
&lt;li&gt;key 过期删除，非常节省&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;实现如下：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var redis = require('redis')
    , client = redis.createClient();

client.on('error', function (err) {
    console.log('Error ' + err);
});

client.on('connect', function(){

});

function cache_expire(k, v){
  console.log('============= cache_expire ==============');
  if(client){
    client.set(k, v, redis.print);
    // Expire in 1*60 seconds
    client.expire(k, 1*60);
  }else{
    console.log('redis client instance is not exist.');
  }
}

/* GET home page. */
router.get('/request_verify_token', function(req, res) {
  var tel = req.param('tel')

  var key = tel + '123456789ssdsfx01234567890';

  a = opt.encode(key);
  console.log(a);

  //首先检测缓存里是否有tel的key
  client.get(tel, function (err, reply) {
      if(reply) {
          console.log('已存在: 不做任何处理' + reply.toString());
          res.status(200).json({
            code: 1,
            msg:'fail，最近1分钟内会已有申请，不允许重复操作'
          })
      } else {
          console.log('不存在，发送短信');

          sms.send(tel,  a + '（xxx验证码），请尽快完成验证。'  + '~~【xxxxx】', function(error, response, body){
            console.log(body);
            if(error){
              res.status(200).json({
                code: 1,
                msg:'sms.send fail'
              })
            }else{
              cache_expire(tel, a);

              res.status(200).json({
                code: 0,
                msg:'sms.send sucess'
              })
            }
          });
      }
  });
});

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;说明&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cache_expire 是设置 redis 的 key&lt;/li&gt;
&lt;li&gt;request_verify_token 是检测缓存里是否有 tel 的 key，如果有就什么也不做，如果没有就发送短信&lt;/li&gt;
&lt;li&gt;如果需要保存发送历史记录，可以日志，也可以库表保存&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;其他逻辑和这个类似，自己实现。&lt;/p&gt;
&lt;h2 id="如果同时并发非常高怎么办？"&gt;如果同时并发非常高怎么办？&lt;/h2&gt;
&lt;p&gt;业务系统和 sms 系统是分开的，如果并发非常高&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;sms 部分做好集群，比如 pm2&lt;/li&gt;
&lt;li&gt;使用 mq（见 &lt;a href="http://mp.weixin.qq.com/s?__biz=MzAxMTU0NTc4Nw==&amp;amp;mid=222389072&amp;amp;idx=1&amp;amp;sn=c0baf99bda2c74aa8b4fd0e2a2b14096#rd" rel="nofollow" target="_blank" title=""&gt;Nodejs 消息队列&lt;/a&gt;）&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;全文完&lt;/p&gt;

&lt;p&gt;详见  &lt;a href="http://mp.weixin.qq.com/s?__biz=MzAxMTU0NTc4Nw==&amp;amp;mid=222488512&amp;amp;idx=1&amp;amp;sn=b068c0453b0f21427fbaf53526540618#rd" rel="nofollow" target="_blank" title=""&gt;如何使用 nodejs 完成 sms 相关业务？&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;欢迎关注我的公众号【node 全栈】  &lt;img src="//dn-cnode.qbox.me/FtALxsauUkYDGdzcuA5y6BaIdUMC" title="" alt="node全栈.png"&gt;&lt;/p&gt;

&lt;p&gt;ruby 里海波写的短信的 gem 很不错&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Mon, 18 May 2015 09:42:09 +0800</pubDate>
      <link>https://ruby-china.org/topics/25615</link>
      <guid>https://ruby-china.org/topics/25615</guid>
    </item>
    <item>
      <title>High Performance Haml Implementation</title>
      <description>&lt;p&gt;High Performance Haml Implementation&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/k0kubun/hamlit" rel="nofollow" target="_blank"&gt;https://github.com/k0kubun/hamlit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fast rendering&lt;/p&gt;

&lt;p&gt;Hamlit's rendering is 8.47x times faster than original haml.&lt;/p&gt;

&lt;p&gt;&lt;img src="https://camo.githubusercontent.com/f726ecfbb1e89aef45c120404db17962a38f5349/687474703a2f2f692e6779617a6f2e636f6d2f35376237323631303261346131363964346238356363323266636262336666332e706e67" title="" alt=""&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hamlit:   133922.9 i/s
erubis:   123464.1 i/s - 1.08x slower
  slim:   110404.3 i/s - 1.21x slower
  faml:    92009.3 i/s - 1.46x slower
  haml:    15810.4 i/s - 8.47x slower
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This benchmark is the same as slim-template/slim's one for fairness. (The result on travis CI)&lt;/p&gt;

&lt;p&gt;开起来还不错的样子&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Tue, 31 Mar 2015 07:33:52 +0800</pubDate>
      <link>https://ruby-china.org/topics/24919</link>
      <guid>https://ruby-china.org/topics/24919</guid>
    </item>
    <item>
      <title>还不错的一个网址</title>
      <description>&lt;p&gt;Showcase &amp;amp; Discover Creative Work&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.behance.net/" rel="nofollow" target="_blank"&gt;https://www.behance.net/&lt;/a&gt;&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Sat, 17 Jan 2015 17:11:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/23787</link>
      <guid>https://ruby-china.org/topics/23787</guid>
    </item>
    <item>
      <title>我的 2014</title>
      <description>&lt;p&gt;既然有朋友牵头，我也来凑个热闹吧&lt;/p&gt;
&lt;h2 id="开源项目和文档"&gt;开源项目和文档&lt;/h2&gt;
&lt;p&gt;主要分几部分&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nodejs 相关&lt;/li&gt;
&lt;li&gt;和 markdown toc 相关的&lt;/li&gt;
&lt;li&gt;工作里总结的：如 ionic，ratchet 等，以 h5 为主&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;下面是具体内容&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npmjs.org 上 23 packages&lt;/li&gt;
&lt;li&gt;i5ting_ztree_toc（github 上 79 个 star）&lt;/li&gt;
&lt;li&gt;tocmd 一系列 ruby 和 node 实现的生产 toc 的命令行工具，还有 gulp 的 task&lt;/li&gt;
&lt;li&gt;ionic_ninjia (关于 ionicframework 的总结，有人约我写书，还没空)&lt;/li&gt;
&lt;li&gt;node-mini-obj&lt;/li&gt;
&lt;li&gt;awesome-mac-practice&lt;/li&gt;
&lt;li&gt;fayeserver&lt;/li&gt;
&lt;li&gt;upload-cli&lt;/li&gt;
&lt;li&gt;promise_practice&lt;/li&gt;
&lt;li&gt;weinre-practice&lt;/li&gt;
&lt;li&gt;ip-cli(a cli tool for show local ip &amp;amp;&amp;amp; copy ip to clipboard)&lt;/li&gt;
&lt;li&gt;ratchet-practice(twitter ratchet framework's practice)&lt;/li&gt;
&lt;li&gt;mmmm(4m for tail wrapper)&lt;/li&gt;
&lt;li&gt;Collection.js(Collection.js is mobile collection: a data access object wrapper for all mobile platform)&lt;/li&gt;
&lt;li&gt;用 node 写了 cron 和 push 项目，mongodb+redis&lt;/li&gt;
&lt;li&gt;node 相关一系列教程和视频&lt;/li&gt;
&lt;li&gt;trans 翻译文档用的工具&lt;/li&gt;
&lt;li&gt;rosi 相关的数据爬去和 ios 客户端&lt;/li&gt;
&lt;li&gt;微信答题&lt;/li&gt;
&lt;li&gt;一个基于 cocos2d-js 的游戏&lt;/li&gt;
&lt;li&gt;js-tools-best-practice（我和柯织一起完成）&lt;/li&gt;
&lt;li&gt;IPA-File-Deliver（和公司的 mdm，mam 类似）&lt;/li&gt;
&lt;li&gt;tealeaf-http 转文档，分分钟&lt;/li&gt;
&lt;li&gt;node-deploy-practice&lt;/li&gt;
&lt;li&gt;node-upload-practice&lt;/li&gt;
&lt;li&gt;study-jade&lt;/li&gt;
&lt;li&gt;timeline-js-boilerplate 简历，给智楠等人讲&lt;/li&gt;
&lt;li&gt;node-debug-tutorial&lt;/li&gt;
&lt;li&gt;badge-cli&lt;/li&gt;
&lt;li&gt;gulp-trans&lt;/li&gt;
&lt;li&gt;api-test(我和健翔 it is a api degign &amp;amp;&amp;amp; doc tools)&lt;/li&gt;
&lt;li&gt;cron（基于 redis 做的调度系统，可以精确到毫秒，非常适合 etl 之类的）&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="视频"&gt;视频&lt;/h2&gt;
&lt;p&gt;主要目前为了检查一下自己弱弱的表达能力&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how-to-write-a-node-cli-tools-with-commander&lt;/li&gt;
&lt;li&gt;node-debug 三法三例之 node debugger&lt;/li&gt;
&lt;li&gt;如何使用 gulp 来把 markdown 生成 html 文档并上传到 git pages 上&lt;/li&gt;
&lt;li&gt;node-debug 三法三例之 node inspector&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="学习"&gt;学习&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;研究 shadowsocks-iOS&lt;/li&gt;
&lt;li&gt;研究 msgpack5，贡献了一点代码&lt;/li&gt;
&lt;li&gt;aes256&lt;/li&gt;
&lt;li&gt;otp&lt;/li&gt;
&lt;li&gt;mdm&lt;/li&gt;
&lt;li&gt;mam&lt;/li&gt;
&lt;li&gt;mqtt&lt;/li&gt;
&lt;li&gt;go&lt;/li&gt;
&lt;li&gt;nodejs&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="最出色的小弟"&gt;最出色的小弟&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;健翔&lt;/li&gt;
&lt;li&gt;柯织&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="创造"&gt;创造&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;以 api 为中心的移动平台方法论&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="诗歌（13 + 1）"&gt;诗歌（13 + 1）&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;清晨 2014-02-19 08&lt;/li&gt;
&lt;li&gt;美 (0/5) 2014-02-24 10:51&lt;/li&gt;
&lt;li&gt;四月 (0/3) 2014-03-25 10:37&lt;/li&gt;
&lt;li&gt;生活 (2014-04-03 07:24)&lt;/li&gt;
&lt;li&gt;旅行前 (2014-04-03 07:24)&lt;/li&gt;
&lt;li&gt;二十一世纪 (2014-04-21 21:34)&lt;/li&gt;
&lt;li&gt;二十九 (2014-07-16 07:56)&lt;/li&gt;
&lt;li&gt;甜蜜的毒药（某电视剧的观后感） (2014-07-17 07:17)&lt;/li&gt;
&lt;li&gt;无题 (2014-08-28 19:40)&lt;/li&gt;
&lt;li&gt;剥鸡蛋 (2014-10-11 15:22)&lt;/li&gt;
&lt;li&gt;秋之上午 (2014-10-15 11:46)&lt;/li&gt;
&lt;li&gt;秋天 (2014-10-20 13:40)&lt;/li&gt;
&lt;li&gt;无题 (2014-10-31 16:44)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;另有一七绝&lt;/p&gt;
&lt;h2 id="新的1年打算学习哪些技术？"&gt;新的 1 年打算学习哪些技术？&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;api 为中心的方法论实现&lt;/li&gt;
&lt;li&gt;html5 版本的 ichat&lt;/li&gt;
&lt;li&gt;h5 再继续精进，最好是把我的框架继续写&lt;/li&gt;
&lt;li&gt;h5 缓存通用框架 Collection.js&lt;/li&gt;
&lt;li&gt;实时相关，比如 kafka 和 storm&lt;/li&gt;
&lt;li&gt;mqtt 协议&lt;/li&gt;
&lt;li&gt;v8 代码&lt;/li&gt;
&lt;li&gt;erlang &amp;amp;&amp;amp; elixir&lt;/li&gt;
&lt;li&gt;go&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="结语"&gt;结语&lt;/h2&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;生活
---------------

就好像如厕
一十二张印花的餐巾纸

展开第四张的时候已有皱纹
多希望喊一声：痛快

展开第十二张的时候
坐在坟前，看太阳

而大多数时候都在纠结：
别再玩了
纸要不够了
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>i5ting</author>
      <pubDate>Sun, 04 Jan 2015 21:52:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/23542</link>
      <guid>https://ruby-china.org/topics/23542</guid>
    </item>
    <item>
      <title>好一段变态的 makefile，js 压缩用的</title>
      <description>&lt;p&gt;好一段变态的 makefile，js 压缩用的&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHELL := /bin/bash

QS=compilation_level=SIMPLE_OPTIMIZATIONS&amp;amp;output_format=text
URL=http://closure-compiler.appspot.com/compile
CODE=js_code@lib/fastclick.js

CHECK=\033[32m✔\033[39m

build/fastclick.min.js: lib/fastclick.js
    @mkdir -p build
    @echo -n "Building build/fastclick.min.js...                  "
    @curl --silent --show-error --data-urlencode "${CODE}" --data "${QS}&amp;amp;output_info=compiled_code" ${URL} -o build/fastclick.min.js
    @echo -e "${CHECK} Done"
    @echo -n "Getting compression stats...                        "
    @echo -e "${CHECK} Done\n\n" "`curl --silent --show-error --data-urlencode "${CODE}" --data "${QS}&amp;amp;output_info=statistics" ${URL}`"
    @echo ${STATS}

test:
    jshint -v lib/*.js

clean:
    rm -rf build

.PHONY: clean test
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;要点&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;使用 closure&lt;/li&gt;
&lt;li&gt;天朝还得翻墙&lt;/li&gt;
&lt;li&gt;其他 makefile 写的很好&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;不过，真心没有 gulp 好用&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Thu, 04 Dec 2014 07:18:09 +0800</pubDate>
      <link>https://ruby-china.org/topics/23013</link>
      <guid>https://ruby-china.org/topics/23013</guid>
    </item>
    <item>
      <title>发现 2 个找茬的帖子：Elixir vs ror</title>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mroth/phoenix-showdown" rel="nofollow" target="_blank"&gt;https://github.com/mroth/phoenix-showdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.littlelines.com/blog/2014/07/08/elixir-vs-ruby-showdown-phoenix-vs-rails/" rel="nofollow" target="_blank"&gt;http://www.littlelines.com/blog/2014/07/08/elixir-vs-ruby-showdown-phoenix-vs-rails/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;发现一个回复，说的很好&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AkitaOnRails • 5 months ago
I'm sorry to say, but this is a pointless comparison.

To start, Phoenix is not nearly as complex as Rails (meaning, Rails does a whole lot more). The language is obviously much faster than Ruby, we all know that. And anyone could write Rails in any other faster language, and they did. You do have ASP.NET MVC in C#, Laravel in PHP, Django (this came before) in Python. Now, the question is: if you can write something much faster in any other language, why did Rails not only survive, but grew?

Elixir + Phoenix is the same in terms of use case as Node.js + Express. You are comparing apples and oranges. Elixir's use case lies in the same category as Node.js, Scala, Go, Clojure. Asynchronous messaging, background batch processing, etc. Elixir does add a heavily needed coat of eye candy and niceties that drops a lot of entry barriers for Erlang, but it's far com being a Ruby-replacement (and it's not even it's main goal, I suppose).

I understand the motivation, but I don't think this is the way to try to evangelize Elixir and Phoenix. Ruby and Rails is not the competition. GoLang and Node.js are.

This is not to say I dislike Elixir or Phoenix. Far from that. I only think there are other ways to showcase something good without such comparisons.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但是 see &lt;a href="https://github.com/mroth/phoenix-showdown#comparative-benchmark-numbers" rel="nofollow" target="_blank"&gt;https://github.com/mroth/phoenix-showdown#comparative-benchmark-numbers&lt;/a&gt; here&lt;/p&gt;

&lt;p&gt;结论是 phoenix 的吞吐量是 sinatra 的 3 倍多&lt;/p&gt;

&lt;p&gt;就算 helloworld，ruby 估计也干不过 Elixir&lt;/p&gt;

&lt;p&gt;求科普&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Sat, 29 Nov 2014 22:18:54 +0800</pubDate>
      <link>https://ruby-china.org/topics/22931</link>
      <guid>https://ruby-china.org/topics/22931</guid>
    </item>
    <item>
      <title>个人怎么申请微信支付</title>
      <description>&lt;ul&gt;
&lt;li&gt;个人认证服务号，行不通啊&lt;/li&gt;
&lt;li&gt;微信支付只能是服务号&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;是不是我哪里错了？求经验&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Sat, 29 Nov 2014 21:09:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/22930</link>
      <guid>https://ruby-china.org/topics/22930</guid>
    </item>
    <item>
      <title>求更精简的写法</title>
      <description>&lt;p&gt;把 0 转成 A，把 1 转成 B，直到 Z&lt;/p&gt;

&lt;p&gt;目前我写的&lt;/p&gt;

&lt;p&gt;js 代码&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function i_to_char(z) {
    var i = z;
    if(z &amp;gt;= 0 &amp;amp;&amp;amp; z &amp;lt; 26) {
        i = i + 65;
    }else{
        return "undefined z in i_to_char(z)"
    }

    return String.fromCharCode(i);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;大家有更精简的写法？&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Thu, 20 Nov 2014 00:12:13 +0800</pubDate>
      <link>https://ruby-china.org/topics/22770</link>
      <guid>https://ruby-china.org/topics/22770</guid>
    </item>
    <item>
      <title>git 里 push request 注意事项</title>
      <description>&lt;h2 id="忽略本地本地"&gt;忽略本地本地&lt;/h2&gt;
&lt;p&gt;忽略本地本地，而不想给 push request 主项目改变的做法&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git update-index --assume-unchanged Gemfile
git update-index --assume-unchanged Gemfile.lock 
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="fork出来的项目和原有项目保持同步"&gt;fork 出来的项目和原有项目保持同步&lt;/h2&gt;
&lt;p&gt;当我们 在 github 上 fork 出一个项目后，如果原有的项目更新了，怎样保持我们 fork 出来的项目和原有项目保持同步呢并提交我们的代码更新呢？即怎样保持 fork 出的项目和上游项目保持更新，怎样创建 pull request？关键步骤是使用 git 的 rebase 命令。&lt;/p&gt;

&lt;p&gt;步骤：&lt;/p&gt;

&lt;p&gt;1、在 Fork 的代码库中添加上游代码库的 remote 源，该操作只需操作一次即可。&lt;/p&gt;

&lt;p&gt;如：其中# upstream 表示上游代码库名，可以任意。&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add upstream https://github.scm.corp.ebay.com/montage/frontend-ui-workspace
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;2、将本地的修改提交 commit&lt;/p&gt;

&lt;p&gt;3、在每次 Pull Request 前做如下操作，即可实现和上游版本库的同步。&lt;/p&gt;

&lt;p&gt;3.1 : &lt;code&gt;git remote update upstream&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3.2 : &lt;code&gt;git rebase upstream/{branch name}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;需要注意的是在操作 3.2 之前，一定要将 checkout 到{branch name}所指定的 branch，&lt;/p&gt;

&lt;p&gt;如：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout develop
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;4、Push 代码到 Github&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>i5ting</author>
      <pubDate>Tue, 18 Nov 2014 21:55:20 +0800</pubDate>
      <link>https://ruby-china.org/topics/22748</link>
      <guid>https://ruby-china.org/topics/22748</guid>
    </item>
    <item>
      <title>还是 Ruby 社区比较高大上</title>
      <description>&lt;p&gt;最近在 nodejs 社区混了一段时间&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;用户不活跃，回复超少&lt;/li&gt;
&lt;li&gt;普遍水平较低，问的问题不能再白了&lt;/li&gt;
&lt;li&gt;不追求各种新奇好东西&lt;/li&gt;
&lt;li&gt;感觉不够包容，还是太年轻了&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;我的总结是：&lt;/p&gt;

&lt;p&gt;还是 ruby 社区比较高大上&lt;/p&gt;

&lt;p&gt;哇哈哈&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Sun, 16 Nov 2014 09:54:36 +0800</pubDate>
      <link>https://ruby-china.org/topics/22704</link>
      <guid>https://ruby-china.org/topics/22704</guid>
    </item>
    <item>
      <title>C in four functions</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/rswier/c4/blob/master/c4.c" rel="nofollow" target="_blank"&gt;https://github.com/rswier/c4/blob/master/c4.c&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;4 个函数&lt;/li&gt;
&lt;li&gt;505 行代码&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;写了一个 c 的编译器&lt;/p&gt;

&lt;p&gt;有点意思吧？&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Mon, 10 Nov 2014 13:53:33 +0800</pubDate>
      <link>https://ruby-china.org/topics/22583</link>
      <guid>https://ruby-china.org/topics/22583</guid>
    </item>
    <item>
      <title>sponsored 是怎么来？</title>
      <description>&lt;p&gt;今天看到的一个项目里有&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Acknowledgements

This project was kindly sponsored by nearForm.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这是咋来得呢？&lt;/p&gt;

&lt;p&gt;其他公司为啥要 sponsor？&lt;/p&gt;

&lt;p&gt;和外包类似？但不又不像，求解&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Sun, 09 Nov 2014 09:32:22 +0800</pubDate>
      <link>https://ruby-china.org/topics/22566</link>
      <guid>https://ruby-china.org/topics/22566</guid>
    </item>
    <item>
      <title>我写的一个 gem，据说安装有问题，我又测不出来，求测试</title>
      <description>&lt;p&gt;一个兄弟给我发邮件说&lt;/p&gt;

&lt;p&gt;“Hi，我搜到了 9 个月前你更新的文章『关于 Markdown 的 ToC，你还想要什么功能？』
用 gem 安装，提示如下图，请问如何解决”&lt;/p&gt;

&lt;hr&gt;

&lt;p&gt;我写的一个 gem，据说安装有问题，我又测不出来&lt;/p&gt;

&lt;p&gt;求测，反馈贴图&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install tocmd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;我目前测试 2.1 下面正常&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜  ~  ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
➜  ~  gem install tocmd


Fetching: tocmd-0.4.1.gem (100%)
Successfully installed tocmd-0.4.1
Parsing documentation for tocmd-0.4.1
Installing ri documentation for tocmd-0.4.1
Done installing documentation for tocmd after 1 seconds
1 gem installed
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;在 2.0 下测试也正常啊&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜  tocmd.gem git:(master) ✗ ruby -v                                            
ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-darwin13.3.0]
➜  tocmd.gem git:(master) ✗ ruby -Ilib bin/tocmd_conf -f test_data/sample2.md  
src path = /Users/sang/workspace/github/tocmd.gem/test_data
desc path = /Users/sang/workspace/github/tocmd.gem/test_data/preview
toc_conf file exist
"start building......"
"process_with_one"
"build = /Users/sang/workspace/github/tocmd.gem/test_data/preview/sample2.html"
"0.4.0"
➜  tocmd.gem git:(master) ✗ 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;为啥有的人装不上呢？&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Wed, 05 Nov 2014 22:45:04 +0800</pubDate>
      <link>https://ruby-china.org/topics/22511</link>
      <guid>https://ruby-china.org/topics/22511</guid>
    </item>
    <item>
      <title>八卦一下，为啥 ruby 里没有 node-inspector 这样的东西呢？</title>
      <description>&lt;p&gt;八卦一下，为啥 ruby 里没有 node-inspector 这样的东西呢？&lt;/p&gt;

&lt;p&gt;node-inspector&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/node-inspector/node-inspector" rel="nofollow" target="_blank"&gt;https://github.com/node-inspector/node-inspector&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;是否我又无知了，求拍死&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Fri, 24 Oct 2014 17:26:48 +0800</pubDate>
      <link>https://ruby-china.org/topics/22250</link>
      <guid>https://ruby-china.org/topics/22250</guid>
    </item>
    <item>
      <title>在 Ionic 或者 Phonegap（cordova）里如何在页面里获取设备是 iPhone 还是 iPad</title>
      <description>&lt;h2 id="在ionicframework或者phonegap（cordova）里如何在页面里获取设备是iPhone还是iPad"&gt;在 ionicframework 或者 phonegap（cordova）里如何在页面里获取设备是 iPhone 还是 iPad&lt;/h2&gt;&lt;h2 id="在index.js里"&gt;在 index.js 里&lt;/h2&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Update DOM on a Received Event
receivedEvent: function(id) {
    alert(platform);
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="修改oc代码"&gt;修改 oc 代码&lt;/h2&gt;&lt;h3 id="方式1"&gt;方式 1&lt;/h3&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 

- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
    // Black base color for background matches the native apps
    theWebView.backgroundColor = [UIColor blackColor];

    NSString *os = (IS_IPAD == YES) ? @"ipad":@"iPhone";
    NSString *js = [NSString stringWithFormat:@"window.platform='%@'",os];
    [theWebView stringByEvaluatingJavaScriptFromString:js];

    return [super webViewDidFinishLoad:theWebView];
}
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="方式2：变态精简版"&gt;方式 2：变态精简版&lt;/h3&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
    // Black base color for background matches the native apps
    theWebView.backgroundColor = [UIColor blackColor];

    [theWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.platform='%@'",((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)  == YES) ? @"ipad":@"iPhone"]];

    return [super webViewDidFinishLoad:theWebView];
}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="附赠一个tip，使用webSQL来保存数据"&gt;附赠一个 tip，使用 webSQL 来保存数据&lt;/h2&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//open database
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024); 

db.transaction(function (tx) {            
    tx.executeSql('CREATE TABLE IF NOT EXISTS last_word (id INTEGER PRIMARY KEY AUTOINCREMENT, content Text,date string)');
});

&lt;/code&gt;&lt;/pre&gt;</description>
      <author>i5ting</author>
      <pubDate>Mon, 13 Oct 2014 14:43:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/22009</link>
      <guid>https://ruby-china.org/topics/22009</guid>
    </item>
    <item>
      <title>Ruby 基础教程 (第 4 版)</title>
      <description>&lt;p&gt;这个书很简单，适合新手，基于 ruby 2.0&lt;/p&gt;

&lt;p&gt;前 11 章适合所有新手，举例以及长短等都非常合适&lt;/p&gt;

&lt;p&gt;中间都是 api&lt;/p&gt;

&lt;p&gt;最后一部分也比较简单，没有讲 gem 啥的&lt;/p&gt;

&lt;p&gt;附录一般，各系统安装之类的&lt;/p&gt;

&lt;p&gt;算基础教程，推荐一下，虽然我不认识译者&lt;/p&gt;

&lt;p&gt;&lt;a href="http://product.china-pub.com/3770445#ml" rel="nofollow" target="_blank"&gt;http://product.china-pub.com/3770445#ml&lt;/a&gt;&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Mon, 22 Sep 2014 23:20:41 +0800</pubDate>
      <link>https://ruby-china.org/topics/21670</link>
      <guid>https://ruby-china.org/topics/21670</guid>
    </item>
    <item>
      <title>erb 有什么经典文章么？</title>
      <description>&lt;p&gt;深入一些的那种&lt;/p&gt;</description>
      <author>i5ting</author>
      <pubDate>Sun, 21 Sep 2014 17:56:32 +0800</pubDate>
      <link>https://ruby-china.org/topics/21645</link>
      <guid>https://ruby-china.org/topics/21645</guid>
    </item>
    <item>
      <title>这样的文档工具有人喜欢么？</title>
      <description>&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2014/fca3a0c74edad71393a5e03d5418bcbd.png" title="" alt=""&gt;&lt;/p&gt;
&lt;h2 id="高级feature"&gt;高级 feature&lt;/h2&gt;&lt;h3 id="中英文切换"&gt;中英文切换&lt;/h3&gt;&lt;h3 id="开发版本与发布版本切换"&gt;开发版本与发布版本切换&lt;/h3&gt;&lt;h3 id="分配任务"&gt;分配任务&lt;/h3&gt;&lt;h3 id="review"&gt;review&lt;/h3&gt;&lt;h3 id="todo"&gt;todo&lt;/h3&gt;&lt;h3 id="嵌入可运行demo"&gt;嵌入可运行 demo&lt;/h3&gt;&lt;h3 id="自定义修改ztree_toc配置项"&gt;自定义修改 ztree_toc 配置项&lt;/h3&gt;</description>
      <author>i5ting</author>
      <pubDate>Sun, 17 Aug 2014 14:37:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/21066</link>
      <guid>https://ruby-china.org/topics/21066</guid>
    </item>
  </channel>
</rss>
