ZSH 自动补全配置

我最喜欢的 shell 是 zsh,它的自动补全功能非常强大,但是经过长期的使用我也感受到一些问题。为了解决这些问题,我查找资料并按自己的喜好配置了它的自动补全系统。本文记录了我的配置。

阅读更多

Run Cloudflare WARP in Docker

Cloudflare WARP is a free VPN service provided by Cloudflare. As most service providers consider its exit IP as a reputable residential broadband IP, many people use it for accessing websites that have strict risk control policies, especially when their server’s IP address is not clean. However, when we use it on our own servers, we may encounter the following issues:

  • The official WARP client, in the default mode 1.1.1.1 with WARP, blocks all inbound connections, which means that websites and services on servers cannot be accessed.
  • Although the official WARP client in Local Proxy mode does not have the problem of blocking inbound connections, the HTTPS/SOCKS5 proxy it provides cannot transmit UDP packets.
  • In order to prevent abuse, Cloudflare blocks third-party clients (such as wgcf) from accessing WARP services in some regions, and it is currently unknown whether this measure will be extended to other regions.

This article will run the official WARP client in Docker to solve the above problem.

阅读更多

在 Docker 中运行 Cloudflare WARP

Cloudflare WARP 是 Cloudflare 提供的免费 VPN 服务,由于多数服务商都将其出口 IP 视作信誉良好的家宽 IP,许多人将其用于 IP 地址较脏的服务器,以便访问风控较严格的网站。然而当我们将它在自己的服务器上使用时,会遇到以下的问题:

  • 官方 WARP 客户端在默认模式 1.1.1.1 with WARP 下会阻断所有入站连接,这意味着服务器上的网站和服务都无法被访问
  • 官方 WARP 客户端在 Local Proxy 模式下尽管没有阻断入站连接的问题,其提供的 HTTPS/SOCKS5 代理并不能传输 UDP 数据包
  • 为了防止滥用,Cloudflare 在部分地区阻止了第三方客户端 (wgcf 等) 访问 WARP 服务,暂不清楚它是否会扩大该措施的范围

本文将在 Docker 中运行官方 WARP 客户端,以解决上述问题。

阅读更多

在无头设备上使用 matplotlib

matplotlib 是一个被广泛使用的 Python 绘图库,但是在远程服务器等无头设备上使用时,可能会遇到 plt.show() 无法显示和缺少中文字体的问题。本文将介绍如何解决这些问题。

阅读更多

使用 Deploy key 将私有 GitHub 仓库克隆到境内服务器

由于某些原因,我们往往无法直接在境内服务器上克隆 GitHub 上的仓库。对于公开仓库,我们可以通过公益或自建的反向代理来解决这个问题。但是当我们希望将仓库保持私有时,我们遇到了以下几个问题:

  1. 我们不希望将自己的凭据上传到服务器,因此需要使用权限较低的 personal access token
  2. 很多反向代理方式,尤其是公益的,并不支持传递 personal access token
  3. 在服务器上使用 personal access token 配合反向代理进行 HTTPS clone 将会向反向代理服务器暴露该 token

本文将通过转发 GitHub 的 SSH 端口并使用 Deploy key 来解决这些问题。使用该方案,服务器上的凭据将仅限于读取指定仓库,且中间人无法获得你的凭据。

阅读更多

搭建基于WSL的开发环境

本文已过时

本文撰写于 2022 年 7 月 8 日,它已经过时。我当前 (2023-07-17) 的开发环境已经和本文中大为不同:

  • 不再使用 socks5 代理而是使用 TUN,这样就不需要对 WSL 进行额外的配置
  • Docker 现在有更好的安装方案,安装一个 Docker 就可以同时在 Windows 和 WSL 上使用,且可以使用开发容器

建议未来的读者在准备 WSL 开发环境时参考微软 WSL 文档的 Tutorials 部分。

更换硬盘并重装了电脑之后,我计划将所有开发环境都放在 Windows Subsystem for Linux (WSL) 上,以避免在 Windows 上遇到依赖地狱。这篇文章介绍了我对基于 WSL 的开发环境的搭建过程。

阅读更多

zsh配置

这篇文章讲讲我的 zsh 配置。zsh 的安装可以参考这里

zsh 是Linux系统诸多 shell 中的一种,比默认的 bash 多了很多功能,也支持自定义。

阅读更多