<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>少华的博客</title>
      <link>https://blog.biofan.org</link>
      <description>轻风拂山岗</description>
      <generator>Zola</generator>
      <language>zh_CN</language>
      <atom:link href="https://blog.biofan.org/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Fri, 06 Sep 2024 07:05:17 +0800</lastBuildDate>
      <item>
          <title>Rust 中调用 Drop 的时机</title>
          <pubDate>Fri, 06 Sep 2024 07:05:17 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2024/09/rust-when-to-drop/</link>
          <guid>https://blog.biofan.org/2024/09/rust-when-to-drop/</guid>
          <description xml:base="https://blog.biofan.org/2024/09/rust-when-to-drop/">&lt;p&gt;&lt;code&gt;Drop&lt;&#x2F;code&gt; trait 在好些地方都有所提及, 但是它们的重点不太一样, 比如前文有介绍
&lt;a href=&quot;https:&#x2F;&#x2F;rust.biofan.org&#x2F;common-traits&#x2F;drop.html&quot;&gt;Drop trait&lt;&#x2F;a&gt; 的基本用法, 以及 &lt;a href=&quot;https:&#x2F;&#x2F;rust.biofan.org&#x2F;ownership&#x2F;move.html&quot;&gt;所有权转移&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;在这一节中, 我们重点介绍 &lt;code&gt;Drop&lt;&#x2F;code&gt; trait 被调用的时机.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>小米10S 手机的体验</title>
          <pubDate>Thu, 13 Jan 2022 21:01:51 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2022/01/mi10s-issues/</link>
          <guid>https://blog.biofan.org/2022/01/mi10s-issues/</guid>
          <description xml:base="https://blog.biofan.org/2022/01/mi10s-issues/">&lt;p&gt;最近一直想换个手机, 之前的 iPhone 用了四年多, 换了电池, 续航还算给力,
可是它的外放声音实在太小, 而且有时接听电话没有声音, 很不方便. 最大的问题还是信号差,
10 月份去北京出差办理入住时一直没有信号, 还是用了同事的热点才成功入住的, 很尴尬.&lt;&#x2F;p&gt;
&lt;p&gt;两天前换了小米 10S 这款手机, 体验了两天, 用起来太费心思.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>查看动态库的依赖关系树</title>
          <pubDate>Mon, 27 Dec 2021 11:07:44 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2021/12/lddtree/</link>
          <guid>https://blog.biofan.org/2021/12/lddtree/</guid>
          <description xml:base="https://blog.biofan.org/2021/12/lddtree/">&lt;p&gt;今天调试一个内存泄露的问题, 表现是在 amd64 的机器上进程正常退出, 而 arm64 上会出现
指针错误.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ .&#x2F;lithium https:&#x2F;&#x2F;bing.com
&lt;&#x2F;span&gt;&lt;span&gt;[1223&#x2F;105725.272479:INFO:command_line_ipc_client.cpp(58)] args item: .&#x2F;lithium
&lt;&#x2F;span&gt;&lt;span&gt;[1223&#x2F;105725.272716:INFO:command_line_ipc_client.cpp(58)] args item:&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; --disable-gpu
&lt;&#x2F;span&gt;&lt;span&gt;[1223&#x2F;105725.272742:INFO:command_line_ipc_client.cpp(58)] args item:&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; --enable-print-preview
&lt;&#x2F;span&gt;&lt;span&gt;[1223&#x2F;105725.272787:INFO:command_line_ipc_client.cpp(58)] args item: https:&#x2F;&#x2F;bing.com
&lt;&#x2F;span&gt;&lt;span&gt;[1223&#x2F;105725.272809:INFO:command_line_ipc_client.cpp(58)] args item:
&lt;&#x2F;span&gt;&lt;span&gt;Found existing runtime, exit now!
&lt;&#x2F;span&gt;&lt;span&gt;*** Error in `.&#x2F;lithium&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;#39;: free(): invalid pointer: 0x00000000402c2f30 ***
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里, 先用 gdb 追踪了一下, 发现在 main() 函数退出后, 执行全局对象的 dtor() 时出了问题.
单步执行来追查, 发现是 protobuf 库在析构时挂了.&lt;&#x2F;p&gt;
&lt;p&gt;之后, 又使用 valgrind 来确认, 同样定位到了相同的问题点:&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>处理小米电视的广告</title>
          <pubDate>Sat, 03 Oct 2020 22:05:14 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/10/xiaomi-ad/</link>
          <guid>https://blog.biofan.org/2020/10/xiaomi-ad/</guid>
          <description xml:base="https://blog.biofan.org/2020/10/xiaomi-ad/">&lt;p&gt;昨天终于回家了。&lt;&#x2F;p&gt;
&lt;p&gt;晚上家人看电视剧时，我发现每次切换一集，就会自动播放 &lt;code&gt;86&lt;&#x2F;code&gt; 秒左右的广告，无法跳过。
相当的坑，每集都这样。&lt;&#x2F;p&gt;
&lt;p&gt;吃了晚饭后，就开始折腾了，找了一些资料，发现确实是可以通过过滤小米服务器域名的
方式来跳过广告的。路由器上跑的 openwrt，这个功能自然很容易配置。&lt;&#x2F;p&gt;
&lt;p&gt;结合了之前的域名黑名单，生成的最终的配置文件是这个 &lt;a href=&quot;https:&#x2F;&#x2F;blog.biofan.org&#x2F;2020&#x2F;10&#x2F;xiaomi-ad&#x2F;dnsmasq.conf.add&quot;&gt;dnsmasq.conf.add&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>cargo sccache 缓存加速编译过程</title>
          <pubDate>Tue, 11 Aug 2020 22:04:32 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/08/cargo-sccache/</link>
          <guid>https://blog.biofan.org/2020/08/cargo-sccache/</guid>
          <description xml:base="https://blog.biofan.org/2020/08/cargo-sccache/">&lt;p&gt;默认情况下, cargo 在编译一个项目的第三方依赖时, 会缓存编译好的结果, 以便加速
之后编译速度.&lt;&#x2F;p&gt;
&lt;p&gt;但是, 对于跨工作区(workspace)的项目来说, 并不能很好地缓存这些第三方库编译后生成的
文件; 为此, mozilla 组织开发了 &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;mozilla&#x2F;sccache&quot;&gt;sccache&lt;&#x2F;a&gt; 项目.&lt;&#x2F;p&gt;
&lt;p&gt;安装它也很简单, 分两步. 第一步在终端安装它:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ cargo install sccache
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>netstat 常用命令</title>
          <pubDate>Thu, 07 May 2020 23:36:34 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/05/netstat/</link>
          <guid>https://blog.biofan.org/2020/05/netstat/</guid>
          <description xml:base="https://blog.biofan.org/2020/05/netstat/">&lt;p&gt;&lt;code&gt;netstat&lt;&#x2F;code&gt; 作为调试网络问题的必备工具, 有些常用选项, 在这里记录一下.&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;显示路由表: &lt;code&gt;netstat -r&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;显示所有连接: &lt;code&gt;netstat -a&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;显示所有 &lt;code&gt;TCP&lt;&#x2F;code&gt; 连接: &lt;code&gt;netstat -at&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;显示所有 &lt;code&gt;UDP&lt;&#x2F;code&gt; 连接: &lt;code&gt;netstat -au&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;显示所有的 &lt;code&gt;TCP&lt;&#x2F;code&gt; 监听服务: &lt;code&gt;netstat -lt&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;列举网络接口: &lt;code&gt;netstat -ie&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;最常用选项: &lt;code&gt;netstat -plent&lt;&#x2F;code&gt; 显示本地 &lt;code&gt;TCP&lt;&#x2F;code&gt; 监听服务及其对应的进程信息&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</description>
      </item>
      <item>
          <title>Rust 语言受限的地方</title>
          <pubDate>Sat, 18 Apr 2020 10:03:20 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/04/rust-issues/</link>
          <guid>https://blog.biofan.org/2020/04/rust-issues/</guid>
          <description xml:base="https://blog.biofan.org/2020/04/rust-issues/">&lt;p&gt;最近半年陆续写了很多的 Rust 代码，跟别的语言相比，它有些地方还是蛮受限的，在表达
一个功能时需要各种弯弯绕，下面就列举几个方面的问题。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;struct-union-bu-zhi-chi-qian-tao&quot;&gt;struct&#x2F;union 不支持嵌套&lt;&#x2F;h2&gt;
&lt;p&gt;类型嵌套可以将关联的数据结构放在一起，这个在C语言里是很常用的。像内核提供的系统
调用，比如 &lt;code&gt;bpf()&lt;&#x2F;code&gt; 以及 &lt;code&gt;io_uring_setup()&lt;&#x2F;code&gt;，都有大量的使用。它们都是定义了一堆的
操作指令（operation-code, op-code），以及一个公用的 &lt;code&gt;union&lt;&#x2F;code&gt; 联合体，跟据不同的
操作指令来解析 &lt;code&gt;union&lt;&#x2F;code&gt; 为不同的结构。尤其是 &lt;code&gt;bpf()&lt;&#x2F;code&gt; 系统调用，使用一个接口就实现了
内核 &lt;code&gt;BPF&lt;&#x2F;code&gt; 虚拟机的所有操作，相当的强大和复杂。&lt;&#x2F;p&gt;
&lt;p&gt;在使用Rust为类似这样的 &lt;code&gt;C&lt;&#x2F;code&gt; 接口做绑定时，会很麻烦。需要先将嵌套的结构体以及 &lt;code&gt;union&lt;&#x2F;code&gt;
联合体拆成独立的片段，然后再依次组装到一起，这样写的代码，其可读性并不好，也更难
维护。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>重新编译 linux 内核，开启 btf</title>
          <pubDate>Wed, 15 Apr 2020 18:13:21 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/04/linux-btf/</link>
          <guid>https://blog.biofan.org/2020/04/linux-btf/</guid>
          <description xml:base="https://blog.biofan.org/2020/04/linux-btf/">&lt;p&gt;默认的 archlinux 内核包并不包含对 BTF(BPF Type Format) 的支持，需要我们手动开启，&lt;&#x2F;p&gt;
&lt;p&gt;目前的内核版本是 &lt;code&gt;5.6.4&lt;&#x2F;code&gt;，我们使用 &lt;code&gt;yaourt&lt;&#x2F;code&gt; 来安装。&lt;&#x2F;p&gt;
&lt;p&gt;首先是安装 &lt;code&gt;pahole&lt;&#x2F;code&gt; 这个依赖包：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;yaourt&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -S&lt;&#x2F;span&gt;&lt;span&gt; pahole
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;目前的 &lt;code&gt;pahole&lt;&#x2F;code&gt; 版本要依赖 &lt;code&gt;libebl&lt;&#x2F;code&gt; 库，而这个库并不是必需的，可以给它创建一个
软链接指向 &lt;code&gt;libelf.so&lt;&#x2F;code&gt; 即可。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>cargo-update：更新 rust 二进制程序</title>
          <pubDate>Sun, 12 Apr 2020 21:10:39 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/04/cargo-update/</link>
          <guid>https://blog.biofan.org/2020/04/cargo-update/</guid>
          <description xml:base="https://blog.biofan.org/2020/04/cargo-update/">&lt;p&gt;使用 &lt;code&gt;cargo install&lt;&#x2F;code&gt; 安装了一些 rust 工具到本地后，如果再想着要更新它们时，需要
手动一个个更新，比较麻烦。可以使用 &lt;code&gt;cargo-update&lt;&#x2F;code&gt; 这个工具来批量更新。&lt;&#x2F;p&gt;
&lt;p&gt;首先把它安装到系统里：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ cargo install cargo-update
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;之后就可以尝试着更新本地的可执行文件了：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ cargo install-update&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; --all
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>下载 deb 安装包及其依赖包</title>
          <pubDate>Fri, 10 Apr 2020 12:33:43 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/04/apt-download/</link>
          <guid>https://blog.biofan.org/2020/04/apt-download/</guid>
          <description xml:base="https://blog.biofan.org/2020/04/apt-download/">&lt;p&gt;这两天要为离线的 arm 服务器安装几个 deb 包，因为这些包都有许多上游的依赖包，得
一起把它们下载到本地。&lt;&#x2F;p&gt;
&lt;p&gt;这里以 ubuntu 18.04 (bionic) 为例，下载 arm64 架构的几个包。&lt;&#x2F;p&gt;
&lt;p&gt;首先就是配置安装源，因为本地环境不是 ubuntu，需要先搞一个 ubuntu 的环境，可以
考虑使用 docker 或者 debootstrap。这里选择使用后者，操作起来要更简单。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;pei-zhi-ubuntu-18-04-amd64-huan-jing&quot;&gt;配置 ubuntu 18.04 amd64 环境&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;sudo debootstrap bionic rootfs http:&#x2F;&#x2F;mirrors.aliyun.com&#x2F;ubuntu
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里用的是阿里云的安装源，系统目录位于 &lt;code&gt;rootfs&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>ssh 端口转发</title>
          <pubDate>Tue, 31 Mar 2020 19:42:24 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/03/ssh-proxy/</link>
          <guid>https://blog.biofan.org/2020/03/ssh-proxy/</guid>
          <description xml:base="https://blog.biofan.org/2020/03/ssh-proxy/">&lt;p&gt;有时需要临时在本地访问一下服务器上的未公开访问权限的服务，可以用 ssh 将此服务的
