One-Click Proxy Setup for WSL2

Cloning a large git project in the WSL2 environment can be slow without a proxy, so I explored how to route WSL2 through Windows’ proxy client. Differences in Networking between WSL1 and WSL2 In the WSL1 era, since the Linux subsystem and Windows shared network ports, accessing Windows’ proxy was straightforward. For instance, if the Windows proxy client was listening on port 8000, you could simply execute the following command in the Linux subsystem to route requests through the proxy: ...

June 30, 2020 · 2 min · Zhiya

WSL2 Installation Guide for Developers

Why Use Windows for Development For a long time, macOS has been favored by programmers for its Unix-like features. However, in recent years, Apple has rarely introduced groundbreaking hardware products. The removal of the Esc key, the use of butterfly keyboards, almost zero hardware upgradability, and tightened system permissions have made Macs less suitable for programming than before. On the other hand, the PC ecosystem has maintained software openness while its hardware experience has gradually caught up with or even surpassed Macs. I no longer want to use a Mac for development and a PC for gaming; I hope to use one computer for both gaming and development, so I’ve returned to the PC camp. ...

June 1, 2020 · 6 min · Zhiya

The Peculiar Behavior of Docker COPY When Copying Directories

Problem Description When creating a Docker image, there is a need to copy all files and directories from a certain path into the image. The following Dockerfile was written: FROM alpine WORKDIR /root/test_docker_proj COPY * ./ The original directory structure is as follows: /projects/test_docker_proj ├── Dockerfile ├── dir1 │ ├── dir11 │ │ └── file11 │ └── file1 └── file2 However, the directory structure copied into the Docker image turns out like this: ...

October 28, 2019 · 2 min · Zhiya

Solution Approach for Using Proxy in Docker Build

Problem Description When using docker build to package an image, there is a need to access the network via a proxy. The following Dockerfile simulates this scenario: FROM golang:1.12 RUN curl www.google.com --max-time 3 In a typical network environment in China, curl www.google.com cannot return normally. The --max-time option is added to ensure the curl command does not take too long. Configuring the http_proxy Variable First, you need to set the http_proxy and https_proxy environment variables so that network access commands (represented here by curl) can access www.google.com through the proxy server configured in the environment variables. ...

April 18, 2019 · 3 min · Zhiya

Understanding the Behavior of the count Function in PostgreSQL

The use of the count function has always been a topic of debate, especially in MySQL. As PostgreSQL gains popularity, does it have similar issues? Let’s explore the behavior of the count function in PostgreSQL through practical experiments. Building a Test Database Create a test database and a test table. The test table includes three fields: an auto-increment ID, a creation time, and content. The auto-increment ID field is the primary key. ...

April 16, 2019 · 7 min · Zhiya