<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>wokenqingtian (吉翔)</title>
    <link>https://ruby-china.org/wokenqingtian</link>
    <description>Ruby developer</description>
    <language>en-us</language>
    <item>
      <title>项目依赖于 wicked_pdf 和 pdfkit 可能要考虑迁移到别的库了</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/mileszs/wicked_pdf" rel="nofollow" target="_blank" title=""&gt;wicked_pdf&lt;/a&gt; 和 &lt;a href="https://github.com/pdfkit/pdfkit" rel="nofollow" target="_blank" title=""&gt;pdfkit&lt;/a&gt; 都依赖于 &lt;a href="https://wkhtmltopdf.org" rel="nofollow" target="_blank" title=""&gt;wkhtmltopdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;wkhtmltopdf 已经基本停止维护了&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/wkhtmltopdf/wkhtmltopdf/issues/5160" rel="nofollow" target="_blank"&gt;https://github.com/wkhtmltopdf/wkhtmltopdf/issues/5160&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wkhtmltopdf.org/status.html" rel="nofollow" target="_blank"&gt;https://wkhtmltopdf.org/status.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;而 wkhtmltopdf 停止维护是因为 &lt;a href="https://github.com/qtwebkit/qtwebkit" rel="nofollow" target="_blank" title=""&gt;qtwebkit&lt;/a&gt; 无人维护了&lt;/p&gt;

&lt;p&gt;而 qtwebkit 被 WebKit 抛弃以后，一直是一位俄罗斯程序员 (&lt;a href="https://github.com/annulen" rel="nofollow" target="_blank" title=""&gt;annulen&lt;/a&gt;) 在维护。
&lt;a href="https://github.com/qtwebkit/qtwebkit/issues/1053#issuecomment-1133884629" rel="nofollow" target="_blank" title=""&gt;但是他的 IP 这两年被 QT 给禁了，他就停止维护了。&lt;/a&gt;
&lt;a href="https://github.com/qtwebkit/.github/commit/e0415c754bf725411c4e147b8295a11cace33453" rel="nofollow" target="_blank" title=""&gt;他把自己的捐赠渠道也给拿下来了，&lt;/a&gt; 彻底不干了这是。
貌似也没有人接手，2 年没发版了&lt;/p&gt;

&lt;p&gt;这里也有一些讨论：&lt;a href="https://github.com/qutebrowser/qutebrowser/issues/4039" rel="nofollow" target="_blank"&gt;https://github.com/qutebrowser/qutebrowser/issues/4039&lt;/a&gt;
看起来大家不是已经迁移就是在迁移的路上了&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/mileszs/wicked_pdf/issues/1038#issuecomment-1329049323" rel="nofollow" target="_blank" title=""&gt;wkhtmltopdf 的 maintainer 也在 wicked_pdf 的一个 issue 里表示应该抛弃 wkhtmltopdf 了&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;至于替代品，我暂时只找到一个： &lt;a href="https://github.com/studiosity/grover" rel="nofollow" target="_blank"&gt;https://github.com/studiosity/grover&lt;/a&gt;&lt;/p&gt;</description>
      <author>wokenqingtian</author>
      <pubDate>Fri, 30 Dec 2022 01:16:39 +0800</pubDate>
      <link>https://ruby-china.org/topics/42813</link>
      <guid>https://ruby-china.org/topics/42813</guid>
    </item>
    <item>
      <title>我的论坛类 SideProject 但反响不好 求提点意见</title>
      <description>&lt;p&gt;&lt;a href="https://monthcamp.com" rel="nofollow" target="_blank" title=""&gt;MonthCamp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;做这个 Side Project 的起因是：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;不喜欢微信，Slack, Discord 每次打开几百上千的信息&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;ul&gt;
&lt;li&gt;把论坛变成一个个子群&lt;/li&gt;
&lt;li&gt;每个群 10 人最多&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;img src="https://l.ruby-china.com/photo/wokenqingtian/6c2351ed-35e6-4054-bdbf-a55892e6392d.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;去 Reddit 上发了下，没有激起半点波澜，还是有点伤心，自己还是很喜欢这个产品形态的，可是貌似没人来用。&lt;/p&gt;

&lt;p&gt;我自己有些后续的想法：&lt;/p&gt;

&lt;p&gt;也许我不该搞这种平台型的？换成 Discourse 那种模式貌似靠谱一点？&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;那样可以有独立域名，比如我其实只想搞个 Ruby 论坛而已？&lt;/li&gt;
&lt;li&gt;再把 MultiTenant 内容去掉代码开源出去？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;发出来望大家给我提点意见&lt;/p&gt;
&lt;h2 id="Updates"&gt;Updates&lt;/h2&gt;
&lt;p&gt;在吸收了这么多意见后，我又做了一次 UI/UX 的重构：&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/wokenqingtian/5f660497-a4b1-4c3a-be3a-0eeea367c231.png!large" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>wokenqingtian</author>
      <pubDate>Fri, 05 Nov 2021 20:53:51 +0800</pubDate>
      <link>https://ruby-china.org/topics/41853</link>
      <guid>https://ruby-china.org/topics/41853</guid>
    </item>
    <item>
      <title>SQL Float 计算 通过 ActiveRecord 获得的值在 MySQL 和 PostgreSQL 下不统一</title>
      <description>&lt;h3 id="第一次调查"&gt;第一次调查&lt;/h3&gt;