端口重映射到本地。使用起来也很简单，比如之前常用的 &lt;code&gt;X11Forward&lt;&#x2F;code&gt; 类似实现的。&lt;&#x2F;p&gt;
&lt;p&gt;下面以访问服务器的 &lt;code&gt;127.0.0.1:8080&lt;&#x2F;code&gt; web 服务为例说明：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;ssh&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span&gt; 22&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -v -N -L&lt;&#x2F;span&gt;&lt;span&gt; 0.0.0.0:8080:127.0.0.1:8080 user@example.com
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;以上命令即可将服务器上 &lt;code&gt;8080&lt;&#x2F;code&gt; 端口的服务映射到本地网络。其中各个参数的意义是：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-p 22&lt;&#x2F;code&gt; 为服务器上的 &lt;code&gt;sshd&lt;&#x2F;code&gt; 服务的端口号，默认是&lt;code&gt;22&lt;&#x2F;code&gt;，可以略去这个选项&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-v&lt;&#x2F;code&gt; 交互式模式，会打印一些日志到终端里；可以略去&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-N&lt;&#x2F;code&gt; 表示不在服务器端执行命令，这样就不会打开服务器上的远程终端；可以略去&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-L 0.0.0.0:8080:127.0.0.1:8080&lt;&#x2F;code&gt; 将服务器上的 &lt;code&gt;8080&lt;&#x2F;code&gt; 映射到本地的 &lt;code&gt;8080&lt;&#x2F;code&gt; 端口&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;user@example.com&lt;&#x2F;code&gt; 是 &lt;code&gt;ssh&lt;&#x2F;code&gt; 服务的用户名及服务器地址&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;之后就可以在本机浏览器里面访问 &lt;code&gt;http:&#x2F;&#x2F;127.0.0.1:8080&lt;&#x2F;code&gt; 地址了。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>运行 gitk 时提示缺少 wish 命令</title>
          <pubDate>Tue, 24 Mar 2020 23:52:00 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/03/gitk-wish/</link>
          <guid>https://blog.biofan.org/2020/03/gitk-wish/</guid>
          <description xml:base="https://blog.biofan.org/2020/03/gitk-wish/">&lt;p&gt;gitk 命令可以方便地查看 git 仓库中某个文件的更改历史。&lt;&#x2F;p&gt;
&lt;p&gt;但是 archlinux 平台上运行这个命令时却提示如下错误：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;&#x2F;usr&#x2F;sbin&#x2F;gitk: line 3: exec: wish: not found
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;查了一下， 发现是没有安装 &lt;code&gt;tk&lt;&#x2F;code&gt; 工具包，手动安装它即可：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;sudo pacman&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -S&lt;&#x2F;span&gt;&lt;span&gt; tk
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这个问题蛮早就有人反馈给上游了，目前还没有把它加到包依赖列表里。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>gcc 编译选项</title>
          <pubDate>Sat, 25 Jan 2020 23:52:44 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/01/gcc-compile-flags/</link>
          <guid>https://blog.biofan.org/2020/01/gcc-compile-flags/</guid>
          <description xml:base="https://blog.biofan.org/2020/01/gcc-compile-flags/">&lt;p&gt;最近常用的 GCC 编译选项:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;g++&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -std&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;c++14&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -Wall -Wextra -Werror -Wfatal-error -pedantic-error
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;其中:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-std=c++14&lt;&#x2F;code&gt;, 使用 C++14 的标准&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-Wall&lt;&#x2F;code&gt;, 打开大多数编译警告选项&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-Wextra&lt;&#x2F;code&gt;, 打开额外的编译警告选项&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-Werror&lt;&#x2F;code&gt;, 将编译警告转为编译报错，进而退出编译过程&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;-pedantic-error&lt;&#x2F;code&gt;, 如果有违背 ISO C++ 标准, 有使用了语言扩展, 旧的语言特性等情况时, 都会报错&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>Rust 中检查是大端还是小端</title>
          <pubDate>Wed, 01 Jan 2020 16:29:32 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2020/01/rust-byte-order/</link>
          <guid>https://blog.biofan.org/2020/01/rust-byte-order/</guid>
          <description xml:base="https://blog.biofan.org/2020/01/rust-byte-order/">&lt;p&gt;在网络编程时，需要将 &lt;code&gt;host byte order&lt;&#x2F;code&gt; 转为 &lt;code&gt;network byte order&lt;&#x2F;code&gt;。
