Using AWS Lambda and iOS Shortcuts for One-Tap Access to Community Gates

The residential community where I live uses a smart access control system called “Watchful Domain (守望领域)” which allows opening community and unit gates via a mobile app. However, using the app to open gates involves several steps: open the app → navigate to the gate control interface → find the gate you want to open → tap to open. Moreover, unlocking the phone with a mask on requires entering a password, making the process quite time-consuming. Often, I find myself standing at the community or unit entrance for a while. At one point, I even got into the habit of carrying a physical access card, which is much quicker for opening gates. ...

October 19, 2021 · 8 min · Zhiya

Avoiding Common Concurrency Bugs in Go

In the paper Understanding Real-World Concurrency Bugs in Go, several researchers analyzed common concurrency bugs in Go and validated them in some of the most popular Go open-source projects. This article organizes the common bugs mentioned in the paper and provides an analysis of solutions. The paper categorizes bugs into two types: blocking and non-blocking: Blocking: A goroutine gets blocked and cannot continue execution (e.g., deadlock). Non-blocking: Execution is not blocked, but there is a potential data race (e.g., concurrent writes). Blocking Bugs Blocking bugs have two root causes: shared memory (e.g., getting stuck on a lock operation intended to protect shared memory) and message passing (e.g., waiting on a channel). The study found that the number of bugs caused by shared memory and message passing is comparable. However, since shared memory is used more frequently than message passing, it was concluded that shared memory is less likely to lead to bugs. ...

August 17, 2021 · 5 min · Zhiya

Issue with ORDER BY Not Working in MySQL Subqueries

By chance, I discovered that an SQL statement produced different results when executed on different MySQL instances. Problem Description To simulate a business scenario, we create two tables: product_tbl for products and product_operation_tbl for product operation records. The structure and data are as follows: Next, we need to query the latest modification time for all products using the following statement: select t1.id, t1.name, t2.product_id, t2.created_at from product_tbl t1 left join (select * from product_operation_log_tbl order by created_at desc) t2 on t1.id = t2.product_id group by t1.id; From the results, we can see that the subquery first sorts all records in product_operation_log_tbl in descending order by creation time (created_at), then performs a join with product_tbl, thus retrieving the latest modification time for the products. ...

July 29, 2021 · 3 min · Zhiya

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