One Month Using Android – A Migration Tale
10 minAs someone who changes phones frequently, I’ve made the switch from OnePlus to iPhone, gradually shifting from the joy of tinkering to a reliance on ecosystems. Recently, at the suggestion of my partner, I picked up an Oppo Find X8 Ultra, mainly to upgrade my photography game. Although deeply ingrained in the Apple ecosystem, migrating apps made me realize the Android app landscape is still hit-or-miss and searching for alternatives can be a challenge. After a month, the friction and adaptation between platforms has been palpable.
Integrating Google Analytics (Tag Manager) with Astro
2 minAfter migrating my blog to the Astro framework, I found that the usual method for integrating Google Analytics no longer fit the bill due to performance concerns. While it's possible to add JavaScript directly to the head tag for event reporting, this dampens page performance. To preserve Astro's signature efficiency, I opted for Partytown to offload scripts from the main thread—keeping the load process smooth. Building on available demo code, I achieved seamless Google Analytics integration, balancing performance with data analytics needs.
Travelogue: Kansai Region(2025.4)
10 minOne weekend in April,a colleague said, 'Let's go to Japan,'so, off we went to Japan.
Cross-City Network Setup: Shanghai & Hangzhou Experience
9 minDue to my girlfriend’s job transfer, she recently moved from Beijing to Shanghai, so I helped her get settled and took care of the broadband installation. Despite signing up for a 500M China Telecom connection, the price was even higher than the 1000M plan in Hangzhou—pretty frustrating! Against this backdrop, I decided to engineer a cross-city network setup allowing for transparent proxy in Shanghai, routing some traffic out via Hangzhou, and seamless LAN communication between both locations. The Hangzhou side was straightforward: a soft router paired with a wireless AP provided a stable ‘home-routing’ solution. Now, it’s time for a new networking challenge!
My Heart Beats for U —— Heart Rate Sync Visualization in Grafana
3 minBy periodically syncing Apple Health heart rate data to a server and visualizing it with Grafana, I created an intuitive way to monitor health. Using the Health Auto Export app’s Restful API, I send heart rate information to a custom HTTP endpoint, store it in InfluxDB, and ultimately display clear dashboards in Grafana—making it easy to track and analyze personal heart rate trends.
Resolving Typename-Variable Name Ambiguity in Syntax Parsing
7 minIn the process of syntax analysis, confusion between user-defined type names and ordinary variable names is a major challenge. For instance, in statements like `a*b;`, the code could be read as either a mathematical expression or a type declaration. This ambiguity stems from grammar design, especially around type specifiers, where a variable identifier might be misinterpreted as a type name, affecting correctness and readability. As uninitialized variable declarations become more common, this issue is increasingly prevalent in source code.
VPS Bundling with Warp: Selective IPv6 Egress with Traffic Splitting
3 minOn a regular afternoon, a Telegram notification sparked excitement for a new VPS package: direct China Telecom CN2 connectivity, 2.5G bandwidth, and a tempting deal. The package came with built-in IPv6, making it perfect for media unlocking—but not all traffic should run through Warp. While previous scripts were convenient, they lacked speed and flexible traffic control. A more refined solution was clearly needed.
Implementing a Dynamic "Memos" (Shuoshuo) Feature in VitePress
18 minIn dynamic blogs, adding a 'Memos' feature can greatly enhance the user experience. Unlike the cumbersome process required by static blogs, this feature allows users to post short thoughts anytime and anywhere, lowering the psychological barrier for sharing. By leveraging CloudFlare Workers for backend logic and KV storage for data, developers can easily manage memos. On the frontend, a Vue component embedded in the VitePress framework provides a lively, interactive display of these dynamic entries, enriching the blog with real-time flair.
Implementing OPNsense Transparent Proxy + Traffic Routing
7 minOPNsense, an open-source firewall and routing platform, has gained attention for its elegant UI and comprehensive features. After exploring various routing solutions, its powerful potential for transparent proxying and traffic segmentation became clear. Combining BGP-based routing, OPNsense offers enhanced security and stability, making it an ideal network management solution. Its automatic IP list updating functionality further simplifies network administration.
More Accurate Domestic and International IP Routing Based on BGP
4 minA BGP-based domestic and international IP routing scheme that enhances the efficiency and precision of transparent proxies. By tagging foreign IPs with FakeIP, the main router can intelligently route traffic to ensure smooth network connections. The DNS module configuration in sing-box is also optimized for greater flexibility and efficiency when handling DNS queries, further improving the overall network experience.
It's Not Impossible to Stay Somewhat Mentally Healthy After Three Years at ByteDance
9 minThree years at ByteDance, and it's as if time has quietly accelerated. Amid rapid change, it’s still possible to find a sliver of mental balance. I remember my early confusion: a young me, standing on the balcony of Hangzhou Bafang City, gazing at the distant mountains, full of expectation and curiosity for the future. As time went on, work challenges and personal growth intertwined. This created a unique, vibrant experience—and taught me how to find my own rhythm amidst the hustle.
The Long Road to Treating Chronic Gastritis
3 minThe journey to treating chronic gastritis has been full of twists and turns. From childhood digestive discomfort to a miraculous recovery during university, then worsening again with workplace indulgences, stomach pain has become a recurring theme in my life. Although my symptoms mysteriously vanished for a while, staying up late and drinking brought the issues back. Frequent nausea and reflux made life unbearable. After multiple medical checks and serious reflection, I’m finally taking this long and complicated treatment process seriously.
Transparent Proxy Routing Based on FakeIP
9 minThe FakeIP-based transparent proxy routing solution aims to address the common pitfalls of conventional bypass router setups, such as single points of failure, limited performance, and complex port forwarding. By introducing sing-box as the new proxy core, the solution not only boosts forwarding performance but also streamlines configuration. With richer protocol support and better optimization, sing-box clearly outperforms clash and emerges as a compelling choice for efficient transparent proxies. While similar results are achievable with clash, the adoption of sing-box delivers a more flexible user experience.
Solving Port Forwarding Failures with Bypass Routers
3 minWhen using a bypass router setup, port forwarding on the primary router often fails. This happens because the gateway configuration of the bypass router changes the forwarding path of network traffic, rendering port forwarding settings on the main router ineffective. The core function of a gateway is to perform address translation, routing internal traffic to the outside world; every internal device requires a gateway to communicate externally. Understanding this mechanism is key to resolving port forwarding failures.
Side Routing Solution with Debian
10 minThe Debian bypass router solution offers users a more stable and flexible choice, breaking free from dependencies on OpenWRT and LuCI. By running configurations directly on Debian, users gain greater system control and steer clear of the limitations and instability that often come with web GUIs. Compared to common bypass router setups, Debian’s approach delivers more reliable transparent proxy settings, unlocking new possibilities for those prioritizing performance and efficiency.
An Examination of the GFW’s Principles
11 minThe operation of the Great Firewall (GFW) is not merely a simple outbound gateway monitoring system. Instead, it employs a side-channel tapping technique to inspect international traffic. This approach duplicates all inbound and outbound IP packets to GFW clusters for deep analysis and filtering. Understanding this is crucial for researching circumvention methods, as it reveals the exact blocking paths and technical means. A thorough exploration of the GFW’s network topology can help devise more effective strategies to evade internet censorship.
Learning Plan for 2024
1 minMy study plan for 2024 is clear and concrete. My goals include reaching N2 level in Japanese, completing both SICP and TAPL, delving deep into operating systems with the aim of building a fully functional POSIX kernel, and updating my blog’s theme. All of these targets are both challenging and motivating, offering a clear path for personal growth and skill development.
Installing the RISC-V Toolchain and Emulator
2 minWhen installing the RISC-V toolchain, it’s best to start by obtaining the riscv-gnu-toolchain source code. Using the `--depth=1` option when cloning helps reduce download size. Make sure to review the Prerequisites section in the README to ensure all dependencies are properly installed. On Debian systems, installing required packages is straightforward, which ensures a smooth setup of the toolchain.
A Casual Talk on Programming Languages
13 minDesigning a new programming language is both a challenging and fascinating endeavor. By simplifying the complexities of compiler theory and feature implementation—and focusing on how code operates within computer systems—we gain deeper insights into the process of building programming languages. Exploring language design from the ground up based on the RISC-VI instruction set, we uncover the system’s layered structure and the concept of virtual machines. This journey is not just a technical exploration, but also a profound reflection on the true nature of programming languages.
A Failed Project Attempt – Spring Festival "Fun for Seven Days" (Not Really)
8 minInspiration quietly struck during the Spring Festival holidays. While reading an article on running Go programs on bare metal during a train ride, I was intrigued by the possibilities of exploring low-level system interfaces. The author’s successful implementation was exhilarating, especially the seamless blend of a high-level language with OS development. As my research deepened, I found that similar ideas had already been explored; this underlying enthusiasm gradually grew and eventually led to a project full of anticipation—though it, unfortunately, didn't end as I’d hoped.
6.5840 Lab 2a — Leader Election
8 minLab 2a focuses on implementing the Leader Election and heartbeat mechanisms in the Raft algorithm, ensuring normal leadership transfers and elections even under extreme scenarios. This lab lays the foundation for the distributed KV store that will be implemented in later labs and is divided into four steps. By taking a lock-free approach, the complexity of the Raft struct is significantly reduced. The lab guide provides the necessary background, but unlike the previous lab, almost no reference code is provided—emphasizing independent implementation.
Raft Paper Notes
13 minRaft is a consensus algorithm designed to improve the efficiency of log replication, especially suitable for multi-node clusters, ensuring continued service even when some machines fail. This algorithm follows a replicated state machine model, utilizing logs to preserve command order, enabling all machines in a cluster to reach a consistent state. The paper 'In Search of an Understandable Consensus Algorithm' delves into Raft's design philosophy and its comparison with Paxos, highlighting its approachable and easy-to-understand nature, and providing a foundation for building reliable large-scale software systems. This post documents my reading notes on the paper and aims to help unpack its core concepts and applications.
Deep Copying Between Different Types of Structs in Golang
3 minDuring system refactoring, converting between entities at different layers in a layered architecture can be challenging, especially when it comes to deep copying. Take products as an example: the Product VO at the view layer, the Product entity at the domain layer, and the Product PO at the persistence layer all have similar but subtly distinct structures. Minor differences, such as varying data types, often make direct conversions difficult and cumbersome. To address this, I explored using reflection to create a general conversion method, aiming to simplify this process, cut down on tedious assembler functions, and improve code maintainability and flexibility.
The Issue of `this` Keyword Causing Compile-Time Constant Propagation Optimization Failure in Java
3 minIn Java, using the `this` keyword can cause the compiler’s constant optimization to fail. Although `ab1` and `ab2` in the example seem to reference the same final static variable `s`, their comparisons yield different results. `ab1` concatenates strings directly via the static variable, while `ab2` uses `this`, preventing the compiler from applying the same constant propagation optimization, thereby affecting string comparison. This phenomenon reveals how subtle syntax differences in Java can lead to changes in compilation behavior.
The 'Majority of People' in The Three-Body Problem
8 minIn The Three-Body Problem, Liu Cixin, through sweeping historical narrative, explores the complex relationship between the individual and the collective. His skepticism toward Western democracy is ever-present, mirroring an unease about the majority deciding their own fate. The heroes’ countless efforts and sacrifices ultimately seem insignificant in the tide of history, highlighting the individual’s powerlessness in the face of epochal upheaval. The story’s origins in the turmoil of the Cultural Revolution underscore the deep conflict between elites and the average masses, reflecting profound contemplation of human nature and society.
6.5840 Lab 1 – MapReduce
7 minThe goal of Lab 1 is to implement a MapReduce system, which is composed of a master and a worker as its core components. This process requires solid understanding of Golang's RPC mechanism and concurrent programming, as well as a deep comprehension of the MapReduce process itself. My implementation went through two major versions: an initial version using mutex locks and an improved, lock-free version leveraging Go channels, the latter being much more elegant and concise. The key to this lab is to thoroughly read the relevant documentation, especially the provided diagrams and explanations.
MapReduce Paper Review
5 minMapReduce is a highly efficient parallel computing model designed to simplify processing of large-scale datasets. By defining two key functions—Map and Reduce—users can effortlessly break down complex tasks into simple operations. The framework architecture automatically manages data distribution and task scheduling, allowing developers to focus on algorithms rather than low-level details. Its widespread adoption in distributed systems demonstrates its remarkable flexibility and practicality.
Setting Up the Environment for CSAPP Labs
5 minThe lab component is crucial when studying CSAPP, but many students are often put off by the headaches of setting up a Linux environment—especially when using virtual machines. Issues like failed installations, compatibility problems, unstable network connections, and more can discourage even the most patient learners. WSL (Windows Subsystem for Linux) offers an ideal solution for users on Windows 10 version 2004 and above, providing a smoother and more direct Linux experience without the complexity or performance issues of a traditional VM.
MYDB 10. Implementation of Server, Client, and Their Communication Rules
5 minMYDB adopts a classic Client/Server (C/S) architecture similar to MySQL, supporting multiple clients connecting to a server via sockets to execute SQL queries and return results. The communication uses a custom binary protocol, though plaintext transmission is also feasible for simplicity. The data transport structure between server and client ensures efficient data exchange and processing.
MYDB 9. Field and Table Management
6 minThe responsibility of the Table Manager (TBM) is to manage field and table structures. By structurally parsing SQL-like statements, the Parser encapsulates statement information into corresponding classes, which simplifies subsequent operations. This chapter also includes the SQL statement grammar used by MYDB, providing a foundation for understanding the management process.
MYDB 8. Index Management
4 minMYDB implements clustered indexes based on B+ trees. The Index Manager (IM) interacts directly with Data Management (DM), bypassing the Version Manager (VM) layer to ensure index data is directly written to the database file. This section details the structure of the binary tree index, covering the basic elements of a node—leaf marker, key count, and sibling node identifier, etc.—providing the foundational framework for implementing index search.
MYDB 7. Deadlock Detection and VM Implementation
7 minThe VM layer needs to handle version skipping and deadlock issues caused by MVCC. With a simple marking mechanism, MYDB can easily undo or roll back transactions, ensuring that data from aborted transactions never affects others. This design makes transaction processing under concurrency more efficient and reliable, sidestepping the common deadlock risks of traditional 2PL methods and boosting overall system stability and performance.
MYDB 6. Record Versions and Transaction Isolation Levels
9 minThe Version Manager enforces serializability of scheduling sequences using the two-phase locking protocol and introduces Multi-Version Concurrency Control (MVCC) to eliminate read-write blocking. It also defines conflicts in database operations, with a particular focus on the interplay between update and read operations, laying the foundation for understanding transaction isolation levels.
MYDB 5. Page Index and DM Implementation
6 minThe page index is a crucial component of the DM (Data Manager) layer, optimizing insert operations by caching each page’s free space. This mechanism allows upper-layer modules to quickly locate suitable pages, avoiding lengthy search processes and improving data processing efficiency. In terms of implementation, the page index is closely tied to the DataItem abstraction, providing strong support for efficient database operations.
MYDB 4. Log Files and Recovery Strategy
8 minWithin MYDB's design, log files play a crucial role in ensuring smooth recovery after system crashes. Every time the underlying data is manipulated, the DM layer generates and records a log entry, forming a continuous log chain. These logs are stored in a specific binary format containing checksums and various operation records, so that upon system restart, the database can accurately reconstruct its state and maintain data consistency and integrity.
MYDB 3. Caching and Management of Data Pages
5 minThe DM module abstracts the file system as pages, using them as units for data reads, writes, and caching. By default, each data page is 8K in size, which helps to improve write performance under heavy loads. With a general-purpose caching framework already in place, the next step is to define the specific structure of a page for efficient page cache management.
MYDB 2. Reference Counting Cache Framework and Shared Memory Arrays
5 minThe Data Manager (DM) serves as the bridge between upper-level modules and the file system. It is responsible for page and cache management while ensuring data safety and recovery. Notably, for its caching strategy, DM adopts a reference counting framework instead of using the traditional LRU, to improve generality and efficiency and lay the foundation for further data operations.
MYDB 1. Starting from the Simplest TM
5 minIn MYDB, transaction management is implemented through the XID file, with each transaction being uniquely identified by an incrementally assigned XID, starting from 1. XID 0 is defined as the Super Transaction, whose state is always committed. The TransactionManager is responsible for maintaining this file and recording the three states of a transaction: active, committed, and aborted. This mechanism ensures that the status of transactions can be accurately queried and managed, providing a foundation for system stability and reliability.
MYDB 0. Project Structure and Some Things I Have to Say
6 minThe MYDB project is a personal undertaking aimed at exploring and implementing the fundamental principles of databases. After half a month of effort, I gradually completed it in my spare time. I picked up some database basics during college courses, though I have to admit I spent more time slacking off during my internship. Being honest about my lack of knowledge in database system interviews didn’t impact me much, but it did make me reflect on the need to proactively learn and practice database concepts, which ultimately motivated this project.