&lt;p&gt;在 Rails console 下跑的结果&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Under PostgreSQL&lt;/span&gt;
&lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT (ACOS(0.9999250668634809) * 6376.77271) as distance;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;
&lt;span class="c1"&gt;# =&amp;gt; 78.0648632113755&lt;/span&gt;

&lt;span class="c1"&gt;# Under MySQL&lt;/span&gt;
&lt;span class="no"&gt;ActiveRecord&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT (ACOS(0.9999250668634809) * 6376.77271) as distance;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;
&lt;span class="c1"&gt;# =&amp;gt; 78.06486321137547&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;在 DB console 下跑的结果&lt;/p&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="k"&gt;Under&lt;/span&gt; &lt;span class="n"&gt;PostgreSQL&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ACOS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9999250668634809&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;6376&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;77271&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;#=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;78&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;06486321137547&lt;/span&gt;

&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="k"&gt;Under&lt;/span&gt; &lt;span class="n"&gt;MySQL&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ACOS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9999250668634809&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;6376&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;77271&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;#=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;78&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;06486321137547&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;h4 id="System configuration:"&gt;System configuration:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Rails version: 5.2.2.1&lt;/li&gt;
&lt;li&gt;Ruby version: 2.4.4&lt;/li&gt;
&lt;li&gt;PostgreSQL version:  11.2 / 9.6&lt;/li&gt;
&lt;li&gt;MySQL version:  5.5.49&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="我的问题"&gt;我的问题&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;78.06486321137547&lt;/code&gt; 是我期望的结果，但是在 PostgreSQL 下通过 ActiveRecord 获得的却是&lt;code&gt;78.0648632113755&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;请问有没有办法让 ActiveRecord 在 PostgreSQL 下返回&lt;code&gt;78.06486321137547&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;=====================================================================================&lt;/p&gt;
&lt;h3 id="第二次调查"&gt;第二次调查&lt;/h3&gt;
&lt;p&gt;终于有时间做第二次调查，不过这次怎么也没办法复现上次 Rails Console 与 DB Console 不统一的情况，以下是我做的测试结果，一共获得了三个结果：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL 9.5, 10, 11 在 Linux/Mac 是统一的为 &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PostgreSQL 12 在 Mac 下是 &lt;code&gt;78.06486321137545&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PostgreSQL 12 在 Linux 下是 &lt;code&gt;78.06486321137547&lt;/code&gt; 且与 MySQL 的结果保持一致&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="具体测试数据:"&gt;具体测试数据：&lt;/h4&gt;&lt;h5 id="Postgres 9.5"&gt;Postgres 9.5&lt;/h5&gt;&lt;h6 id="PG Host on Docker"&gt;PG Host on Docker&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6 id="PG Host on Mac"&gt;PG Host on Mac&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="Postgres 10"&gt;Postgres 10&lt;/h5&gt;&lt;h6 id="PG Host on Docker"&gt;PG Host on Docker&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6 id="PG Host on Mac"&gt;PG Host on Mac&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="Postgres 11"&gt;Postgres 11&lt;/h5&gt;&lt;h6 id="PG Host on Docker"&gt;PG Host on Docker&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6 id="PG Host on Mac"&gt;PG Host on Mac&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.0648632113755&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="Postgres 12"&gt;Postgres 12&lt;/h5&gt;&lt;h6 id="PG Host on Docker"&gt;PG Host on Docker&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.06486321137547&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.06486321137547&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6 id="PG Host on Mac"&gt;PG Host on Mac&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;Rails console(host on Mac): &lt;code&gt;78.06486321137545&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB console: &lt;code&gt;78.06486321137545&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="第二次调查的问题"&gt;第二次调查的问题&lt;/h4&gt;
&lt;p&gt;其实由于第一次的问题没法复现，所以这次就没有啥问题了&lt;/p&gt;
&lt;h4 id="进一步调查为什么PostgreSQL 12 的值不一样"&gt;进一步调查为什么 PostgreSQL 12 的值不一样&lt;/h4&gt;
&lt;p&gt;发现 PotsgreSQL 12 的结果的 precision 多一位，就查了一下文档：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By default, floating point values are output in text form in their shortest precise decimal representation; the decimal value produced is closer to the true stored binary value than to any other value representable in the same binary precision. (However, the output value is currently never exactly midway between two representable values, in order to avoid a widespread bug where input routines do not properly respect the round-to-even rule.) This value will use at most 17 significant decimal digits for float8 values, and at most 9 digits for float4 values.&lt;/p&gt;

&lt;p&gt;For compatibility with output generated by older versions of PostgreSQL, and to allow the output precision to be reduced, the extra_float_digits parameter can be used to select rounded decimal output instead. Setting a value of 0 restores the previous default of rounding the value to 6 (for float4) or 15 (for float8) significant decimal digits. Setting a negative value reduces the number of digits further; for example -2 would round output to 4 or 13 digits respectively.&lt;/p&gt;

&lt;p&gt;-- PostgreSQL 12&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;而 PostgreSQL 11 下没有这些描述。
所以这可以算是 precision 的变化带来的不同，不过确正好在 LInux 下与 MySQL 有了一样的结果&lt;/p&gt;</description>
      <author>wokenqingtian</author>
      <pubDate>Tue, 25 Feb 2020 20:41:43 +0800</pubDate>
      <link>https://ruby-china.org/topics/39539</link>
      <guid>https://ruby-china.org/topics/39539</guid>
    </item>
  </channel>
</rss>
