跳至主要内容

博文

目前显示的是 2022的博文

顺手拷贝的一个 build.gradle.kts

Gradle 的 `build.gradle` 通常都是用 Groovy DSL 来编写的。随着 Kotlin 流行,Gradle 也慢慢开始支持 `build.gradle.kts`。 刚好看见一个简单的 sample,顺手放在这里 ```kotlin plugins { `java-library` "jacoco" } repositories { mavenCentral() } dependencies { implementation("jakarta.inject:jakarta.inject-api:2.0.1.MR") implementation("jakarta.ws.rs:jakarta.ws.rs-api:3.1.0") implementation("jakarta.servlet:jakarta.servlet-api:5.0.0") implementation(project(":home-made-lib")) testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") testImplementation("org.mockito:mockito-core:4.5.1") testImplementation("org.eclipse.jetty:jetty-server:11.0.9") testImplementation("org.eclipse.jetty:jetty-servlet:11.0.9") } tasks.withType () { useJUnitPlatform() } java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } ```

Ubuntu 安装和配置 NeoVim

最近想试试 NeoVim,在 Windows 10 WSL 的 Ubuntu (20.04) 里安装 neovim 是非常方便的,[用 Snap](https://askubuntu.com/questions/430008/how-to-install-neovim-on-ubuntu) 就可以了。 sudo apt install neovim 如果需要将 Neovim 设置为常用的编辑器,最好[利用系统的 Alternatives 设定](https://blog.aktsbot.in/vim-to-neovim.html),以取代常见的默认程序 (如 `/usr/bin/vim.basic`)。 ```bash $ sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60 $ sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60 $ sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60 ``` [除了以上这几个命令之外,还有 ex, vi, vim, editor, view, vimdiff 等等](https://stackoverflow.com/questions/65889273/how-do-i-add-nvim-to-update-alternatives-when-using-snap-under-ubuntu),都可以使用类似的命令来替换。 值得一提的是,不像 `vim`,`neovim` 不再支持各种 alias commands,而是推荐直接调用 `nvim` 时传入相应的 args 来进入需要的模式,例如 `nvim -R` 就类似于 `view`;`nvim -d` 类似于 `vimdiff`。可以参考这两个 GitHub Issues: - https://github.com/neovim/neovim/pull/2008 - https://github.com/neovim/neovim/issues/1646

[Resources] Golang, Kotlin, JS and Misc

周末看的几篇文章提到了一些有用的资源,记录一下: - Golang 1. [awesome-go](https://github.com/avelino/awesome-go) 2. [Effective Go](https://go.dev/doc/effective_go) - Kotlin 1. [Coding Conventions](https://kotlinlang.org/docs/coding-conventions.html) - JavaScript 1. [Prototype Chain](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Inheritance_and_the_prototype_chain) - Web 1. [MS Restful API Guideline](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md) 2. [Hardening Your HTTP Security Headers](https://www.keycdn.com/blog/http-security-headers)

Requests Pipelining and Size Estimation

这两周刚好在看和 requests pipelining 有关的 Netty 代码,找到了挺有意思的文章: 1. [Pipelining requests](https://aphyr.com/posts/267-pipelining-requests) 2. [Estimate size of objects in OrderedMemoryAwareThreadPoolExecutor](https://aphyr.com/posts/269-reaching-200k-events-sec) 这里提到的 [Riemann](https://riemann.io/) 是一个分布式监控软件,用 Clojure 语言开发的(GitHub 代码库[地址](https://github.com/riemann))。

Create Symbolic Link using PowerShell

类似于 Linux 的 `ln -s` 命令,Windows PowerShell 也支持在文件系统中创建 SymbolicLink。 例如,为了方便在 Visual Studio Code中预览 Markdown 的图片,就可以建立软链接: ```PowerShell cd src\main New-Item -Path .\markdown\frontend\img \ -ItemType SymbolicLink \ -Value .\resources\frontend\images\ ```

WSL invalid option when executing shell script

有一个 bash script,在MacOS里执行的顺利无比,但是一到 WSL 里头就总是出问题。 : invalid option 一开始怀疑是 shebang 哪里写错了,后来发现不对,貌似和 '^M' 有关。最后在[这里](https://newbedev.com/bad-interpreter-bin-bash-m-code-example)看到了类似的提示,果然是linefeed要替换! sed -i -e 's/\r$//' $FILE.sh

"The Java Version Almanac"

看了看从 Java 8 到 17 的 changes。 从 [这篇文章](https://ondro.inginea.eu/index.php/new-features-in-java-versions-since-java-8/) 发现了个有意思的 [Java 年鉴](https://javaalmanac.io/),非常用心地将历代 API 的变化都标注了出来。 仔细看了看,该网站的作者之一 Cay Horstmann 就是当年俺初学 Java 时读的 Core Java 的作者。