<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sean&#39;s TechLab</title>
    <link>http://seanfeng.dev/</link>
    <description>Recent content on Sean&#39;s TechLab</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 30 Oct 2024 22:07:21 -0400</lastBuildDate>
    <atom:link href="http://seanfeng.dev/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Integrate Antlr4 to C&#43;&#43; Projects for Javascript with CMake on Linux</title>
      <link>http://seanfeng.dev/tech/en/antler4_cpp/</link>
      <pubDate>Wed, 30 Oct 2024 22:07:21 -0400</pubDate>
      <guid>http://seanfeng.dev/tech/en/antler4_cpp/</guid>
      <description>&lt;p&gt;Here are the requires steps to make existing CMake-based C++ projects to compile with&#xA;antlr4 for Javascript on Linux.&lt;/p&gt;&#xA;&lt;h3 id=&#34;1-generate-the-javascriptlexerhcpp-and-javascriptparserhcpp&#34;&gt;1. Generate the JavaScriptLexer.{h|cpp} and JavaScriptParser.{h|cpp}&lt;/h3&gt;&#xA;&lt;p&gt;These files will be added to your project to parse JavaScript.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Download the ANTLR4 Java binary&lt;/strong&gt;: Visit &lt;a href=&#34;https://www.antlr.org/download.html&#34;&gt;ANTLR&amp;rsquo;s download page&lt;/a&gt; and&#xA;download the latest &lt;code&gt;.jar&lt;/code&gt; file. Example: &lt;code&gt;antlr-4.13.2-complete.jar&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Get the grammar files&lt;/strong&gt;: Download &lt;code&gt;JavaScriptLexer.g4&lt;/code&gt; and&#xA;&lt;code&gt;JavaScriptParser.g4&lt;/code&gt; from the &lt;a href=&#34;https://github.com/antlr/grammars-v4/tree/master/javascript/javascript&#34;&gt;official ANTLR grammars repo&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Modify the grammar files&lt;/strong&gt; according to the instructions are &lt;a href=&#34;https://github.com/antlr/grammars-v4/tree/master/javascript/javascript/Cpp#c-port&#34;&gt;https://github.com/antlr/grammars-v4/tree/master/javascript/javascript/Cpp#c-port&lt;/a&gt;.&#xA;This is needed because the grammar files are generic to all target languages, we need&#xA;some tweaks for C++.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Self-host Calibre with Kobo Sync</title>
      <link>http://seanfeng.dev/tech/en/calibre/</link>
      <pubDate>Sat, 15 Apr 2023 22:07:21 -0400</pubDate>
      <guid>http://seanfeng.dev/tech/en/calibre/</guid>
      <description>&lt;!-- raw HTML omitted --&gt;&#xA;&lt;p&gt;Calibre is an incredibly convenient tool for managing books in various&#xA;formats. I became addicted to it when I discovered its syncing ability&#xA;with Kobo. The first release was in 2006 and after seventeen years, it&#xA;is still the go-to software for many people nowadays.&lt;/p&gt;&#xA;&lt;p&gt;In this article, I will elaborate on the setup I did. Ultimately, you&#xA;will have Calibre self-hosted so that you can use it to manage your&#xA;books and sync with Kobo flawlessly and wirelessly.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Review of My Home Server</title>
      <link>http://seanfeng.dev/life/en/my_home_server/</link>
      <pubDate>Fri, 07 Apr 2023 20:30:43 -0400</pubDate>
      <guid>http://seanfeng.dev/life/en/my_home_server/</guid>
      <description>&lt;p&gt;About eight months ago, I built a mini-computer that I treat as an always-on home server. I&#xA;installed Linux and hosted several applications on it. In this article, I am going to share some details&#xA;some details and my experience with it.&lt;/p&gt;&#xA;&lt;h2 id=&#34;hardware&#34;&gt;Hardware&lt;/h2&gt;&#xA;&lt;h4 id=&#34;specification-and-after-tax-price&#34;&gt;Specification And After-Tax Price.&lt;/h4&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CPU: Intel Core i3-10100, $156&#xA;Memory: Crucial RAM 8GB DDR4 2666, $56&#xA;Motherboard: MSI H510 Pro, $160&#xA;Power Supply: EVGA SuperNOVA 80 Plus Gold 550W, ~$100&#xA;Disk 1: A Spare 256GB NVME SSD&#xA;Disk 2: WD Digital 14TB Red NAS Drive, $315 ($22.5/T)&#xA;Case: Thermaltake Core V1 Black Edition, $84&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;All the items that I purchased were brand new, and I spent $556 Canadian dollar on them if I don&amp;rsquo;t count the&#xA;NAS drive, which is still pricey for a home server. To recap, I think I could have&#xA;reduced the cost if I had purchased used items, which I may consider doing next time.&#xA;Additionally, I am also not a hardware expert, so I don&amp;rsquo;t have enough knowledge about finding&#xA;the best budget items. I used my limited knowledge to come up the spec list, which&#xA;is probably not a cost-efficiency list.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Vim的中文输入解决方案</title>
      <link>http://seanfeng.dev/tech/cn/vim_typing_chinese/</link>
      <pubDate>Sun, 19 Mar 2023 17:43:04 -0400</pubDate>
      <guid>http://seanfeng.dev/tech/cn/vim_typing_chinese/</guid>
      <description>&lt;p&gt;近日终于配置好了一个觉得满意的在&lt;code&gt;Vim&lt;/code&gt;中输入中文的一个方案，现在分享给大家。&lt;/p&gt;&#xA;&lt;p&gt;首先，安装依云的&lt;a href=&#34;https://github.com/lilydjwg/fcitx.vim&#34;&gt;fcitx.vim&lt;/a&gt;插件（注意根据&lt;code&gt;Fcitx&lt;/code&gt;的版本，安装相应的版本）。此插件会记录当前&lt;code&gt;Fcitx&lt;/code&gt;的输入方式，&#xA;当从&lt;code&gt;Vim&lt;/code&gt;的&lt;code&gt;Input&lt;/code&gt;模式切回&lt;code&gt;Normal&lt;/code&gt;模式的时候，输入方式会自动切换到英文。这样无需手动切换输入方式，便可使用&lt;code&gt;Vim&lt;/code&gt;的快捷键，而不会被输入方法拦截。然后再从&lt;code&gt;Normal&lt;/code&gt;回到&lt;code&gt;Input&lt;/code&gt;的时候，会自动切换回记录的输入方式，因此无需手动切换输入方式就可以在Vim中进行流畅的中文输入。&lt;/p&gt;</description>
    </item>
    <item>
      <title>一个浏览器工程师实现Web元素的经历</title>
      <link>http://seanfeng.dev/tech/cn/web_dialog/</link>
      <pubDate>Wed, 17 Aug 2022 02:43:47 +0000</pubDate>
      <guid>http://seanfeng.dev/tech/cn/web_dialog/</guid>
      <description>&lt;p&gt;在过去的2个月，我用了很多时间在Gecko中补充了&lt;a href=&#34;https://html.spec.whatwg.org/multipage/#the-dialog-element&#34;&gt;&lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;&lt;/a&gt;标签的支持使其符合大部分的标准，能够在Nightly中默认开启，但还不能在Release中开启，因为当前的实现并不完美。这是我第一次实现Web标准，写下这篇文章来进行一个总结，顺便也可以帮助大家了解到浏览器工程师是如何工作的。&lt;/p&gt;&#xA;&lt;p&gt;Spec(标准)的理解是第一步也是最重要的一步。浏览器工程师需要大量的时间来阅读Web标准，很多时候还需要跟别的引擎开发团队进行讨论和修改。拿&lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;标签来举例，我所做的第一件事情，就是阅读跟&lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;相关的文档，而一项标准往往和别的标准相关联，&lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;就跟&lt;a href=&#34;http://link.zhihu.com/?target=https%3A//fullscreen.spec.whatwg.org/#top-layer&#34;&gt;top layer&lt;/a&gt;的标准联系很大，所以top layer也是需要被掌握的内容。当&lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;在进入modal状态下的时候，需要被&lt;a href=&#34;https://html.spec.whatwg.org/multipage/#dialog-focusing-steps&#34;&gt;focus&lt;/a&gt;的元素也在标准中明确声明了，因此也需要阅读focus相关的文档。&lt;/p&gt;</description>
    </item>
    <item>
      <title>在Linux下使用rr来debug C/C&#43;&#43;程序</title>
      <link>http://seanfeng.dev/tech/cn/debug_rr/</link>
      <pubDate>Wed, 17 Aug 2022 02:43:40 +0000</pubDate>
      <guid>http://seanfeng.dev/tech/cn/debug_rr/</guid>
      <description>&lt;p&gt;想象一下如果你的程序某时会崩溃，但是不能稳定复现，你会如何debug它?&lt;/p&gt;&#xA;&lt;p&gt;用传统debugger面临的问题就是你不知道这次运行的时候能不能复现，你猜测可能某段代码出现了问题，所以进行了一番检查。但如果最后不能复现的话，刚刚所做的工作就是无用的。gdb通过一个反向调试的功能解决了这个问题。但是gdb的反向调试代价很大，在大型项目上运行很吃力。Bug出现的几率高还好，但如果出现的概率是1/100，甚至1/1000呢？&lt;/p&gt;</description>
    </item>
    <item>
      <title>Perfect Forwarding And Universal Reference</title>
      <link>http://seanfeng.dev/tech/en/perfect_fowarding_universal_reference/</link>
      <pubDate>Wed, 10 Aug 2022 02:15:21 +0000</pubDate>
      <guid>http://seanfeng.dev/tech/en/perfect_fowarding_universal_reference/</guid>
      <description>&lt;p&gt;While I was learning &lt;a href=&#34;https://github.com/mtrebi/thread-pool&#34;&gt;mtrebi&amp;rsquo;s threadpool&lt;/a&gt; implementation, I noticed some peculiar usage of &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, which looked like this.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;template&amp;lt;typename F, typename...Args&amp;gt;&#xA;auto submit(F&amp;amp;&amp;amp; f, Args&amp;amp;&amp;amp;... args) -&amp;gt; std::future&amp;lt;decltype(f(args...))&amp;gt; {&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; is known for rvalue reference in C++, but what does it mean in this context? To answer this question, I did some research and figured it was called &lt;code&gt;universal reference&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The term &lt;a href=&#34;https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers&#34;&gt;universal reference&lt;/a&gt; was coined by Scott Meyers, and it is used to describe references that may be either lvalue references or rvalue references may bind to anything. To understand it precisely, we need to understand what problem does it solve.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Somes Notes About Linking in C&#43;&#43;</title>
      <link>http://seanfeng.dev/tech/en/linking_cpp/</link>
      <pubDate>Wed, 10 Aug 2022 02:14:56 +0000</pubDate>
      <guid>http://seanfeng.dev/tech/en/linking_cpp/</guid>
      <description>&lt;p&gt;One thing that came to my mind frequently, while I was working with C++, was that how to link external libraries to my projects. A lot of the time, when I see a project on Github, I see the source code and a makefile, but I don&amp;rsquo;t know what I suppose to do with them. Do I need to compile them, to a special format? How do I compile them? So today, I decided to resolve this mystery as a gift for myself.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Order of Evaluation</title>
      <link>http://seanfeng.dev/tech/en/order_of_evaluation/</link>
      <pubDate>Wed, 10 Aug 2022 02:14:47 +0000</pubDate>
      <guid>http://seanfeng.dev/tech/en/order_of_evaluation/</guid>
      <description>&lt;p&gt;Today I saw the &lt;code&gt;Order of Evaluation&lt;/code&gt; section in C++ Primer, and I wished I could&amp;rsquo;ve learned this earlier!&lt;/p&gt;&#xA;&lt;p&gt;This section stated that the order of evaluation in C++ is not defined (there are few exceptions), instead it&amp;rsquo;s totally up to the compiler to decide which operand will be evaluated first.&lt;/p&gt;&#xA;&lt;p&gt;For instance, &lt;code&gt;int a = f1() * f2()&lt;/code&gt;; There are no guarantees that &lt;code&gt;f1()&lt;/code&gt; will be evaluated first or &lt;code&gt;f2()&lt;/code&gt; will be evaluated first.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Triaging Firefox Nightly Bugs - It&#39;s fun!</title>
      <link>http://seanfeng.dev/tech/en/traiging_nightly/</link>
      <pubDate>Wed, 10 Aug 2022 02:14:41 +0000</pubDate>
      <guid>http://seanfeng.dev/tech/en/traiging_nightly/</guid>
      <description>&lt;p&gt;You may notice that typing &lt;code&gt;about:crashes&lt;/code&gt; in Firefox brings up all the crashes that&#xA;have occurred in your browser. Do you ever wonder the process of how Firefox engineers&#xA;look into these crash reports and analyze them? In this post, I&amp;rsquo;ll be talking&#xA;about the crash triage process that I&amp;rsquo;ve been involved in for the past few months&#xA;and hopefully, you can find it interesting.&lt;/p&gt;&#xA;&lt;p&gt;This is a group of people whose responsibilities are filing bugs for &lt;code&gt;Nightly&lt;/code&gt;&#xA;crashes if they are valid. It is a small group of engineers so we do a&#xA;weekly rotation to respect everyone&amp;rsquo;s time which also ensures that we have&#xA;coverage on each day.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
