<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>hui_green (eiffel)</title>
    <link>https://ruby-china.org/hui_green</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>不用 Rails 如何获取资源的 fingerprint?</title>
      <description>&lt;p&gt;页面是用 C 语言生成的，页面里的资源没有 fingerprint 就加载不出来，尝试着用 C 来获得相应资源的 fingerprint，算法都是 sha256，但是得出的值和 rails 生成的不一样，代码如下：&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;char&lt;span class="k"&gt;*&lt;/span&gt; sha256_fingerprint&lt;span class="o"&gt;(&lt;/span&gt;char &lt;span class="k"&gt;*&lt;/span&gt;filename&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;   unsigned char c[SHA256_DIGEST_LENGTH]&lt;span class="p"&gt;;&lt;/span&gt;
    unsigned char fingerprint[SHA256_DIGEST_LENGTH&lt;span class="k"&gt;*&lt;/span&gt;2]&lt;span class="p"&gt;;&lt;/span&gt;
    int i&lt;span class="p"&gt;;&lt;/span&gt;
    FILE &lt;span class="k"&gt;*&lt;/span&gt;inFile &lt;span class="o"&gt;=&lt;/span&gt; fopen &lt;span class="o"&gt;(&lt;/span&gt;filename, &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    SHA256_CTX shaContext&lt;span class="p"&gt;;&lt;/span&gt;
    int bytes&lt;span class="p"&gt;;&lt;/span&gt;
    unsigned char data[1024]&lt;span class="p"&gt;;&lt;/span&gt;

    SHA256_Init &lt;span class="o"&gt;(&lt;/span&gt;&amp;amp;shaContext&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;bytes &lt;span class="o"&gt;=&lt;/span&gt; fread &lt;span class="o"&gt;(&lt;/span&gt;data, 1, 1024, inFile&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; 0&lt;span class="o"&gt;)&lt;/span&gt;
        SHA256_Update &lt;span class="o"&gt;(&lt;/span&gt;&amp;amp;shaContext, data, bytes&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    SHA256_Final &lt;span class="o"&gt;(&lt;/span&gt;c,&amp;amp;shaContext&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;i &lt;span class="o"&gt;=&lt;/span&gt; 0&lt;span class="p"&gt;;&lt;/span&gt; i &amp;lt; SHA256_DIGEST_LENGTH&lt;span class="p"&gt;;&lt;/span&gt; i++&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;sprintf&lt;span class="o"&gt;(&lt;/span&gt;fingerprint+i&lt;span class="k"&gt;*&lt;/span&gt;2, &lt;span class="s2"&gt;"%02x"&lt;/span&gt;, c[i]&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
    fclose &lt;span class="o"&gt;(&lt;/span&gt;inFile&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;fingerprint&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;或者还有别的办法获取 fingerprint 吗？&lt;/p&gt;</description>
      <author>hui_green</author>
      <pubDate>Sat, 01 Apr 2017 14:50:26 +0800</pubDate>
      <link>https://ruby-china.org/topics/32681</link>
      <guid>https://ruby-china.org/topics/32681</guid>
    </item>
    <item>
      <title>用 Passenger Standalone 部署 Action Cable 过一段时间就断开然后就连不上了</title>
      <description>&lt;p&gt;我在本地也架设了 passenger standalone 服务器，测试目前为止一切正常，但是部署到产品服务器以后，有 3 个奇怪的问题：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;chrome 一直连不上，提示 WebSocket is closed before the connection is established&lt;/li&gt;
&lt;li&gt;firefox 开始是正常连接并且传输数据的，但是过一段时间（貌似是在接收过数据以后，但不是马上就断）就自动断开，再连就连不上了，服务器运行正常，但是接收不到浏览器的连接请求&lt;/li&gt;
&lt;li&gt;有一次服务器断开连接是因为 Request queue full (configured max. size: 100)，这个我觉得不太可能，因为只是小范围测试没有这么多请求（而且我在客户端设置了如果连接三次不成功就放弃）&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;对服务器部署这方面知识欠缺，现在一头雾水，有没有明白的大神给个提示，感激不尽&lt;/p&gt;</description>
      <author>hui_green</author>
      <pubDate>Wed, 14 Dec 2016 16:45:25 +0800</pubDate>
      <link>https://ruby-china.org/topics/31906</link>
      <guid>https://ruby-china.org/topics/31906</guid>
    </item>
    <item>
      <title>Gem 源在局域网中另一台机器上，如何安装能保持 gem 的更新</title>
      <description>&lt;p&gt;我有一个自己写的 gem，现在要在另一台机器上部署应用程序进行测试，由于这个 gem 每天都要更新，如果我不想把这个 gem 也拷贝到服务器上每天都手动更新，应该如何安装这个 gem?&lt;/p&gt;</description>
      <author>hui_green</author>
      <pubDate>Wed, 30 Nov 2016 15:30:35 +0800</pubDate>
      <link>https://ruby-china.org/topics/31744</link>
      <guid>https://ruby-china.org/topics/31744</guid>
    </item>
    <item>
      <title>Action Cable 跨域如何获得 user_id？</title>
      <description>&lt;p&gt;服务器单开，连接的时候没办法获得原域的 cookie，也就没办法验证用户了，当然最好是在用户登陆的时候设置这个域的 cookie，但是我不知道可不可以，试着指定 cookie 的 domain，没有成功，或是有其他办法获得 user_id？&lt;/p&gt;</description>
      <author>hui_green</author>
      <pubDate>Mon, 28 Nov 2016 14:59:41 +0800</pubDate>
      <link>https://ruby-china.org/topics/31717</link>
      <guid>https://ruby-china.org/topics/31717</guid>
    </item>
    <item>
      <title>Rails 为什么要有 mass assign？</title>
      <description>&lt;p&gt;rails5 已经不支持 attr_accessible, 取而代之的是 permitted params, 这样就要在每个需要 mass assign 的方法设置 permitted params，是不是更麻烦了，可不可以彻底不用 mass assign，直接 obj.attr=params[:attr]，然后 save，这样代码更加清晰易读。&lt;/p&gt;</description>
      <author>hui_green</author>
      <pubDate>Mon, 21 Nov 2016 15:23:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/31650</link>
      <guid>https://ruby-china.org/topics/31650</guid>
    </item>
  </channel>
</rss>