rust 本身支持在编译期检查当前的编译工具链是大端还是小端，如下所示：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;is_little_endian&lt;&#x2F;span&gt;&lt;span&gt;() -&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;bool &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;  cfg!(target_endian &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;little&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;当然，也有方法可以在运行期进行检查，这里我们使用 &lt;code&gt;union&lt;&#x2F;code&gt; 类型，为了方便。&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;is_little_endian&lt;&#x2F;span&gt;&lt;span&gt;() -&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;bool &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    union Check {
&lt;&#x2F;span&gt;&lt;span&gt;        l: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;u16&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        s: [&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;u8&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;],
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;unsafe &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; c &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; Check { l: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;0x0102 &lt;&#x2F;span&gt;&lt;span&gt;};
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;return&lt;&#x2F;span&gt;&lt;span&gt; c.s[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;== &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;但要注意的是直接访问 &lt;code&gt;union&lt;&#x2F;code&gt; 中的内部元素是 &lt;code&gt;unsafe&lt;&#x2F;code&gt; 的。&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>chroot 时做了什么</title>
          <pubDate>Tue, 31 Dec 2019 23:18:59 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/12/chroot/</link>
          <guid>https://blog.biofan.org/2019/12/chroot/</guid>
          <description xml:base="https://blog.biofan.org/2019/12/chroot/">&lt;p&gt;debian 社区，大都使用 chroot 环境做一些干净的编译打包操作，之前手动安装 debian
和 archlinux 系统时，也有在使用 chroot。但并不了解 chroot 时，系统究竟发生了什么。
在 2019 年最后一天，找时间看了下内核代码，才了解到里面的操作。&lt;&#x2F;p&gt;
&lt;p&gt;先说结论：chroot 改变当前进程所在的内核空间的一个叫做 &lt;code&gt;current-&amp;gt;root&lt;&#x2F;code&gt; 的全局变量，
之后该进程所有的文件系统操作的路径，都以新的 &lt;code&gt;path&lt;&#x2F;code&gt; 作为根目录。&lt;&#x2F;p&gt;
&lt;p&gt;首先看 &lt;code&gt;fs&#x2F;open.c&lt;&#x2F;code&gt; 中实现的 &lt;code&gt;ksys_chroot()&lt;&#x2F;code&gt; 系统调用：&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>通过 USB 2 TTL 串口线连接树莓派4</title>
          <pubDate>Sat, 28 Dec 2019 11:18:29 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/12/pi4-serial/</link>
          <guid>https://blog.biofan.org/2019/12/pi4-serial/</guid>
          <description xml:base="https://blog.biofan.org/2019/12/pi4-serial/">&lt;p&gt;刚好手边有 USB转 TTL 的串口线，不需要再通过 ssh 连接树莓派了。&lt;&#x2F;p&gt;
&lt;p&gt;首先就是串口线的接法，大致如下图：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;span&gt;USB_5V  &amp;lt;--&amp;gt; PI4外侧串口第一个口(5V)
&lt;&#x2F;span&gt;&lt;span&gt;USB_GND &amp;lt;--&amp;gt; PI4外侧串口第三个口(GND)
&lt;&#x2F;span&gt;&lt;span&gt;USB_RX &amp;lt;--&amp;gt; PI4外侧串口第四个口(GPIO14)
&lt;&#x2F;span&gt;&lt;span&gt;USB_TX &amp;lt;--&amp;gt; PI4外侧串口第五个口(GPIO15)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;接好线之后，给树莓派供电，此时在电脑里面查看一下是否有串口设备：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ ls &#x2F;dev&#x2F;ttyUSB&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;*
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里有找到 &lt;code&gt;&#x2F;dev&#x2F;ttyUSB0&lt;&#x2F;code&gt; 设备。&lt;&#x2F;p&gt;
&lt;p&gt;使用 &lt;code&gt;lsusb&lt;&#x2F;code&gt; 命令查看一下：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
&lt;&#x2F;span&gt;&lt;span&gt;Bus 003 Device 002: ID 1358:c123 Realtek  Bluetooth Radio
&lt;&#x2F;span&gt;&lt;span&gt;Bus 003 Device 006: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
&lt;&#x2F;span&gt;&lt;span&gt;Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
&lt;&#x2F;span&gt;&lt;span&gt;Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
&lt;&#x2F;span&gt;&lt;span&gt;Bus 001 Device 003: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
&lt;&#x2F;span&gt;&lt;span&gt;Bus 001 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
&lt;&#x2F;span&gt;&lt;span&gt;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里显示的 &lt;code&gt;HL-340 USB-Serial adapter&lt;&#x2F;code&gt; 就是我们的 USB 串口连接器。
也可以在 `dmesg｀ 里面找到内核打印信息。&lt;&#x2F;p&gt;
&lt;p&gt;在电脑上安装串口工具，常用的是 &lt;code&gt;minicom&lt;&#x2F;code&gt;：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ sudo apt install minicom
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>pi4 配置无线网连接</title>
          <pubDate>Sat, 28 Dec 2019 10:58:41 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/12/pi4-headless/</link>
          <guid>https://blog.biofan.org/2019/12/pi4-headless/</guid>
          <description xml:base="https://blog.biofan.org/2019/12/pi4-headless/">&lt;p&gt;手边没有可用的显示器，在配置树莓派 4 的时候，只能选择使用 headless 模式了。
但配置也比较简单，分以下几步。&lt;&#x2F;p&gt;
&lt;p&gt;将包含 pi4 raspbian 系统的 TF 卡连接到电脑上，有两个可用的分区，只需要在 boot 分区中操作。&lt;&#x2F;p&gt;
&lt;p&gt;首先创建一个空白的名为 &lt;code&gt;ssh&lt;&#x2F;code&gt; 的文件，用于开启 ssh 服务。&lt;&#x2F;p&gt;
&lt;p&gt;其次在 boot 分区创建 &lt;code&gt;wpa_supplicant.conf&lt;&#x2F;code&gt; 文件，用于设置无线网络连接信息，示例如下：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;conf&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-conf &quot;&gt;&lt;code class=&quot;language-conf&quot; data-lang=&quot;conf&quot;&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;ctrl_interface&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;DIR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;var&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;wpa_supplicant &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;GROUP&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;netdev
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;update_config&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;1
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;country&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;CN
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;network&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;ssid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;YOUR_SSID&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;psk&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;SSID_PASSWORD&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>honor magicbook 2019 pro 的问题</title>
          <pubDate>Sat, 14 Dec 2019 17:56:52 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/12/honor-magicbook-2019-pro/</link>
          <guid>https://blog.biofan.org/2019/12/honor-magicbook-2019-pro/</guid>
          <description xml:base="https://blog.biofan.org/2019/12/honor-magicbook-2019-pro/">&lt;p&gt;十月份买了个华为新出的 Honor MagicBook Pro 笔记本, 有16寸显示屏, 使用
AMD Ryzen 3500H CPU, 性能还是很棒的.&lt;&#x2F;p&gt;
&lt;p&gt;但是, 经过这两个月的使用, 发现这笔记本有多个问题.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;mai-ke-feng-rong-yi-jin-hui&quot;&gt;麦克风容易进灰&lt;&#x2F;h2&gt;
&lt;p&gt;它的麦克风位于 C 面, 键盘的左右两侧. 外放的声音比 iPhone 8 Plus 的效果要差.
另外, 我用的是银色机身, 麦克风的过滤网是黑色的. 这个位置安置过滤网, 很容易进灰,
而且难以清理, 黑色的非常明显, 有强迫症的话就难以接受了, 日常情况都是有些积灰的.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>rust 中 string 与其它类型间的互转</title>
          <pubDate>Sun, 13 Oct 2019 19:38:39 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/10/rust-string-convertion/</link>
          <guid>https://blog.biofan.org/2019/10/rust-string-convertion/</guid>
          <description xml:base="https://blog.biofan.org/2019/10/rust-string-convertion/">&lt;p&gt;Rust 中经常用到的字符串与其它数据类型之间的转换, 可以通过其它类型实现几个预定义的
Trait 来完成.&lt;&#x2F;p&gt;
&lt;p&gt;其中, 包括:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;std::str::FromStr&lt;&#x2F;code&gt;, 用于从字符串转为指定的类型, 提供了 &lt;code&gt;parse()&lt;&#x2F;code&gt; 方法&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;std::string::ToString&lt;&#x2F;code&gt;, 用于将将指定的类型转为字符串, 提供了 &lt;code&gt;to_string()&lt;&#x2F;code&gt; 方法&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;在标准库中, 已经实现了基本数据类型(比如bool, i32, u64, f64等)与字符串之间的互转,
举例:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; i &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;42&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;.parse::&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;();
&lt;&#x2F;span&gt;&lt;span&gt;assert_eq!(i, &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;Ok&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;42&lt;&#x2F;span&gt;&lt;span&gt;));
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;以及:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; s &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;3.14&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;to_string&lt;&#x2F;span&gt;&lt;span&gt;();
&lt;&#x2F;span&gt;&lt;span&gt;assert_eq!(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;3.14&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;, s);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;下面以 &lt;code&gt;struct Color&lt;&#x2F;code&gt; 为例, 说明一下如何为自定义的类型实现以上两个 Traits.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>cmake 基本设置</title>
          <pubDate>Sun, 13 Oct 2019 14:30:30 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/10/cmake-basic/</link>
          <guid>https://blog.biofan.org/2019/10/cmake-basic/</guid>
          <description xml:base="https://blog.biofan.org/2019/10/cmake-basic/">&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;&lt;h2 id=&quot;yi-ban-ke-zhi-xing-wen-jian-de-she-zhi&quot;&gt;一般可执行文件的设置&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;cmake&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-cmake &quot;&gt;&lt;code class=&quot;language-cmake&quot; data-lang=&quot;cmake&quot;&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;project&lt;&#x2F;span&gt;&lt;span&gt;(demo)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;cmake_minimum_required&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;VERSION &lt;&#x2F;span&gt;&lt;span&gt;3.0)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 开启 make verbose 模式, 也可以用 `make VERBOSE=1`
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_VERBOSE_MAKEFILE ON)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 指定编译器, 通常在编译时才指定.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;#set(CMAKE_C_COMPILER  &#x2F;usr&#x2F;bin&#x2F;clang)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;#set(CMAKE_CXX_COMPILER  &#x2F;usr&#x2F;bin&#x2F;clang++)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 设置 c&#x2F;c++ 版本, 可以考虑使用 c++14
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_CXX_STANDARD 11)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_C_STANDARD 11)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_C_STANDARD_REQUIRED ON)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 默认使用 Release 模式, 只有显示指定 Debug 模式时才编译 debug 版本
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_CONFIGURATION_TYPES Debug Release)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;NOT &lt;&#x2F;span&gt;&lt;span&gt;CMAKE_BUILD_TYPE)
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_BUILD_TYPE Release)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;endif&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 分别设置 Debug 模式和 Release 模式不同的编译器选项
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_BUILD_TYPE &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;MATCHES &lt;&#x2F;span&gt;&lt;span&gt;Debug)
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_C_FLAGS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;${CMAKE_C_FLAGS} -g -Wall -Werror -Wextra&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -fno-rtti, Disable real-time type information
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -fno-exceptions Disable exceptions
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -fsanitize=address Enable memory sanitize plugin
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_CXX_FLAGS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;${CMAKE_CXX_FLAGS} -g -Wall -Werror -Wextra -fno-exceptions&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -fsanitize=address, Enable memory address sanitizer.
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_CXX_FLAGS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;${CMAKE_CXX_FLAGS} -fsanitize=address&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -fsanitize=leak, Enable memory leak sanitizer.
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# set(CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} -fsanitize=leak&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -fsanitize=memory, Enable detecting uninitited memory sanitizer.
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# set(CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} -fsanitize=memory&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_CXX_FLAGS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;${CMAKE_CXX_FLAGS} -fsanitize-memory-track-origins \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;      -fPIC -pie -fno-omit-frame-pointer&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# set(CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough=1&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;else&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# -Wl, -O2 Enable linker optimizations
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;#-Wl, --gc-sections Remove unused code resulting from -fdsta-sections and -ffunction-sections
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_C_FLAGS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;${CMAKE_C_FLAGS} -Wall -O2 -Wl,-O1 -Wl,--gc-sections&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_CXX_FLAGS &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;${CMAKE_CXX_FLAGS} -Wall -O2 -Wl,-O1 -Wl,--gc-sections -Wno-unused-result&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;endif&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 修改 LD_LIBRARY_PATH, 编译时会把 `-Wl,-rpath,&#x2F;tmp&#x2F;add&#x2F;lib` 传给编译器.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 优先级比较高, 会先查找这样指定的目录, 再找系统目录.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;LINK_DIRECTORIES&lt;&#x2F;span&gt;&lt;span&gt;(&#x2F;tmp&#x2F;add&#x2F;lib)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 编译时会把 `-I&#x2F;tmp&#x2F;add&#x2F;include` 传给编译器. 优先级高.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;INCLUDE_DIRECTORIES&lt;&#x2F;span&gt;&lt;span&gt;(&#x2F;tmp&#x2F;add&#x2F;include)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;add_executable&lt;&#x2F;span&gt;&lt;span&gt;(demo main.c)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;target_link_libraries&lt;&#x2F;span&gt;&lt;span&gt;(demo add)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;ku-de-she-zhi&quot;&gt;库的设置&lt;&#x2F;h2&gt;
&lt;p&gt;以下以 &lt;code&gt;libadd&lt;&#x2F;code&gt; 为例:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;cmake&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-cmake &quot;&gt;&lt;code class=&quot;language-cmake&quot; data-lang=&quot;cmake&quot;&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;project&lt;&#x2F;span&gt;&lt;span&gt;(add)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;cmake_minimum_required&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;VERSION &lt;&#x2F;span&gt;&lt;span&gt;3.0)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(CMAKE_INCLUDE_CURRENT_DIR ON)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 通常先定义一下库的版本号.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(ADD_VERSION_MAJOR 0)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(ADD_VERSION_MINOR 1)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(ADD_VERSION_PATCH 3)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span&gt;(ADD_VERSION_STRING
&lt;&#x2F;span&gt;&lt;span&gt;    ${ADD_VERSION_MAJOR}.${ADD_VERSION_MINOR}.${ADD_VERSION_PATCH})
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 定义静态库
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;add_library&lt;&#x2F;span&gt;&lt;span&gt;(add_static &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;STATIC &lt;&#x2F;span&gt;&lt;span&gt;add.c)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 修改生成的 .a 文件的名称
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set_target_properties&lt;&#x2F;span&gt;&lt;span&gt;(add_static &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;PROPERTIES
&lt;&#x2F;span&gt;&lt;span&gt;    OUTPUT_NAME &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;add&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 定义动态库
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;add_library&lt;&#x2F;span&gt;&lt;span&gt;(add_shared &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;SHARED &lt;&#x2F;span&gt;&lt;span&gt;add.c)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 设置动态库的库文件名, 以及 so 版本号
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 这里可以不指定 public header, 而是单独为头文件创建一个 `install target`
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;set_target_properties&lt;&#x2F;span&gt;&lt;span&gt;(add_shared &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;PROPERTIES
&lt;&#x2F;span&gt;&lt;span&gt;    VERSION ${ADD_VERSION_STRING}
&lt;&#x2F;span&gt;&lt;span&gt;    SOVERSION ${ADD_VERSION_MAJOR}
&lt;&#x2F;span&gt;&lt;span&gt;    PUBLIC_HEADER add.h
&lt;&#x2F;span&gt;&lt;span&gt;    OUTPUT_NAME &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;add&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 设置动态库的安装目录
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;INSTALL&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;TARGETS &lt;&#x2F;span&gt;&lt;span&gt;add_shared
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;LIBRARY DESTINATION &lt;&#x2F;span&gt;&lt;span&gt;&#x2F;tmp&#x2F;add&#x2F;lib
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;PUBLIC_HEADER DESTINATION &lt;&#x2F;span&gt;&lt;span&gt;&#x2F;tmp&#x2F;add&#x2F;include)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#75715e;&quot;&gt;# 设置静态库的安装目录
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;INSTALL&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;TARGETS &lt;&#x2F;span&gt;&lt;span&gt;add_static
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;DESTINATION &lt;&#x2F;span&gt;&lt;span&gt;&#x2F;tmp&#x2F;add&#x2F;lib)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>windows 系统中配置 rust 环境</title>
          <pubDate>Sat, 05 Oct 2019 17:50:04 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/10/rust-windows/</link>
          <guid>https://blog.biofan.org/2019/10/rust-windows/</guid>
          <description xml:base="https://blog.biofan.org/2019/10/rust-windows/">&lt;p&gt;与 linux 系统相比, 在 widnows 系统中设置 rust 开发环境要麻烦一些.
需要手动额外安装几个软件包.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;C++ build tools for Visual Studio&lt;&#x2F;li&gt;
&lt;li&gt;git (可选)&lt;&#x2F;li&gt;
&lt;li&gt;.Net Framework (&amp;gt;= 4.5)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>处理一个 socket: too many open files 问题</title>
          <pubDate>Thu, 19 Sep 2019 11:14:04 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/09/go-http-client/</link>
          <guid>https://blog.biofan.org/2019/09/go-http-client/</guid>
          <description xml:base="https://blog.biofan.org/2019/09/go-http-client/">&lt;p&gt;大概情况是这样的, 前几天做完离职交接, 今天看到前公司的微信群里消息爆炸了, 用户
无法在微信小程序中下单. 接手后端项目的小胖已经重启了数据库(不晓得他为啥一进服务器
就先把数据库重启了), 说还是不行.&lt;&#x2F;p&gt;
&lt;p&gt;后来另一位同事重启了 &lt;code&gt;consumer&lt;&#x2F;code&gt; 服务, 然后服务就恢复了.&lt;&#x2F;p&gt;
&lt;p&gt;查看了 docker log, 发现了一个 ``dial tcp 127.0.0.1:8202: socket: too many open files 的问题,
但是请求的 http server 也是布署在同一台服务器上, 它们也共享了同一个 docker network, 通常是
不会出现这个问题的, 之后就猜到可能是因为本地的 TCP 端口号被占完了, 或者分配给该进程
的文件句柄数被用光了, http client 无法再发起新的 socket 连接导致的.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>C++ 中的 string slice</title>
          <pubDate>Sat, 07 Sep 2019 23:17:37 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/09/cpp-string-slice/</link>
          <guid>https://blog.biofan.org/2019/09/cpp-string-slice/</guid>
          <description xml:base="https://blog.biofan.org/2019/09/cpp-string-slice/">&lt;p&gt;最近在读 &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;llvm-mirror&#x2F;llvm&#x2F;blob&#x2F;master&#x2F;include&#x2F;llvm&#x2F;ADT&#x2F;StringRef.h&quot;&gt;LLVM&lt;&#x2F;a&gt; 的代码, 发现了它里面也实现了 string slice 字符串引用的功能.&lt;&#x2F;p&gt;
&lt;p&gt;在之前, 已经在 &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;leveldb&#x2F;blob&#x2F;master&#x2F;include&#x2F;leveldb&#x2F;slice.h&quot;&gt;leveldb&lt;&#x2F;a&gt; 以及 &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;re2&#x2F;blob&#x2F;master&#x2F;re2&#x2F;stringpiece.h&quot;&gt;re2&lt;&#x2F;a&gt; 中见过类似的实现, 当然, 类似的
功能在 &lt;a href=&quot;https:&#x2F;&#x2F;cs.chromium.org&#x2F;chromium&#x2F;src&#x2F;base&#x2F;strings&#x2F;string_piece.h&quot;&gt;chromium&lt;&#x2F;a&gt; 的代码中有更复制的实现.&lt;&#x2F;p&gt;
&lt;p&gt;之所以这些开源软件中要独立实现一套 string slice, 我觉得有这几个原因:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;cpp 中要支持 &lt;code&gt;std::string&lt;&#x2F;code&gt; 以及 &lt;code&gt;const char*&lt;&#x2F;code&gt; 这两种字符串类型, 而这两种类型实现的
某些操作方法, 并不一致&lt;&#x2F;li&gt;
&lt;li&gt;标准库中的 字符串类型缺少一些功能&lt;&#x2F;li&gt;
&lt;li&gt;作为值传递时, 尽可能减少内存复制&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>安装 FreeBSD</title>
          <pubDate>Fri, 06 Sep 2019 09:04:52 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/09/install-freebsd/</link>
          <guid>https://blog.biofan.org/2019/09/install-freebsd/</guid>
          <description xml:base="https://blog.biofan.org/2019/09/install-freebsd/">&lt;p&gt;最近因为 &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;xushaohua&#x2F;nc&quot;&gt;nc&lt;&#x2F;a&gt; 项目, 需要安装多种系统, 直接装在虚拟机里是个不错的选择.
这篇文章就简单记录一下安装和使用 FreeBSD 的一些操作.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Linux 系统代理设置</title>
          <pubDate>Wed, 28 Aug 2019 09:01:55 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/linux-proxy/</link>
          <guid>https://blog.biofan.org/2019/08/linux-proxy/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/linux-proxy/">&lt;p&gt;目前 linux 终端里经常要下载一些东西, 比如:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;git clone 一些内部的项目代码&lt;&#x2F;li&gt;
&lt;li&gt;go dep 下载一些第三方模块&lt;&#x2F;li&gt;
&lt;li&gt;depot_tools 下载谷歌官方的项目&lt;&#x2F;li&gt;
&lt;li&gt;cargo 更新包依赖&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;这些情况, 有部分网站是无法直连的, 还有一些即使边得上, 速度也很差.
针对这些应用, 我们可以设置一下终端里的代理环境, 使用 VPS 上布署的
中转服务器加速请求.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>使用 multiarch 运行其它架构的程序</title>
          <pubDate>Mon, 26 Aug 2019 15:30:40 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/debian-multiarch/</link>
          <guid>https://blog.biofan.org/2019/08/debian-multiarch/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/debian-multiarch/">&lt;p&gt;Debian 提供的 &lt;code&gt;multiarch&lt;&#x2F;code&gt; 功能对于调试跨架构的应用来说非常方便.
尽管 &lt;code&gt;multiarch&lt;&#x2F;code&gt; 常用于在 &lt;code&gt;x86_64&lt;&#x2F;code&gt; 的系统里面运行 &lt;code&gt;x86&lt;&#x2F;code&gt; 的程序.&lt;&#x2F;p&gt;
&lt;p&gt;以下操作以在 &lt;code&gt;x86_64&lt;&#x2F;code&gt; 的系统里面编译并运行 &lt;code&gt;arm64&lt;&#x2F;code&gt; 的应用为示例来演示一下 &lt;code&gt;multiarch&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-zhuang-jiao-cha-bian-yi-de-gong-ju-lian&quot;&gt;安装交叉编译的工具链&lt;&#x2F;h2&gt;
&lt;p&gt;apt 仓库里面提供了多个架构的 gcc 工具链, 如果编译 arm64 平台的, 可以安装:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ sudo apt install gcc-aarch64-linux-gnu
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;该工具包提供了包括编译器和链接器等:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcc
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcc-ar
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcc-nm
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcc-ranlib
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcov
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcov-dump
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;bin&#x2F;aarch64-linux-gnu-gcov-tool
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>降级 Debian 系统</title>
          <pubDate>Sat, 24 Aug 2019 17:50:46 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/downgrade-debian/</link>
          <guid>https://blog.biofan.org/2019/08/downgrade-debian/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/downgrade-debian/">&lt;p&gt;之前 NAS 服务器用的是 &lt;code&gt;unstable&lt;&#x2F;code&gt; 版的 debian 系统, 最近系统频繁更新, 比较麻烦,
正好 &lt;code&gt;debian 10 - buster&lt;&#x2F;code&gt; 也发正式版了, 就想着换成这个版本.&lt;&#x2F;p&gt;
&lt;p&gt;但是现在服务器上面跑着好几个服务, 不打算重新装系统, 就尝试着把 &lt;code&gt;unstable&lt;&#x2F;code&gt; 版本
降级为 &lt;code&gt;buster&lt;&#x2F;code&gt; 这个 &lt;code&gt;stable&lt;&#x2F;code&gt; 版.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;geng-gai-apt-yuan&quot;&gt;更改 apt 源&lt;&#x2F;h2&gt;
&lt;p&gt;之前的源列表是:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;conf&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-conf &quot;&gt;&lt;code class=&quot;language-conf&quot; data-lang=&quot;conf&quot;&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;deb &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;http:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;debian&lt;&#x2F;span&gt;&lt;span&gt; sid main contrib non&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;free
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;deb-src &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;http:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;debian&lt;&#x2F;span&gt;&lt;span&gt; sid main contrib non&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;free
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;deb &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;http:&#x2F;&#x2F;mirrors.huaweicloud.com&#x2F;debian&lt;&#x2F;span&gt;&lt;span&gt; sid main contrib non&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;free
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;deb-src &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;http:&#x2F;&#x2F;mirrors.huaweicloud.com&#x2F;debian&lt;&#x2F;span&gt;&lt;span&gt; sid main contrib non&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;free
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>编译 LLVM 项目</title>
          <pubDate>Sat, 17 Aug 2019 20:53:45 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/llvm-get-started/</link>
          <guid>https://blog.biofan.org/2019/08/llvm-get-started/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/llvm-get-started/">&lt;p&gt;最近开始研究 llvm 项目了. Rust 编译器也是基于它实现的.&lt;&#x2F;p&gt;
&lt;p&gt;LLVM 项目本身有多个子项目组成:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;llvm, 编译器&lt;&#x2F;li&gt;
&lt;li&gt;lldb, 类似 gdb 的调试工具&lt;&#x2F;li&gt;
&lt;li&gt;clang, c&#x2F;c++ 编译器前端&lt;&#x2F;li&gt;
&lt;li&gt;libcxx, c++ 标准库实现, 质量很棒, 可读性比较强&lt;&#x2F;li&gt;
&lt;li&gt;polly, 用来做数据计算优化&lt;&#x2F;li&gt;
&lt;li&gt;openmp, c&#x2F;c++&#x2F;fortran 并行计算库&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;首先是下载源代码, llvm 项目在 github 上面有完整的源码镜像:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ git clone https:&#x2F;&#x2F;github.com&#x2F;llvm&#x2F;llvm-project
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>Rust cmp 数值比较模块中的PartialEq, PartialOrd</title>
          <pubDate>Fri, 16 Aug 2019 17:18:56 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/rust-cmp/</link>
          <guid>https://blog.biofan.org/2019/08/rust-cmp/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/rust-cmp/">&lt;p&gt;&lt;code&gt;core::cmp.rs&lt;&#x2F;code&gt; 模块里定义了用于两值之间比较的几个 trait, 分别是:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;PartialEq&lt;&#x2F;li&gt;
&lt;li&gt;Eq&lt;&#x2F;li&gt;
&lt;li&gt;PartialOrd&lt;&#x2F;li&gt;
&lt;li&gt;Ord&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;这四个 trait 之间有这样一个关系:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Eq 基于 PartialEq, 即 &lt;code&gt;pub trait Eq: PartialEq&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;PartialOrd 基于 PartialEq, 即 &lt;code&gt;pub trait PartialOrd: PartialEq&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Ord 基于 Eq 和 PartialOrd, &lt;code&gt;pub trait PartialOrd: Eq + PartialOrd&amp;lt;Self&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;同时还定义了比较结果 &lt;code&gt;Ordering&lt;&#x2F;code&gt; 这样一个枚举类型:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;enum &lt;&#x2F;span&gt;&lt;span&gt;Ordering {
&lt;&#x2F;span&gt;&lt;span&gt;    Less &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= -&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    Equal &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    Greater &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>从 jekyll 切换到 zola</title>
          <pubDate>Thu, 15 Aug 2019 12:55:43 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/replace-jekyll-with-zola/</link>
          <guid>https://blog.biofan.org/2019/08/replace-jekyll-with-zola/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/replace-jekyll-with-zola/">&lt;p&gt;最近写的博客多一些, 也更加厌烦了 &lt;code&gt;jekyll&lt;&#x2F;code&gt;, 它对 markdown 支持的问题. 前天时间
多一些, 就找到了 rust 静态网站工具, zola.&lt;&#x2F;p&gt;
&lt;p&gt;首先是源代码更新还比较频繁, 社区也蛮活跃. 翻了&lt;a href=&quot;https:&#x2F;&#x2F;www.getzola.org&quot;&gt;官网的文档&lt;&#x2F;a&gt;, 也蛮简单的.
初步考察之后, 就决定尝试着把博客迁移到 zola.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>REST API 实践</title>
          <pubDate>Mon, 12 Aug 2019 17:08:26 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/rest-api-rules/</link>
          <guid>https://blog.biofan.org/2019/08/rest-api-rules/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/rest-api-rules/">&lt;p&gt;REST API 用于表示服务器端的资源模型(resource model).&lt;&#x2F;p&gt;
&lt;p&gt;可以使用 WRML (Web Resource Modeling Language) 来设计及实现统一的 REST API.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Rust 中的 Drop Trait</title>
          <pubDate>Sat, 10 Aug 2019 16:08:47 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/rust-drop-trait/</link>
          <guid>https://blog.biofan.org/2019/08/rust-drop-trait/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/rust-drop-trait/">&lt;h2 id=&quot;drop-trait&quot;&gt;Drop Trait&lt;&#x2F;h2&gt;
&lt;p&gt;先看代码:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;#[derive(Default)]
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;struct &lt;&#x2F;span&gt;&lt;span&gt;Point {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span&gt;x: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span&gt;y: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;#[derive(Default)]
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;struct &lt;&#x2F;span&gt;&lt;span&gt;Rectangle {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span&gt;p1: Point,
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span&gt;p2: Point,
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;impl &lt;&#x2F;span&gt;&lt;span&gt;Drop &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;Point {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;drop&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&amp;amp;mut &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;self&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;        println!(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;Point &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;{} {}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt; ::drop()&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;, self.x, self.y);
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;impl &lt;&#x2F;span&gt;&lt;span&gt;Drop &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;Rectangle {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;drop&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&amp;amp;mut &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;self&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;        println!(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;Rectangle::drop()&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; _p &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;Point::default();
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; _r &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; Rectangle {
&lt;&#x2F;span&gt;&lt;span&gt;        p1: Point { x: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;, y: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;2 &lt;&#x2F;span&gt;&lt;span&gt;},
&lt;&#x2F;span&gt;&lt;span&gt;        p2: Point { x: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;, y: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;4 &lt;&#x2F;span&gt;&lt;span&gt;},
&lt;&#x2F;span&gt;&lt;span&gt;    };
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;打印的结果是:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;span&gt;Rectangle::drop()
&lt;&#x2F;span&gt;&lt;span&gt;Point 1 2 ::drop()
&lt;&#x2F;span&gt;&lt;span&gt;Point 3 4 ::drop()
&lt;&#x2F;span&gt;&lt;span&gt;Point 0 0 ::drop()
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;可以发现 &lt;code&gt;Drop Trait&lt;&#x2F;code&gt; 的几个特性:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Drop::drop()&lt;&#x2F;code&gt; 方法是被隐式调用的.&lt;&#x2F;li&gt;
&lt;li&gt;先调用了 &lt;code&gt;Rectangle::drop()&lt;&#x2F;code&gt;, 之后调用了其内部属性的 &lt;code&gt;Point::drop()&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;Rectangle&lt;&#x2F;code&gt; 内部性性的 &lt;code&gt;drop()&lt;&#x2F;code&gt; 方法是基于声明的先后顺序调用的. 上面才会先打印
&lt;code&gt;Point 1 2 ::drop()&lt;&#x2F;code&gt;, 再打印 &lt;code&gt;Point 3 4 ::drop()&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;先声明的变量后被 &lt;code&gt;drop&lt;&#x2F;code&gt;. 上面的试验, 先 drop 了 &lt;code&gt;Rectangle _r&lt;&#x2F;code&gt;, 之后再 drop 了
&lt;code&gt;Point _p&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;另外还有几个特点:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Drop::drop()&lt;&#x2F;code&gt; 是不能手动调用的.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;Drop&lt;&#x2F;code&gt; trait 只能用于结构体 (struct), 不能用于 primative type.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;mem-drop&quot;&gt;mem::drop&lt;&#x2F;h2&gt;
&lt;p&gt;尽管不能手动调用 &lt;code&gt;Drop::drop()&lt;&#x2F;code&gt; 方法来 &lt;code&gt;destruct&lt;&#x2F;code&gt; 一个结构体, 但我们可以调用
&lt;code&gt;std::mem::drop()&lt;&#x2F;code&gt; 函数, 这个函数的实现也是非常简单的.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;#[inline]
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;drop&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;_x&lt;&#x2F;span&gt;&lt;span&gt;: T) { }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;它获取了传入参数的所有权, 然后什么都不做, 等该函数运行完之后, 该变量 &lt;code&gt;_x&lt;&#x2F;code&gt; 的值
的生命周期已完成, 它就要被释放掉.&lt;&#x2F;p&gt;
&lt;p&gt;我们来修改一下上面的测试代码:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; p &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;Point::default();
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; _r &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; Rectangle {
&lt;&#x2F;span&gt;&lt;span&gt;        p1: Point { x: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;, y: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;2 &lt;&#x2F;span&gt;&lt;span&gt;},
&lt;&#x2F;span&gt;&lt;span&gt;        p2: Point { x: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;, y: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;4 &lt;&#x2F;span&gt;&lt;span&gt;},
&lt;&#x2F;span&gt;&lt;span&gt;    };
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    std::mem::drop(p);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这次的打印结果是:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;span&gt;Point 0 0 ::drop()
&lt;&#x2F;span&gt;&lt;span&gt;Rectangle::drop()
&lt;&#x2F;span&gt;&lt;span&gt;Point 1 2 ::drop()
&lt;&#x2F;span&gt;&lt;span&gt;Point 3 4 ::drop()
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;Point p&lt;&#x2F;code&gt; 优先被 &lt;code&gt;drop&lt;&#x2F;code&gt; 了, 因为 &lt;code&gt;std::mem::drop(p);&lt;&#x2F;code&gt; 这条调用完结之后, &lt;code&gt;Point p&lt;&#x2F;code&gt;
的生命周期就完结了. 之后, 在 &lt;code&gt;main()&lt;&#x2F;code&gt; 函数结束时, 自动调用了 &lt;code&gt;Rectangle _r&lt;&#x2F;code&gt; 的 &lt;code&gt;drop()&lt;&#x2F;code&gt;
方法.&lt;&#x2F;p&gt;
&lt;p&gt;关于 &lt;code&gt;mem::drop()&lt;&#x2F;code&gt; 有一点要注意的是, 它只能用来 &lt;code&gt;drop&lt;&#x2F;code&gt; 没有实现 &lt;code&gt;Copy trait&lt;&#x2F;code&gt; 的变量,
像 rust 里的原始数据类型, usize&#x2F;u8&#x2F;u16&#x2F;u32&#x2F;u64&#x2F;u128&#x2F;... 这些都是实现了 &lt;code&gt;Copy trait&lt;&#x2F;code&gt;的,
&lt;code&gt;mem::drop()&lt;&#x2F;code&gt; 来 drop 它们时, 是没有效果的. 比如下面的代码, 变量 &lt;code&gt;x&lt;&#x2F;code&gt; 在传入 &lt;code&gt;drop()&lt;&#x2F;code&gt;
函数时, 它的值是被复制了一份的, 所以并不能 &lt;code&gt;drop&lt;&#x2F;code&gt; 变量 &lt;code&gt;x&lt;&#x2F;code&gt; 本身.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; x &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;42&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;std::mem::drop(x);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>Rust 中的引用与借用 (references and borrowing)</title>
          <pubDate>Thu, 08 Aug 2019 14:08:56 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/rust-references-and-borrowing/</link>
          <guid>https://blog.biofan.org/2019/08/rust-references-and-borrowing/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/rust-references-and-borrowing/">&lt;p&gt;Rust 中, 引用, 简单而言就是指向一个值所在内存的指针, 这个跟 c++ 里是一致的.
引用本身不支持指针操作, 使用起来更安全.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Cargo 使用 build.rs 动态生成版本号</title>
          <pubDate>Sat, 03 Aug 2019 10:08:10 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/cargo-build-script/</link>
          <guid>https://blog.biofan.org/2019/08/cargo-build-script/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/cargo-build-script/">&lt;p&gt;最近有个需求, 要在生成的可执行文件中包含一个版本号字段, 除了像 &lt;code&gt;0.1.0&lt;&#x2F;code&gt; 这样的
在 &lt;code&gt;Cargo.toml&lt;&#x2F;code&gt; 中定义的版本号之外, 最好还包含一下当前的 git commit id.&lt;&#x2F;p&gt;
&lt;p&gt;这个功能可以用 build.rs 脚本来实现. 大致做法也很简单:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;在 build.rs 中读取 Cargo.toml 里定义好的版本号, 以及当前的 git 历史, 并写入到编译目录里的一个文本文件&lt;&#x2F;li&gt;
&lt;li&gt;在 &lt;code&gt;src&#x2F;&lt;&#x2F;code&gt; 目录的源代码里, 定义一个字符串常量, 它的值在编译期指定的, 就是这个文件文件的内容&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>在 docker 中编译 rust 程序</title>
          <pubDate>Thu, 01 Aug 2019 16:08:23 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/rust-docker-build/</link>
          <guid>https://blog.biofan.org/2019/08/rust-docker-build/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/rust-docker-build/">&lt;p&gt;为了保证一致的编译环境, 可以考虑把代码放在 docker 中编译.&lt;&#x2F;p&gt;
&lt;p&gt;做法也很简单, 下面以之前用到的 &lt;code&gt;musl-demo&lt;&#x2F;code&gt; 示例程序为例来说明一下.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>使用 musl 库静态编译 rust 程序</title>
          <pubDate>Thu, 01 Aug 2019 09:08:28 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/08/rust-static-build-with-musl/</link>
          <guid>https://blog.biofan.org/2019/08/rust-static-build-with-musl/</guid>
          <description xml:base="https://blog.biofan.org/2019/08/rust-static-build-with-musl/">&lt;p&gt;rust 提供了很简单的方式调用外部的 C 库, 但是它默认是以动态链接的方式链到外部库,
这增加了部署时的复杂性.&lt;&#x2F;p&gt;
&lt;p&gt;musl 是一个轻量级的 libc 库, 与 glibc 相比, 它的代码比较简洁, 体积也更小, 更方便
静态编译到程序中.&lt;&#x2F;p&gt;
&lt;p&gt;我们可以将 musl 以及第三方的 C 库静态链接到 rust 程序可执行文件中.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>常用的 Debian 源</title>
          <pubDate>Wed, 31 Jul 2019 16:07:01 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/07/debian-repos/</link>
          <guid>https://blog.biofan.org/2019/07/debian-repos/</guid>
          <description xml:base="https://blog.biofan.org/2019/07/debian-repos/">&lt;p&gt;这些年陆陆续续用了不少的 debian 仓库源. 印象中速度比较快的有这些:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;http:&#x2F;&#x2F;ftp2.cn.debian.org&#x2F;debian&#x2F;, 指向的是清华大学源&lt;&#x2F;li&gt;
&lt;li&gt;http:&#x2F;&#x2F;ftp.cn.debian.org&#x2F;debian&#x2F;, 指向的是中科大源, 最终地址是: http:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;debian&#x2F;&lt;&#x2F;li&gt;
&lt;li&gt;http:&#x2F;&#x2F;mirrors.aliyun.com&#x2F;debian&#x2F;, 只有 i386&#x2F;amd64 的&lt;&#x2F;li&gt;
&lt;li&gt;http:&#x2F;&#x2F;ftp.hk.debian.org&#x2F;debian&#x2F;, 服务器位于香港&lt;&#x2F;li&gt;
&lt;li&gt;https:&#x2F;&#x2F;mirrors.huaweicloud.com&#x2F;debian&#x2F;, 华为云提供的源&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>systemd-networkd 启用 DHCP </title>
          <pubDate>Wed, 31 Jul 2019 12:07:56 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/07/systemd-dhcp/</link>
          <guid>https://blog.biofan.org/2019/07/systemd-dhcp/</guid>
          <description xml:base="https://blog.biofan.org/2019/07/systemd-dhcp/">&lt;p&gt;在 Virtualbox 虚拟机中安装了不带图形界面的 debian 系统之后, 为了方便与宿主系统
间的通信, 就为它分配了两张虚拟网卡, 并把其中一张网卡的模式设置为了 Host-Only.
这样就可以与宿主系统共享同一个网段. 但是, 虚拟机中的 debian 系统默认只有在安装
时会扫描一下 DHCP, 系统运行起来以后, 需要手动处理, 比较麻烦.&lt;&#x2F;p&gt;
&lt;p&gt;现在, 可以使用 systemd-networkd 服务来自动配置这些网卡.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>减小 rust 编译出的程序的文件大小</title>
          <pubDate>Mon, 22 Jul 2019 00:07:17 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/07/reduce-rust-binary-size/</link>
          <guid>https://blog.biofan.org/2019/07/reduce-rust-binary-size/</guid>
          <description xml:base="https://blog.biofan.org/2019/07/reduce-rust-binary-size/">&lt;p&gt;随着引入的依赖包越来越多, 编译生成的 rust 程序二进制文件越来越大, 要花更久的
时间把它推送到线上服务器.&lt;&#x2F;p&gt;
&lt;p&gt;通过使用以下手段, 可以显著减小生成的程序文件大小, 同时不破坏其完整性.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;debug-mo-shi&quot;&gt;debug 模式&lt;&#x2F;h2&gt;
&lt;p&gt;debug 模式生成的文件非常大, 里面包含了很全面的调试信息, 也没有经过优化.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>常用的 cargo 命令以及扩展命令</title>
          <pubDate>Mon, 22 Jul 2019 00:07:14 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/07/cargo-commands/</link>
          <guid>https://blog.biofan.org/2019/07/cargo-commands/</guid>
          <description xml:base="https://blog.biofan.org/2019/07/cargo-commands/">&lt;p&gt;熟练 cargo 工具以及扩展之后, 编写 rust 软件可以更高效.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;cargo-zi-dai-ming-ling&quot;&gt;cargo 自带命令&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;cargo-update&quot;&gt;cargo update&lt;&#x2F;h3&gt;
&lt;p&gt;更新 &lt;code&gt;Cargo.lock&lt;&#x2F;code&gt; 中定义的依赖包的版本.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Rust 中的 never 类型 </title>
          <pubDate>Wed, 10 Jul 2019 11:07:24 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/07/rust-never-types/</link>
          <guid>https://blog.biofan.org/2019/07/rust-never-types/</guid>
          <description xml:base="https://blog.biofan.org/2019/07/rust-never-types/">&lt;p&gt;这个特性目前还只有在 &lt;code&gt;nightly&lt;&#x2F;code&gt; 版本中可用, 但我觉得这是一个很差劲的设计.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;pub &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;exit&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;status&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32&lt;&#x2F;span&gt;&lt;span&gt;) -&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;! &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;  nc::exit(status);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>Rust match 中的坑</title>
          <pubDate>Mon, 29 Apr 2019 15:04:39 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/04/rust-match-pattern-issues/</link>
          <guid>https://blog.biofan.org/2019/04/rust-match-pattern-issues/</guid>
          <description xml:base="https://blog.biofan.org/2019/04/rust-match-pattern-issues/">&lt;p&gt;Rust 的 match 模式匹配, 可以很方便地匹配多种情况, 类似于 C 语言中的 switch 语句.
但是, 如果要匹配数字范围时, 需要这样写:&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Rust 抓取 panic 并恢复运行</title>
          <pubDate>Thu, 25 Apr 2019 11:04:21 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/04/rust-unwind/</link>
          <guid>https://blog.biofan.org/2019/04/rust-unwind/</guid>
          <description xml:base="https://blog.biofan.org/2019/04/rust-unwind/">&lt;p&gt;长期运行的服务, 比如 web app 服务器, 需要抓取 panic, 防止因为处理一个请求出错
导致整个服务退出.&lt;&#x2F;p&gt;
&lt;p&gt;可以使用 panic 库来修改抓取异常退出. 示例如下:&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Rust 中使用 Raw identifier</title>
          <pubDate>Thu, 25 Apr 2019 09:04:50 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/04/rust-raw-identifier/</link>
          <guid>https://blog.biofan.org/2019/04/rust-raw-identifier/</guid>
          <description xml:base="https://blog.biofan.org/2019/04/rust-raw-identifier/">&lt;p&gt;Rust 中定义的关键字越来越多, 有时可能会有命名冲突, 为了部分缓解这个问题, 在
Rust 2018 中定义了 &lt;code&gt;Raw Identifier&lt;&#x2F;code&gt;. 先看示例:&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>处理 Debian 升级 zfs 报错</title>
          <pubDate>Tue, 12 Mar 2019 09:03:25 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/03/upgrade-zfs/</link>
          <guid>https://blog.biofan.org/2019/03/upgrade-zfs/</guid>
          <description xml:base="https://blog.biofan.org/2019/03/upgrade-zfs/">&lt;p&gt;Debian 里更新 zfs 版本时, 总有以下报错:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;Setting up zfsutils-linux (0.7.13-1) ...
&lt;&#x2F;span&gt;&lt;span&gt;zfs-import-scan.service is a disabled or a static unit, not starting it.
&lt;&#x2F;span&gt;&lt;span&gt;Job for zfs-mount.service failed because the control process exited with error code.
&lt;&#x2F;span&gt;&lt;span&gt;See &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;systemctl status zfs-mount.service&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; and &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;journalctl -xe&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; for details.
&lt;&#x2F;span&gt;&lt;span&gt;invoke-rc.d: initscript zfs-mount, action &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;restart&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; failed.
&lt;&#x2F;span&gt;&lt;span&gt;     Docs: man:zfs(8)
&lt;&#x2F;span&gt;&lt;span&gt;  Process: 51146 ExecStart=&#x2F;sbin&#x2F;zfs mount&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -a&lt;&#x2F;span&gt;&lt;span&gt; (code=exited, status=1&#x2F;FAILURE)
&lt;&#x2F;span&gt;&lt;span&gt; Main PID: 51146 (code=exited, status=1&#x2F;FAILURE)
&lt;&#x2F;span&gt;&lt;span&gt;Mar 12 01:46:05 mydebian-gen8 zfs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;51146&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;: cannot mount &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;#39;&#x2F;pool&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;: directory is not empty
&lt;&#x2F;span&gt;&lt;span&gt;2 not fully installed or removed.
&lt;&#x2F;span&gt;&lt;span&gt;After this operation, 0 B of additional disk space will be used.
&lt;&#x2F;span&gt;&lt;span&gt;Do you want to continue&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;? [&lt;&#x2F;span&gt;&lt;span&gt;Y&#x2F;n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt; y
&lt;&#x2F;span&gt;&lt;span&gt;Setting up zfsutils-linux (0.7.13-1) ...
&lt;&#x2F;span&gt;&lt;span&gt;● zfs-mount.service - Mount ZFS filesystems
&lt;&#x2F;span&gt;&lt;span&gt;   Loaded: loaded (&#x2F;lib&#x2F;systemd&#x2F;system&#x2F;zfs-mount.service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;; &lt;&#x2F;span&gt;&lt;span&gt;enabled&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;; &lt;&#x2F;span&gt;&lt;span&gt;vendor preset: enabled)
&lt;&#x2F;span&gt;&lt;span&gt;Mar 12 01:46:24 mydebian-gen8 systemd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;: zfs-mount.service: Main process exited, code=exited, status=1&#x2F;FAILURE
&lt;&#x2F;span&gt;&lt;span&gt;Mar 12 01:46:24 mydebian-gen8 systemd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;: zfs-mount.service: Failed with result &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;#39;exit-code&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;.
&lt;&#x2F;span&gt;&lt;span&gt;Mar 12 01:46:24 mydebian-gen8 systemd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;: Failed to start Mount ZFS filesystems.
&lt;&#x2F;span&gt;&lt;span&gt;dpkg: error processing package zfsutils-linux (--configure)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#66d9ef;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt; zfs-zed depends on zfsutils-linux (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt;= 0.7.13-1)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;; &lt;&#x2F;span&gt;&lt;span&gt;however:
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;即使手动将 &lt;code&gt;&#x2F;pool&lt;&#x2F;code&gt; 里面挂载的zfs分区都卸载了, 仍然无法解决. 后来, 先用 umount
手动卸载里面挂的系统, 再把这个挂载目录清空即可.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>mitmproxy 中间人代理</title>
          <pubDate>Tue, 05 Mar 2019 19:03:26 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/03/mitm/</link>
          <guid>https://blog.biofan.org/2019/03/mitm/</guid>
          <description xml:base="https://blog.biofan.org/2019/03/mitm/">&lt;p&gt;使用 mitmproxy 做中间人代理时, 需要做一些配置, 下面列出了基本的步骤.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-zhuang&quot;&gt;安装&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ sudo apt install mitmproxy
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;或者直接用 pip 安装:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ pip3 install&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; --user&lt;&#x2F;span&gt;&lt;span&gt; mitmproxy
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>为 cargo 和 rustup 设置内地的代理</title>
          <pubDate>Tue, 12 Feb 2019 08:02:04 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2019/02/cargo-config/</link>
          <guid>https://blog.biofan.org/2019/02/cargo-config/</guid>
          <description xml:base="https://blog.biofan.org/2019/02/cargo-config/">&lt;h2 id=&quot;cargo&quot;&gt;cargo&lt;&#x2F;h2&gt;
&lt;p&gt;如果在大陆使用 cargo 命令下载依赖包太慢, 可以使用中科大的官方镜像, 只需要在
&lt;code&gt;$HOME&#x2F;.cargo&#x2F;config&lt;&#x2F;code&gt; 或者项目的&lt;code&gt;.cargo&#x2F;config&lt;&#x2F;code&gt; 里面加入以下内容即可:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;toml&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-toml &quot;&gt;&lt;code class=&quot;language-toml&quot; data-lang=&quot;toml&quot;&gt;&lt;span&gt;[source.crates-io]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;registry &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;crates.io-index&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;replace-with &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;#39;ustc&amp;#39;
&lt;&#x2F;span&gt;&lt;span&gt;[source.ustc]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;registry &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;git:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;crates.io-index&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>关于安全访问策略</title>
          <pubDate>Fri, 14 Dec 2018 15:12:57 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/12/acl/</link>
          <guid>https://blog.biofan.org/2018/12/acl/</guid>
          <description xml:base="https://blog.biofan.org/2018/12/acl/">&lt;h2 id=&quot;ssh-key&quot;&gt;SSH Key&lt;&#x2F;h2&gt;
&lt;p&gt;校验公钥&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ssl-tls&quot;&gt;SSL&#x2F;TLS&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;mfa-duo-yin-zi-yan-zheng&quot;&gt;MFA 多因子验证&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;jin-yong-root-yong-hu-qi-yong-duo-ge-yong-hu-he-duo-ge-zu&quot;&gt;禁用 root 用户, 启用多个用户和多个组&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;qiang-zhi-mi-ma-ce-lue&quot;&gt;强制密码策略&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;rolebasedaccesscontrl-ji-yu-jiao-se-de-fang-wen-ce-lue&quot;&gt;RoleBasedAccessContrl, 基于角色的访问策略&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;keyring&quot;&gt;Keyring&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;time-tick&quot;&gt;Time Tick&lt;&#x2F;h2&gt;
</description>
      </item>
      <item>
          <title>Python VS Code 开发环境目前的一些小问题</title>
          <pubDate>Sun, 09 Dec 2018 17:12:47 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/12/python-vscode/</link>
          <guid>https://blog.biofan.org/2018/12/python-vscode/</guid>
          <description xml:base="https://blog.biofan.org/2018/12/python-vscode/">&lt;p&gt;为 VS Code 配置了 python 开发环境, 如果再加上这些功能, 对用户就会更方便.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-zhuang-python-jie-xi-qi&quot;&gt;安装 python 解析器&lt;&#x2F;h2&gt;
&lt;p&gt;pyenv 这个工具可以完成一部分工作, 但是在 windows 平台, 需要依赖 Windows SDK,
这些可以集成到安装脚本里面.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Windows 平台配置 GNU&#x2F;Linux 开发环境</title>
          <pubDate>Wed, 21 Nov 2018 16:11:01 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/11/windows-dev/</link>
          <guid>https://blog.biofan.org/2018/11/windows-dev/</guid>
          <description xml:base="https://blog.biofan.org/2018/11/windows-dev/">&lt;p&gt;需要在 Windows 平台编译程序时, 又想保留 Linux 平台上的习惯, 可以安装这些工具.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;vim&quot;&gt;Vim&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.vim.org&#x2F;download.php#pc&quot;&gt;Vim&lt;&#x2F;a&gt; 的官网, 有提供 windows 版本, 直接安装即可.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Memory Mapping</title>
          <pubDate>Tue, 21 Aug 2018 09:08:57 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/08/mmap/</link>
          <guid>https://blog.biofan.org/2018/08/mmap/</guid>
          <description xml:base="https://blog.biofan.org/2018/08/mmap/">&lt;p&gt;mmap() 在进程的虚拟地址空间(virtual address space) 创建新的内存映射.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;文件映射, 将文件直接映射到进程虚拟内存, 内存页自动从文件中按需载入. 又被称作
file-based mapping 或 memory-mapped file.&lt;&#x2F;li&gt;
&lt;li&gt;匿名映射, 不需要映射相应的文件, 而是把映射的内存页里的内容初始化为0.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;进程之间共享内存映射:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;两个进程同时映射文件中的同一个区域时, 它们共享物理内存中相同的页面.&lt;&#x2F;li&gt;
&lt;li&gt;fork() 出来的子进程, 会持有父进程内存映射的复制, 它们指向同一个区域的物理内存.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>虚拟内存相关的操作</title>
          <pubDate>Fri, 17 Aug 2018 10:08:17 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/08/virtual-memory/</link>
          <guid>https://blog.biofan.org/2018/08/virtual-memory/</guid>
          <description xml:base="https://blog.biofan.org/2018/08/virtual-memory/">&lt;h2 id=&quot;nei-cun-bao-hu-mprotect&quot;&gt;内存保护, mprotect()&lt;&#x2F;h2&gt;
&lt;p&gt;mprotect() 改变一定范围内的虚拟内存页的保护方式.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;suo-ding-nei-cun-mlock-mlockall&quot;&gt;锁定内存 mlock(), mlockall()&lt;&#x2F;h2&gt;
&lt;p&gt;因为内核可能会将进程的内存页写到交换分区上, 如果该内存页上有敏感数据的话, 可能
导致它被泄露, 可以给关键的内存区域加锁, 告诉内核不要把这个区域的内存页执行交换
页的操作.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>文件锁</title>
          <pubDate>Wed, 15 Aug 2018 23:08:10 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/08/file-lock/</link>
          <guid>https://blog.biofan.org/2018/08/file-lock/</guid>
          <description xml:base="https://blog.biofan.org/2018/08/file-lock/">&lt;p&gt;锁定文件的两个接口:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;flock(), 用来锁定整个文件&lt;&#x2F;li&gt;
&lt;li&gt;fcntl(), 用来锁定文件的区域&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;基本用法是:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;给文件加锁&lt;&#x2F;li&gt;
&lt;li&gt;一般的文件读写操作&lt;&#x2F;li&gt;
&lt;li&gt;释放之前的锁&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>内核简介</title>
          <pubDate>Tue, 14 Aug 2018 17:08:09 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/08/kernel-info/</link>
          <guid>https://blog.biofan.org/2018/08/kernel-info/</guid>
          <description xml:base="https://blog.biofan.org/2018/08/kernel-info/">&lt;h2 id=&quot;ke-zhong-ru-reentrant-kernel&quot;&gt;可重入 (Reentrant Kernel)&lt;&#x2F;h2&gt;
&lt;p&gt;多个进程可以在内核里同时执行. 当一个进程被挂起时, 它的所有运行状态都被保存下来,
在下次被恢复执行时, 就从之前的状态继续执行.&lt;&#x2F;p&gt;
&lt;p&gt;当一个函数只修改本地的变量时, 它是一个可重入的函数.
当内核里的函数不可重入时, 就得用锁机制, 来保证同时只有一个进程来调用这个不可
重入的函数.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>使用 docker 获取 root shell</title>
          <pubDate>Wed, 27 Jun 2018 16:06:00 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/06/docker-privilege-escalation/</link>
          <guid>https://blog.biofan.org/2018/06/docker-privilege-escalation/</guid>
          <description xml:base="https://blog.biofan.org/2018/06/docker-privilege-escalation/">&lt;p&gt;基本情况是这样的:
今天把后端布署到线上服务器, 本来是由运维来做的, 但是他事情比较多, 又是远程的,
沟通一次, 要等待很久. 后来在导入数据时, MariaDB 一直无法正常连接. 催了他几次,
他也没能解决. 后来我就要求给我一个 ssh, 我自己来做. 但是, 给我的帐号, 并不属于
&lt;code&gt;sudo&lt;&#x2F;code&gt; 组的, 这样的话几乎做不了什么事儿. 之后我就要求把之前的帐号加入到 &lt;code&gt;docker&lt;&#x2F;code&gt;
组里, 这样至少可以下载&#x2F;更新 docker 镜像并管理 docker 上面运行的任务了.&lt;&#x2F;p&gt;
&lt;p&gt;但是, nginx 的配置是需要 root 权限才可以修改的, 后端服务的配置目录属于 www-data,
我也无权修改(需要改一下内部服务器监听的端口).&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Linux 桌面里打开 heic 格式的图片</title>
          <pubDate>Tue, 05 Jun 2018 09:06:04 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/06/linux-heic/</link>
          <guid>https://blog.biofan.org/2018/06/linux-heic/</guid>
          <description xml:base="https://blog.biofan.org/2018/06/linux-heic/">&lt;p&gt;iOS 11 之后, 就把默认的照片格式换成了 heic, 这个比较新的格式, 在其它平台上有
很大的兼容性问题, 到目前为止只有很少的图片查看工具支持它.&lt;&#x2F;p&gt;
&lt;p&gt;但这种情况正在得到改善, 比如前不久发布的 &lt;a href=&quot;https:&#x2F;&#x2F;www.gimp.org&#x2F;release-notes&#x2F;gimp-2.10.html&quot;&gt;GIMP 2.10&lt;&#x2F;a&gt;
已经支持对 heic 文件进行打开, 编辑以及保存了. ImageMagick 新版本也支持了这种
格式. 它们都使用了 libheif 这个库.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>录制终端</title>
          <pubDate>Wed, 30 May 2018 10:05:33 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/05/record-terminal/</link>
          <guid>https://blog.biofan.org/2018/05/record-terminal/</guid>
          <description xml:base="https://blog.biofan.org/2018/05/record-terminal/">&lt;p&gt;刚刚有个需求, 需要录制终端操作, 然后在别的机器上重放一下, 用于演示, 直接的做法
是启动 recordmydesktop 这样的屏幕录制工具, 生成 ogv 视频文件.&lt;&#x2F;p&gt;
&lt;p&gt;后来找了一下, 发现 bsdutils 这个包里带了 scriptreplay, 用于终端演示的, 使用方法
也很简单.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>为何一直使用 Debian 发行版</title>
          <pubDate>Thu, 17 May 2018 16:05:24 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/05/why-debian/</link>
          <guid>https://blog.biofan.org/2018/05/why-debian/</guid>
          <description xml:base="https://blog.biofan.org/2018/05/why-debian/">&lt;p&gt;陆陆续续有朋友向我推荐 Linux 桌面其它发行版, 比如 ArchLinux 这样的, 但我一直
没有切换过去. 首先一点, 这些发行版之前都有使用过, 包括 Debian GNU&#x2F;Linux 在内,
它们都有各自的优势与不足, 但其中 Debian 这个发行版, 可以最大程度上满足我的需要,
现在大致列举一下吧.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>cgroups</title>
          <pubDate>Tue, 08 May 2018 10:05:34 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/05/cgroup/</link>
          <guid>https://blog.biofan.org/2018/05/cgroup/</guid>
          <description xml:base="https://blog.biofan.org/2018/05/cgroup/">&lt;h2 id=&quot;cgroup-gong-neng&quot;&gt;cgroup 功能&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;限制资源容量, 包括 CPU, 内存, 网络, 文件系统等&lt;&#x2F;li&gt;
&lt;li&gt;对资源访问的优先级, 比如 CPU, 或者 硬盘I&#x2F;O&lt;&#x2F;li&gt;
&lt;li&gt;资源计量, 比如, 服务商可以根据用户使用内存的多少来收费&lt;&#x2F;li&gt;
&lt;li&gt;控制进程组, 比如挂起, 重启&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>中国地理标志 列表</title>
          <pubDate>Fri, 04 May 2018 01:05:55 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/05/cpgip/</link>
          <guid>https://blog.biofan.org/2018/05/cpgip/</guid>
          <description xml:base="https://blog.biofan.org/2018/05/cpgip/">&lt;p&gt;抓取了 &lt;a href=&quot;http:&#x2F;&#x2F;www.cgi.gov.cn&quot;&gt;中国地理标志网&lt;&#x2F;a&gt; 里列出来的推荐的国内产品.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;bei-jing&quot;&gt;北京&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;北寨红杏&lt;&#x2F;li&gt;
&lt;li&gt;昌平草莓&lt;&#x2F;li&gt;
&lt;li&gt;昌平草莓-昌平&lt;&#x2F;li&gt;
&lt;li&gt;平谷大桃&lt;&#x2F;li&gt;
&lt;li&gt;牛栏山二锅头&lt;&#x2F;li&gt;
&lt;li&gt;房山磨盘柿&lt;&#x2F;li&gt;
&lt;li&gt;昌平苹果&lt;&#x2F;li&gt;
&lt;li&gt;燕山板栗&lt;&#x2F;li&gt;
&lt;li&gt;京白梨&lt;&#x2F;li&gt;
&lt;li&gt;大兴西瓜&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>Linux 权限管理之 sudo</title>
          <pubDate>Fri, 27 Apr 2018 11:04:22 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/sudo/</link>
          <guid>https://blog.biofan.org/2018/04/sudo/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/sudo/">&lt;p&gt;&lt;code&gt;sudo&lt;&#x2F;code&gt; 命令实现了更多的功能, 在权限管理方面:&lt;&#x2F;p&gt;
&lt;p&gt;首先是可以自定义匹配规则, 只允许某个组或者某条命令以 root 权限或者别的权限执行.
规则文件位于 &lt;code&gt;&#x2F;etc&#x2F;sudoers&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Linux 权限管理之 su</title>
          <pubDate>Tue, 24 Apr 2018 11:04:36 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/su/</link>
          <guid>https://blog.biofan.org/2018/04/su/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/su/">&lt;p&gt;&lt;code&gt;su&lt;&#x2F;code&gt; 命令用于切换到 &lt;code&gt;root&lt;&#x2F;code&gt; 或者别的用户.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;su&lt;&#x2F;code&gt; 可执行文件本身是加了 sticky 标记的, 当执行这个命令时, 可以切换到 root 帐户,
这样才有权限读取 &lt;code&gt;&#x2F;etc&#x2F;shadow&lt;&#x2F;code&gt; 文件.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>清空 docker 进程及镜像</title>
          <pubDate>Thu, 19 Apr 2018 15:04:23 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/cleanup-docker/</link>
          <guid>https://blog.biofan.org/2018/04/cleanup-docker/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/cleanup-docker/">&lt;p&gt;今天要清理一下 docker 的镜像, 里面有太多垃圾了, 占了很多空间.
如果不想清空的话, 可以考虑为 &lt;code&gt;&#x2F;bar&#x2F;lib&#x2F;docker&lt;&#x2F;code&gt; 这个挂载点单独挂一个硬盘分区.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ sudo docker kill $(docker ps&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -q&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo docker rm&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -f &lt;&#x2F;span&gt;&lt;span&gt;$(docker ps&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -aq&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo docker rmi&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -f &lt;&#x2F;span&gt;&lt;span&gt;$(docker images&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -q -f&lt;&#x2F;span&gt;&lt;span&gt; danling=true)
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo docker rmi&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -f &lt;&#x2F;span&gt;&lt;span&gt;$(docker images&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -q&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>Qt 进程没有被设置语言环境变量时导致文件路径乱码的问题</title>
          <pubDate>Tue, 17 Apr 2018 23:04:30 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/qt-locale-fileinfo/</link>
          <guid>https://blog.biofan.org/2018/04/qt-locale-fileinfo/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/qt-locale-fileinfo/">&lt;h1 id=&quot;wen-ti&quot;&gt;问题&lt;&#x2F;h1&gt;
&lt;p&gt;前几天帮同事调试一个问题, 其表现是这样的:&lt;&#x2F;p&gt;
&lt;p&gt;前端 UI 进程里有个菜单项, 激活之后, 会调用后端的一个 dbus 服务, 这个服务使用 Qt
写的. 菜单会把当前选中的文件的绝对路径传递给后端的这个 dbus 服务, 当路径里有中文
字符时, 路径就不被识别了, 后来经过打印发现, &lt;code&gt;QFileInfo::exists(filepath);&lt;&#x2F;code&gt; 返回
&lt;code&gt;false&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Openbox 桌面环境里调整屏幕亮度</title>
          <pubDate>Tue, 17 Apr 2018 00:04:05 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/openbox-backlight/</link>
          <guid>https://blog.biofan.org/2018/04/openbox-backlight/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/openbox-backlight/">&lt;p&gt;最近换到 openbox 了, 因为要编译程序, 其它桌面环境太占资源.&lt;&#x2F;p&gt;
&lt;p&gt;到了晚上, 笔记本屏幕太亮, 需要调整一下, 可以使用 &lt;code&gt;gnome-settings-daemon&lt;&#x2F;code&gt; 这个
软件包提供的 &lt;code&gt;gsd-backlight-helper&lt;&#x2F;code&gt; 来实现, 它其实是修改了
&lt;code&gt;&#x2F;sys&#x2F;class&#x2F;backlight&#x2F;xxx_backlight&#x2F;brightness&lt;&#x2F;code&gt; 这个内核文件里的值. 直接手动
修改的话, 需要 root 权限, 但是可以使用 &lt;code&gt;pkexec&lt;&#x2F;code&gt; 命令来绕过, 因为
&lt;code&gt;gnome-settings-daemon&lt;&#x2F;code&gt; 已经注册了安全策略.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>配置一下 tmux 窗口操作快捷键</title>
          <pubDate>Sun, 15 Apr 2018 00:04:28 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/tmux/</link>
          <guid>https://blog.biofan.org/2018/04/tmux/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/tmux/">&lt;p&gt;最近换到了 tmux, 发现它默认的快捷键很难使用. 默认的快捷键前缀是 &lt;code&gt;Ctrl+b&lt;&#x2F;code&gt;, 要同时
用左手的小指和大拇指来按这两个键, 手指很酸痛, 对小指的压迫感太强. 我把它改为了
&lt;code&gt;Ctrl+a&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;而且, 默认的水平及竖直方向上的分屏快捷键是 &lt;code&gt;%&lt;&#x2F;code&gt; 和 &lt;code&gt;&quot;&lt;&#x2F;code&gt;, 这两个字符跟分屏完全没有
关联系, 为了跟 vim 以及 Gnome 保持一致, 把这俩快捷键换成了 &lt;code&gt;h&lt;&#x2F;code&gt; 和 &lt;code&gt;v&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>创建本地的Docker 镜像</title>
          <pubDate>Thu, 12 Apr 2018 17:04:53 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/docker-registry/</link>
          <guid>https://blog.biofan.org/2018/04/docker-registry/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/docker-registry/">&lt;p&gt;为了方便共享本地的镜像, 可以在本机开一个镜像服务. 分三步来做:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;创建 registry 服务:&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ sudo docker run&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -d &lt;&#x2F;span&gt;&lt;span&gt;\
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;    -p&lt;&#x2F;span&gt;&lt;span&gt; 5000:5000 \
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;    --name&lt;&#x2F;span&gt;&lt;span&gt; my-registry1 \
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;    -v&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;mnt&#x2F;data&#x2F;registry:&#x2F;var&#x2F;lib&#x2F;registry \
&lt;&#x2F;span&gt;&lt;span&gt;    registry:2
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>使用 kubeadm 初始化 Kubernetes 集群</title>
          <pubDate>Thu, 12 Apr 2018 10:04:23 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/04/kubernetes-installation/</link>
          <guid>https://blog.biofan.org/2018/04/kubernetes-installation/</guid>
          <description xml:base="https://blog.biofan.org/2018/04/kubernetes-installation/">&lt;p&gt;本来, 基于&lt;a href=&quot;https:&#x2F;&#x2F;kubernetes.io&#x2F;docs&#x2F;&quot;&gt;k8s-doc&lt;&#x2F;a&gt;, 可以很容易架起 k8s 集群, 但因为大陆地区的网络问题,
中间遇到了很多坑, 现在记录一下. 当然了, 如果全程使用 VPN 连接到国陆互联网
的话也不存在问题.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;huan-jing&quot;&gt;环境&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;master 节点, 网络地址是 10.0.1.10, 安装了 debian sid&lt;&#x2F;li&gt;
&lt;li&gt;工作节点, 网络地址是 10.0.1.11, 安装了 debian sid&lt;&#x2F;li&gt;
&lt;li&gt;kubernetes 版本是 v1.10.0&lt;&#x2F;li&gt;
&lt;li&gt;etcd 版本是 3.2.17&lt;&#x2F;li&gt;
&lt;li&gt;flannel 版本是 v0.10.0-amd64, 使用flannel 作为节点网络.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>调试定位云音乐搜索框冻结的问题</title>
          <pubDate>Thu, 22 Mar 2018 10:03:10 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/03/cef-input-box/</link>
          <guid>https://blog.biofan.org/2018/03/cef-input-box/</guid>
          <description xml:base="https://blog.biofan.org/2018/03/cef-input-box/">&lt;p&gt;去年年底发布云音乐之后, 就收到社区反馈说, 使用搜狗输入法在网易云音乐搜索框中输入时,
很容易导致播放器窗口没有响应. 这个问题在开发过程中, 在我的机器上并没有遇到过.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;gen-zong&quot;&gt;跟踪&lt;&#x2F;h2&gt;
&lt;p&gt;找一个可以重现问题的机器.&lt;&#x2F;p&gt;
&lt;p&gt;先启动播放器, 在输入框中多次输入文字之后, 就可以重现上面说到的窗口冻结的问题了.
现在使用 gdb 来跟踪一下调用栈.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Secure Boot 签名认证的大致过程</title>
          <pubDate>Thu, 15 Mar 2018 10:03:26 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/03/uefi-shim-review/</link>
          <guid>https://blog.biofan.org/2018/03/uefi-shim-review/</guid>
          <description xml:base="https://blog.biofan.org/2018/03/uefi-shim-review/">&lt;h2 id=&quot;shen-qing-ea-qian-ming-zheng-shu&quot;&gt;申请 EA 签名证书&lt;&#x2F;h2&gt;
&lt;p&gt;需要如实填写公司信息, 签名证书并不便宜, 比如 DigiCert 的三年 $499.&lt;&#x2F;p&gt;
&lt;p&gt;参考: &lt;a href=&quot;https:&#x2F;&#x2F;msdn.microsoft.com&#x2F;zh-cn&#x2F;library&#x2F;windows&#x2F;hardware&#x2F;dn962263(v=vs.85).aspx&quot;&gt;获取代码签名证书&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;bian-yi&quot;&gt;编译&lt;&#x2F;h2&gt;
&lt;p&gt;这一步我们来编译带有签名的 shim 文件, 在 Ubuntu 16.04 64 位系统里操作.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>cp 命令中对复制目录的优化</title>
          <pubDate>Sat, 03 Mar 2018 12:03:16 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/03/cp-inodes/</link>
          <guid>https://blog.biofan.org/2018/03/cp-inodes/</guid>
          <description xml:base="https://blog.biofan.org/2018/03/cp-inodes/">&lt;p&gt;昨天, 朋友告诉我, 他们的文件管理器使用了 cp 命令的优化方法, 复制目录的速度
提升了好几倍. 听了大概的意思, 上午就看了一下cp 命令的代码, 找到了它的开发者
的做法:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;text&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-text &quot;&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;span&gt;先对一个源目录中的所有文件, 基于 inode 做一次排序, 再依次读取
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>shimo.im 的问题</title>
          <pubDate>Sat, 20 Jan 2018 07:01:59 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2018/01/shimo-issues/</link>
          <guid>https://blog.biofan.org/2018/01/shimo-issues/</guid>
          <description xml:base="https://blog.biofan.org/2018/01/shimo-issues/">&lt;p&gt;最近写了三四份大的文档, 每份都有十几页二十页. 刚开始是用的 libreoffice,
过程中没有任何问题, 使用起来也非常顺手, 排版方式很简单统一, 做出来的页面
中规中矩, 都是标准化的处理方式.&lt;&#x2F;p&gt;
&lt;p&gt;但是, 因为现在公司要求所有的文档都用 shimo.im 来写, 我就把 libreoffice
默认的 odt 格式文档转换成了 docx 格式, 文档样式倒是没有多大变化.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>mpv 接口的设计问题</title>
          <pubDate>Tue, 26 Dec 2017 16:12:13 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/12/mpv-issues/</link>
          <guid>https://blog.biofan.org/2017/12/mpv-issues/</guid>
          <description xml:base="https://blog.biofan.org/2017/12/mpv-issues/">&lt;p&gt;这几天在为一个旧的项目写 mpv NPAPI 插件, 因为其它播放器对 RTSP 流支持不完够完善.&lt;&#x2F;p&gt;
&lt;p&gt;在调用 libmpv 的接口时, 发现了一些问题, 这个库给上层开发者提供的接口很不好用.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;dui-hou-duan-bo-fang-zhuang-tai-de-kong-zhi-du-shi-tong-guo-zi-fu-chuan-ming-ling-lai-wan-cheng-de&quot;&gt;对后端播放状态的控制都是通过字符串命令来完成的&lt;&#x2F;h2&gt;
&lt;p&gt;比如, 要暂停当前播放, 需要这样:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;c&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-c &quot;&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; flag &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ae81ff;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;mpv_set_property(mpv_ctx, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;pause&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;, MPV_FORMAT_FLAG, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;flag);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>禁用 chromium 浏览器的安全策略</title>
          <pubDate>Sat, 02 Dec 2017 00:12:50 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/12/chromium-web-security/</link>
          <guid>https://blog.biofan.org/2017/12/chromium-web-security/</guid>
          <description xml:base="https://blog.biofan.org/2017/12/chromium-web-security/">&lt;p&gt;调试前端应用时, 有时需要向另一个域名的发出 XHR 请求, 如果目标服务器没有设定
跨域请求, 浏览器就会阻止这个请求, 基于安全考虑. 此时, 可以临时先禁用一下浏览器
安全策略来实现.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>iOS 使用中发现的问题</title>
          <pubDate>Mon, 27 Nov 2017 14:40:21 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/11/ios-issues/</link>
          <guid>https://blog.biofan.org/2017/11/ios-issues/</guid>
          <description xml:base="https://blog.biofan.org/2017/11/ios-issues/">&lt;p&gt;因为要使用 AR, 前些天换了个 iPhone 8 Plus, 一直对苹果的设备不感冒. 经过这段时间的
使用, 发现它存在一系统的问题, 这里大致列举一下吧.&lt;&#x2F;p&gt;
&lt;p&gt;当然, 在提到它的不足之前, 先说说它的优势, 与安卓手机相比.&lt;&#x2F;p&gt;
&lt;p&gt;首先是运行速度, 支付宝基本是秒开, 但是在安卓上, 启动时间要以秒计了.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>网易云音乐 Linux 版 1.1.0 版本经验总结</title>
          <pubDate>Sat, 18 Nov 2017 07:13:12 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/11/cloud-music-linux/</link>
          <guid>https://blog.biofan.org/2017/11/cloud-music-linux/</guid>
          <description xml:base="https://blog.biofan.org/2017/11/cloud-music-linux/">&lt;h2 id=&quot;ru-guo-wen-ti-chu-xian-guo-yi-ci-na-ta-yi-ding-huan-hui-zai-chu-xian&quot;&gt;如果问题出现过一次, 那它一定还会再出现&lt;&#x2F;h2&gt;
&lt;p&gt;不要幻想着同样的问题不再发生, 除非已经明确定位到问题的出处并且修正了它.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;mei-you-bu-cun-zai-wen-ti-de-ruan-jian&quot;&gt;没有不存在问题的软件&lt;&#x2F;h2&gt;
&lt;p&gt;不管是功能上的错误, 还是设计交互上的不合理, 没有哪款软件是不存在问题的.&lt;&#x2F;p&gt;
&lt;p&gt;但是, 项目管理时, 要做的就是从全局评估一个问题会提高多少成本, 会损失什么.
当一个问题会导致软件无法启动, 或者运行时出现段错误退出了, 用户的数据也会
丢失, 那这个问题就是不可接受的, 这样的软件也明显是不可以被发布的.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Linux 桌面成不了大器</title>
          <pubDate>Fri, 17 Nov 2017 20:27:32 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/11/linux-desktop-sucks/</link>
          <guid>https://blog.biofan.org/2017/11/linux-desktop-sucks/</guid>
          <description xml:base="https://blog.biofan.org/2017/11/linux-desktop-sucks/">&lt;p&gt;今天发布了云音乐 1.1 版, 并不开心. 这些天被这一堆的桌面问题
坑得无语. 分两部分说吧.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;chai-de-bu-neng-zai-chai-de-bao-guan-li-gong-ju&quot;&gt;差得不能再差的包管理工具&lt;&#x2F;h2&gt;
&lt;p&gt;嗯, 同一个发行版, 不同的系统版本, 包名竟然不一样. 而且, Debian&#x2F;deb 系的,
尤其喜欢拆包, 一个好好的软件包, 拆成一堆的小包, 一个 VLC 播放器, 被拆成了
十几个包. 更可恶的, Ubuntu 16.04 与 Ubuntu 17.10 上面, VLC 的解码器
被放到了不同的包里, 前者是 vlc-nox, 后者有 vlc-plugin-base, 但是还得
安装 vlc-bin. 这是自找没趣, 闲得没事儿干. 他们拆包时, 并没有为这个软件包
加入什么新的功能, 反而把一些包改得没了样子.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Rust 语言中的瑕疵 - 省去 return</title>
          <pubDate>Tue, 07 Nov 2017 20:55:32 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/11/rust-return/</link>
          <guid>https://blog.biofan.org/2017/11/rust-return/</guid>
          <description xml:base="https://blog.biofan.org/2017/11/rust-return/">&lt;p&gt;Rust 语法中的 &lt;code&gt;return&lt;&#x2F;code&gt; 关键字是可以省去的, 这也是推荐做法,
但是某些条件下会带来问题.&lt;&#x2F;p&gt;
&lt;p&gt;先看例子:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a6e22e;&quot;&gt;max&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;a&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt;b&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32&lt;&#x2F;span&gt;&lt;span&gt;) -&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#66d9ef;&quot;&gt;i32 &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; a &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; b {
&lt;&#x2F;span&gt;&lt;span&gt;        a
&lt;&#x2F;span&gt;&lt;span&gt;    } &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f92672;&quot;&gt;else &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;        b
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>可重入的函数</title>
          <pubDate>Sun, 29 Oct 2017 22:36:18 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/10/reentrent-functions/</link>
          <guid>https://blog.biofan.org/2017/10/reentrent-functions/</guid>
          <description xml:base="https://blog.biofan.org/2017/10/reentrent-functions/">&lt;p&gt;可重入的函数有这样的特性: 当该函数被调用时, 不会影响之前的
状态. 它们是线程安全的, 而且也可以在信号处理函数(signal handler)
里面使用. 它们没有副作用.&lt;&#x2F;p&gt;
&lt;p&gt;举例来说, read(), write() 都是可重入的, 因为它们的状态, 比如
缓存, 文件偏移量都是在内核中维护的. 而 fread(), fwrite(),
printf(), 这些都不是可重入的. 它们的缓存是由 libc 维护的, 极端的
情况下, libc 在处理缓存时被内核中断了, 触发了信号处理函数, 在信号
处理函数内部, 调用 printf() 时, libc 之前的缓存状态就被修改了.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>那一堆的 Linux 桌面环境还会剩下谁?</title>
          <pubDate>Thu, 26 Oct 2017 23:08:31 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/10/linux-desktop/</link>
          <guid>https://blog.biofan.org/2017/10/linux-desktop/</guid>
          <description xml:base="https://blog.biofan.org/2017/10/linux-desktop/">&lt;p&gt;最近, Canonical 的 CEO 发文说明了一下为什么他们要放弃
Unity 桌面环境. 先不管他说了什么, 且来提一提之前那些年
Ubuntu 上死了的商业化产品:&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>申请 Steam 开发者帐号</title>
          <pubDate>Thu, 26 Oct 2017 22:35:48 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/10/steam-w8ben/</link>
          <guid>https://blog.biofan.org/2017/10/steam-w8ben/</guid>
          <description xml:base="https://blog.biofan.org/2017/10/steam-w8ben/">&lt;p&gt;Steam 取消了之前的 &quot;绿光&quot; 计划, 现在向 steam 商启提交游戏的话,
是要有审核费用的, 叫做 Steam Direct Product Submission Fee.
昨天尝试着申请了一下, 是 100 美元, 付款方式还算方便, 银联, 支付宝,
Paypal, Visa 任意选.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>体验 Gnome 3.26</title>
          <pubDate>Wed, 18 Oct 2017 00:07:49 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/10/gnome3.26/</link>
          <guid>https://blog.biofan.org/2017/10/gnome3.26/</guid>
          <description xml:base="https://blog.biofan.org/2017/10/gnome3.26/">&lt;p&gt;Gnome 的最新正式版 3.26 已经发布有一段时间了, 但是 Debian unstable
仓库里面只是在最近几天才把大部分 Gnome 组件从 3.24 升级到了 3.26.&lt;&#x2F;p&gt;
&lt;p&gt;使用 Gnome 桌面环境已经有近十年时间了, 从 Ubuntu 07.04, 07.10 开始,
接触到的就是 Gnome. 期间更换了多个桌面环境, 用起来最顺手最高效的, 还是
Gnome 桌面. 当时, 由于某些时期, Gnome 更新后无法正常启动, 或者因为
内存泄露的问题, 会偶尔切换到 openbox + fbpanel 的轻量环境.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>互联网除了广告之外的另一种获利方式</title>
          <pubDate>Sat, 14 Oct 2017 23:55:04 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/10/web-ads/</link>
          <guid>https://blog.biofan.org/2017/10/web-ads/</guid>
          <description xml:base="https://blog.biofan.org/2017/10/web-ads/">&lt;p&gt;目前, 网站的一大赢利点是在网页中嵌入广告链接, 访者在消费网站提供的
内容的时候也有意无意的看了广告或者点击了广告, 网站可以得到广告商
(比如谷歌) 的广告分成.&lt;&#x2F;p&gt;
&lt;p&gt;现在, 除了展示广告之外, 一种新的获利形式陆陆续续被一些网站使用, 那就是
在网页中嵌入挖矿代码. 这是一种新的形式和潮流. 但是目前效率还不算高.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>设置动态 DNS</title>
          <pubDate>Sat, 14 Oct 2017 14:27:09 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/10/ddns/</link>
          <guid>https://blog.biofan.org/2017/10/ddns/</guid>
          <description xml:base="https://blog.biofan.org/2017/10/ddns/">&lt;p&gt;现在的做法是把家里的服务器通过外网一个 VPS 做中转.
这种方式有些不足之处:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;网速受到 VPS 的影响很大, 毕竟 VPS 服务器不在大陆.&lt;&#x2F;li&gt;
&lt;li&gt;数据没有高强度加密, TLS 加密数据在 VPS 上面已经被正确解密了,
VPS 与 家里的服务器之间的传输没有经过高强度加密, 只是依赖中转服务
提供的简单的加密算法.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>配置 HP Gen8 (4) UPS 自动关机</title>
          <pubDate>Sat, 30 Sep 2017 20:06:40 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/09/gen8-ups/</link>
          <guid>https://blog.biofan.org/2017/09/gen8-ups/</guid>
          <description xml:base="https://blog.biofan.org/2017/09/gen8-ups/">&lt;p&gt;为了保障硬盘的安全, 之前为 Gen8 服务器安装了 APC UPS, 型号是 BK650-CH, 这个性价比挺高的,
断电时足够支持 Gen8 服务器正常运行十分钟. 但是, 当电池电量用完时, 服务器的电源仍然会被强制
切断, 并不能有效地保护硬盘. 为此, 这里使用 APC 提供的电源管理服务, 当市电中断, UPS 供电
一分钟后, 就自动关闭 Gen8 服务器.&lt;&#x2F;p&gt;
&lt;p&gt;BK650-CH 提供了 RJ45转 USB口的数据线, 将 RJ45端 插到 UPS 侧面的管理接口, USB端插到
Gen8 背面的 USB 接口.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>配置 HP Gen8 启动光盘位的系统</title>
          <pubDate>Sat, 30 Sep 2017 19:44:00 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/09/gen8-sata5-boot/</link>
          <guid>https://blog.biofan.org/2017/09/gen8-sata5-boot/</guid>
          <description xml:base="https://blog.biofan.org/2017/09/gen8-sata5-boot/">&lt;p&gt;接上文, 当服务器中的四个硬盘位都安放了硬盘后, 在 BIOS 中关闭 HP Array RAID, 并开启
AHCI 模式. 这时, BIOS 就会优先尝试从 SATA1 启动, 因为我们已经把 SATA1~SATA4 组成了
ZFS RAID6, 上面并没有可用的引导器, 而 SATA5 上面的系统以及引导器, 并没有被服务器使用,
为此, 临时的解决方法是使用 U 盘引导 SATA5 上面的系统, 具体做法如下:&lt;&#x2F;p&gt;
&lt;p&gt;首先, 为 U 盘新建一个小的空白分区, 用于安装 GRUB:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ sudo parted &#x2F;dev&#x2F;sdX mklabel msdos
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo parted &#x2F;dev&#x2F;sdX mkpart primary fat32 1M 100M
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo mkfs.fat -F32 &#x2F;dev&#x2F;sdX1
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>为 Firefox 添加 PAC 代理规则</title>
          <pubDate>Thu, 21 Sep 2017 12:35:29 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/09/firefox-pac/</link>
          <guid>https://blog.biofan.org/2017/09/firefox-pac/</guid>
          <description xml:base="https://blog.biofan.org/2017/09/firefox-pac/">&lt;p&gt;Firefox 更新之后, 之前的代理扩展越来越不好用了, 索性就把它移除了, 然后用自动代理脚本来
实现智能代理和广告过滤.&lt;&#x2F;p&gt;
&lt;p&gt;但是, 找了一些资料, 关于 PAC 的具体实现, 并没有太多说明. 后来就去 firefox 源代码里面
找了找. Firefox 对 PAC 的支持是在 &lt;code&gt;netwerk&#x2F;base&#x2F;ProxyAutoConfig.cpp&lt;&#x2F;code&gt; 里面实现的.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>以预防为主的医疗</title>
          <pubDate>Mon, 04 Sep 2017 22:37:29 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/09/health-forecast/</link>
          <guid>https://blog.biofan.org/2017/09/health-forecast/</guid>
          <description xml:base="https://blog.biofan.org/2017/09/health-forecast/">&lt;p&gt;现如今, 每当身体不舒服了, 要去医院看病时, 都要排队挂号, 然后大夫大致了解情况之后,
就要求去做各类的检查, 从核磁共振到抽血到化验体液.&lt;&#x2F;p&gt;
&lt;p&gt;现在的状况是, 一般只有当身体一直连着几天都不舒服了, 撑不下去了, 才想着去医院查一下,
以后, 随着检测设备的低成本化, 就像现在的血压仪血糖仪一样, 会陆陆续续地成为一般家诞庭
必备的设备, 这些器械可以采集体液, 空气成分, 甚至光学或者红外摄像头, 不间断地记录家人
的身体状况, 一旦数据稍有差异, 就可以及时地发现问题, 比如流感. 基于这些日常数据, 大夫
也可以更全面地了解患者的状况, 而不是单单凭借一次检测数据来做决断.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>配置 HP Gen8 启用 ZFS 文件系统</title>
          <pubDate>Tue, 22 Aug 2017 12:14:16 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/08/gen8-zfs/</link>
          <guid>https://blog.biofan.org/2017/08/gen8-zfs/</guid>
          <description xml:base="https://blog.biofan.org/2017/08/gen8-zfs/">&lt;h1 id=&quot;an-zhuang-ci-pan-zhen-lie-bing-pei-zhi-zfs-raid6&quot;&gt;安装磁盘阵列, 并配置 ZFS raid6&lt;&#x2F;h1&gt;
&lt;p&gt;当 debian 系统正常被安装到 SSD 之后, 把它从台式机上面卸下来, 然后安装到 Gen8
服务器的光驱位置. 当然, 这个需要先把 Gen8 的外壳打开, 在服务器的后面, 有两个
蓝色的旋扭, 把它们拧开之后, 稍微用力向后拉服务器的外壳, 应该就可以顺利把它打开了.&lt;&#x2F;p&gt;
&lt;p&gt;连接 SSD 的 SATA 接口是要接到主板上预留的一个 SATA 接口, 电源线要接到服务器
顶部的有四个接口的电源输出线上.&lt;&#x2F;p&gt;
&lt;p&gt;之后用 VGA 线缆连接 Gen8 服务器和显示器.&lt;&#x2F;p&gt;
&lt;p&gt;通电, 等主板自检完成之后, 按 F9 进入 BIOS 设置.
我们要关闭服务器自带的 RAID Controller, 把硬盘模式从 Array 改为 AHCI 模式.
然后修改启动顺序, 把硬盘启动放到第一个. 然后退出, 按 F10 保存设置.&lt;&#x2F;p&gt;
&lt;p&gt;机器重启后, 应该就可以正常读取 SSD 上面的 GRUB 了. 使用刚刚创建的用户登录
系统.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>配置 HP Gen8 安装 debian 系统</title>
          <pubDate>Mon, 21 Aug 2017 08:59:09 +0800</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/2017/08/gen8-debian/</link>
          <guid>https://blog.biofan.org/2017/08/gen8-debian/</guid>
          <description xml:base="https://blog.biofan.org/2017/08/gen8-debian/">&lt;h1 id=&quot;an-zhuang-debian-xi-tong&quot;&gt;安装 debian 系统&lt;&#x2F;h1&gt;
&lt;p&gt;先把新的 120GB 的因特尔 SSD 挂到已有的 debian 系统上面, 这块 SSD 只用来放置 debian 系统,
所有的应用数据和用户文件都要放到 ZFS 文件系统上面.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;fen-qu&quot;&gt;分区&lt;&#x2F;h2&gt;
&lt;p&gt;使用 parted 为它分区:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#272822;color:#f8f8f2;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;$ sudo parted &#x2F;dev&#x2F;sdb mklabel msdos
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo parted &#x2F;dev&#x2F;sdb mkpart primary ext4 1MiB 100%
&lt;&#x2F;span&gt;&lt;span&gt;$ sudo mkfs.ext4&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#fd971f;&quot;&gt; -F -L &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e6db74;&quot;&gt;&amp;quot;Gen8&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;dev&#x2F;sdb1
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里要注意的是, Gen8 默认不支持 UEFI 启动, 所以为新的 SSD 创建 &lt;code&gt;MSDOS&lt;&#x2F;code&gt;
分区表. 并且创建一个 &lt;code&gt;ext4&lt;&#x2F;code&gt; 分区.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>关于</title>
          <pubDate>Sun, 01 Jan 2017 00:00:00 +0000</pubDate>
          <author>Shaohua</author>
          <link>https://blog.biofan.org/about/</link>
          <guid>https://blog.biofan.org/about/</guid>
          <description xml:base="https://blog.biofan.org/about/">&lt;p&gt;目前从事 Linux 系统开发的工作。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;lian-xi-fang-shi&quot;&gt;联系方式:&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;blog.biofan.org&#x2F;about&#x2F;shaohua@biofan.org&quot;&gt;shaohua@biofan.org&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;xushaohua&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;xushaohua&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</description>
      </item>
    </channel>
</rss>
