Svoboda | Graniru | BBC Russia | Golosameriki | Facebook

WSL导入导出

默认情况WSL会安装在C盘,可以将其迁移到其他盘,这里使用WSL提供的导入和导出命令。

关闭所有的WSL,查询要导出的名称:

PS > wsl --shutdown
PS > wsl -l -v
  NAME            STATE           VERSION
  Ubuntu-22.04    Stopped         2

将要导出的WSL保存到D盘:

PS > wsl --export Ubuntu-22.04 D:\Ubuntu-22.04.tar


Use tldraw in Vite

Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects. Is consists of two major parts:

  • A dev server that provides rich feature enhancements over native ES modules, for example extremly fast Hot Module Replacement(HMR).
  • A build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production.

tldraw is a library for creating infinite canvas experiences in React.



C++折叠表达式

折叠表达式(Fold Expressions)是C++17标准引入的,引入折叠表达式的主要目的是计算某个值。这个值的特殊性在于:它与可变参有关,而不是与单独某个可变参有关。换句话说,所有的可变参都参与计算,才能求出该值。在可变参函数模板中,因为展开参数比较麻烦,如果要把传递进来的所有参数加在一起,可能要写很多代码,而通过折叠表达式,只需要一行代码就可以求出所有可变参的和。

template<typename... T>
auto add_val(T... args)
{
    return (... + args);
}

在上面的例子中,return语句后面的括号中就是一个折叠表达式。



C++可变参函数模板

可变参模板的英文为Variadic Templates,是C++11标准引入的,可变参模板允许模板定义中含有0到多个模板参数。

template <typename... T>
void myvtfunct(T... args)
{
    cout << sizeof...(args) << endl;
    cout << sizeof...(T) << endl;
}

typename后面的3个点代表参数包,然后才修饰T。T后面带了3个点,所以将T称为可变参类型,实际上其中包含了0到多个不同的类型(一包类型),args成为一包或一堆参数。



卡尔曼滤波

我不得不说说卡尔曼滤波,因为它能做到的事情简直让人惊叹!意外的是很少有软件工程师和科学家对对它有所了解,这让我感到沮丧,因为卡尔曼滤波是一个如此强大的工具,能够在不确定性中融合信息,与此同时,它提取精确信息的能力看起来不可思议。

什么是卡尔曼滤波

你可以在任何含有不确定信息的动态系统中使用卡尔曼滤波,对系统下一步的走向做出有根据的预测,即使伴随着各种干扰,卡尔曼滤波总是能指出真实发生的情况。

在连续变化的系统中使用卡尔曼滤波是非常理想的,它具有占用内存小的优点(除了前一个状态量外,不需要保留其它历史数据),并且速度很快,很适合应用于实时问题和嵌入式系统。

在Google上找到的大多数关于实现卡尔曼滤波的数学公式看起来有点晦涩难懂,这个状况有点糟糕。实际上,如果以正确的方式看待它,卡尔曼滤波是非常简单和容易理解的,下面我将用漂亮的图片和色彩清晰的阐述它,你只需要懂一些基本的概率和矩阵的知识就可以了。



李白《侠客行》

赵客缦胡缨,吴钩霜雪明。银鞍照白马,飒沓如流星。

十步杀一人,千里不留行。事了拂衣去,深藏身与名。

闲过信陵饮,脱剑膝前横。将炙啖朱亥,持觞劝侯嬴。

三杯吐然诺,五岳倒为轻。眼花耳热后,意气素霓生。

救赵挥金锤,邯郸先震惊。千秋二壮士,烜赫大梁城。

纵死侠骨香,不惭世上英。谁能书阁下,白首太玄经。



Define Emacs Formatter

Steve Purcell has created a package reformatter, which can define commands to format the current Emacs buffer.

The reformatter-define macro expands to code which generates xxx-buffer and xxx-region interactive commands, and a local minor mode called xxx-on-save-mode. The :args and :program expressions will be evaluated at runtime, so they can refer to variables that may have a buffer-local value. A custom variable will be generated for the mode lighter, with the supplied value becoming the default.



苏轼《定风波》

莫听穿林打叶声,何妨吟啸且徐行。竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。

料峭春风吹酒醒,微冷,山头斜照却相迎。回首向来萧瑟处,归去,也无风雨也无晴。



Build Emacs On Windows

On Windows, we can build GNU Emacs with MSYS2 and MinGW-w64.

First, install some necessary packages. The packages include the base developer tools, the compiler toolchain, several image libraries, and XML library, the GnuTLS library, zlib for decompressing text, HarfBuzz for use as the shaping engine, libgccjit for native-compilation support, SQLite3 for accessing SQL databases, and the tree-sitter library used by some major modes. You can select only part of the libraries if you don't need them all.



Build Emacs From Source

Windows 11 features built-in support for running Linux GUI applications. Emacs 29 has became a real GTK application, gone with the blurry fonts problem.

Firstly, install essential packages in WSL2 Ubuntu 22.04.

apt-get update
apt-get install build-essential libgtk-3-dev libgnutls28-dev libtiff5-dev libgif-dev libjpeg-dev libpng-dev libxpm-dev libncurses-dev texinfo sqlite3 libsqlite3-dev libjansson4 libjansson-dev autoconf


Math Equation With Org Mode

LaTeX math snippets can be displayed on HTML pages which exported with org-mode. The default is to use the MathJax.

If $a^2=b$ and \( b=2 \), then the solution must be either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].

If \(a^2=b\) and \( b=2 \), then the solution must be either \[ a=+\sqrt{2} \] or \[ a=-\sqrt{2} \].



Valar Morghulis. Valar Dohaeris.

Top