December 6, 2023
Abandoning the migration from Next.js to Astro.js
Sharing the journey from migration to abandonment using Astro.js
November 15, 2023
The Ingenious Use and Pitfalls of Go Type Embedding in Deserialization
The usage and tricks of struct embedding in Go language, including replacing field types and handling JSON deserialization. Be aware of some pitfalls when dealing with JSON deserialization of nested structs.
June 18, 2023
A Brief Analysis of Telegram's Rich Text Rendering Mechanism
An analysis of Telegram's TDLib API, including the data structure and rendering scheme of rich text data.
January 24, 2022
Interacting with the Frontend Using gRPC
Interacting with the frontend using gRPC. gRPC-Gateway is suitable for supporting both rest and grpc interfaces simultaneously, allowing existing systems to smoothly transition from rest to grpc; gRPC-Web is suitable for direct interaction between the frontend and backend using the gRPC protocol, providing support for HTTP/1.x. It supports Unary and Server Streaming, but does not support Bi-directional Streaming and Client Streaming.
January 12, 2022
Server-side Real-time "Animation" Rendering
In this article, the author shares a method for real-time updating of a portion of data on a webpage: using multipart/X-Mixed-Replace format to render MJPEG images. The author demonstrates the feasibility of this method by implementing a server-side rendering service for Game of Life.
January 1, 2022
Using gRPC in Production Environment
This article summarizes the process of using gRPC in a production environment, including using gRPC-Gateway to be compatible with HTTP/JSON interfaces, defining ProtoBuf RPC interface mapping, mounting gRPC-Gateway, providing interfaces for the front end, etc. It also mentions some potential pitfalls, such as polymorphic types and null value handling.
December 29, 2021
Customize Your Instant Yellow Page Domain
Use Cloudflare Worker to implement a custom domain for Jike Yellow Page, allowing you to enjoy the sense of accomplishment. This process is actually a general process of using Cloudflare Worker to implement reverse proxy.
December 20, 2021
Trying Out Go1.18
Understand how to install Go1.18beta1 and how to solve the problem that vscode cannot parse code containing generics.
December 11, 2021
Considering Optional and Required Fields in ProtoBuf
What changes have the optional and required fields in ProtoBuf, especially the reintroduction of the optional keyword, brought about for considerations of extensibility and type safety? This article summarizes some experiments done with TypeScript and Go's gRPC, proposing two implementation methods for optional fields. Through comparison, we can better understand the role and significance of optional.
December 3, 2021
A Little Optimization on the Loading Volume of Blog Web Pages
This article introduces methods for optimizing the loading volume of blog web pages, including optimizations for Syntax Highlighter, lodash, and Chakra UI, as well as how to control the size of NEXT_DATA. Through these optimizations, the volume of the web page has been significantly reduced, and the JS volume of the first page load has decreased from 200+KB to 70+KB.
October 25, 2021
Understanding Exception Handling in Go singleflight
Understanding exception handling in Go singleflight, this introduces the usage of Go's singleflight library and its exception handling methods.
September 26, 2021
Using Podman instead of Docker on MacOS
Sorry, I can't proceed without a text to translate. Could you please provide a line of text?
September 23, 2021
In-depth Understanding of Go Comparable Type
This article mainly introduces the Comparable type in Go language, including the comparison rules of Go's built-in types, the implementation method in the reflect package, and related pitfalls and applications. The article points out that apart from Map, Slice, and Func, most types in Go are Comparable, where Struct and Array depend on the support of member types. To avoid related issues, it is recommended to use pointer types or Struct types that cannot be forged as the Key of Context.
September 11, 2021
The Principle of Go sync.Once
Understand the working principle of sync.Once in Go. Implement the double-check lock singleton pattern through atomic and Mutex, ensuring that a task is executed only once.
August 29, 2021
gRPC and "Extensible Programming"
This article explores how to achieve backward compatibility and extensibility through gRPC, including all fields being optional, the use of UnimplementedServer, input and output must be structured, each RPC has its own input and output types, etc. The aim of the article is to help us create interfaces that are easier to maintain and extend.
August 21, 2021
String Interning in Go
Introducing the String Interning technology in Go, which can reduce memory usage and improve performance in specific scenarios. The technique of using String Interning has been widely used, such as easyjson, which can introduce String Interning during deserialization.
July 31, 2021
Elegantly Building Go Microservices on Vercel
This article introduces how to build Go microservices on Vercel, including writing code, customizing routes, Monorepo, RPC, scheduled tasks, log monitoring, databases, and Integrations, etc. Compared to building your own K8S cluster or AWS Lambda, using Vercel's cloud functions can significantly reduce maintenance costs, but it's important to note that Vercel's functionality is limited.
May 29, 2021
Server-Side Events: Simple and Efficient Server Push
Server-Side Events is a simple and efficient server-side push mechanism, more real-time than traditional polling and long polling, with less network overhead, implemented using HTTP. For the server side, it is simpler and lighter to implement. It is suitable for message subscriptions displayed on the front end.
March 19, 2021
How to Correctly Handle Errors in Go Echo
This article introduces the correct way to handle errors in Go Echo, covering the error handling process in Echo, the differences between HTTPErrorHandler and Error Handle Middleware, and the order of middleware, etc. The article elaborates on how to avoid HTTP/500 errors caused by mistakes, ensuring that the final response meets expectations, and also provides some suggestions on how to properly use middleware.
March 1, 2021
The Practice of Golang in Jike's Backend
This article introduces the process and practice of the backend service reconstruction of Jike, as well as the results and solutions after the reconstruction. Through the advantages of the Go language and the optimization of Jike's backend services, the overhead of the new version of the service has been significantly reduced. The article also introduces the experience of repository structure, continuous integration, and construction.
October 31, 2020
Got a New Keyboard
The article introduces the author's experience of buying a new keyboard, compares several alternative options, and finally chooses Niz 66. This keyboard supports Bluetooth connection and dual-mode, has a rich key layout, is silent, and has a good touch. Summary: Buying a new keyboard.
July 5, 2020
Use GSuite Like a PRO
May 1, 2020
A Little Understanding of Go Programming Philosophy
Go programming philosophy: explicit errors, strict typing, concise source code, no generics, low cognitive load.
April 4, 2020
Initialization of struct in Go
This article explains the initialization methods of struct in Go language, various data types, and the combination methods of struct, etc. The article summarizes the different initialization methods and their differences, introduces the initialization of embedded struct, and the initialization methods of types that need make, such as slice, map, channel, etc.
October 10, 2019
Pitfalls in MongoDB Read-Write Separation
Pitfalls in MongoDB read-write separation. Master-slave replication leads to non-real-time return of write operations, solutions include Write Concern mechanism, etc. See the article for details.
September 10, 2019
PlantUML as a Document
Use PlantUML to draw UML diagrams in Markdown documents. PlantUML is a tool that relies on DSL to draw UML diagrams. This tool supports many types of diagrams, and related materials can be found in Chinese documents. You can use the PlantUML server to render images for frontend display. This tool is managed with Git in sync with the code, making it very suitable for engineering document management.
September 6, 2019
Switching from Google Passports to 1Password
Switching from Google Passwords to 1Password has solved the pain points of password management, and also brought more features. However, when deleting old passwords, I encountered a problem and could only delete them one by one through a script.
August 22, 2019
Some Thoughts on JWT
The advantages and disadvantages of JWT, as well as its design philosophy and implementation methods, including the combination of AccessToken+RefreshToken, what information should be included in AccessToken and RefreshToken, and whether different KeyPairs should be used. At the same time, it discusses how to blacklist a set of Tokens and implement zero-delay forced logouts.
March 14, 2019
Manage Windows with dotfiles
Manage Windows using dotfiles, dataize the configuration process, and achieve quick backup and device migration through Git and soft links. It is recommended to use dotfiles to manage PowerShell style files, startup scripts, Telegram font configuration files, VSCode configuration files, etc. Here is the address of my dotfiles repository.
February 8, 2019
Reflections on Personal Project Architecture
Thoughts on Personal Project Architecture: In the current popularity of microservices and front-end and back-end separation, why should we do this? For personal development, there is no problem of division of labor in itself, doing so instead brings me a lot of unnecessary trouble. For simple personal projects, if the front end is just a CRUD display of the back-end data foundation, there is no need to separate. After "compressing" the entire system, I can package the entire project into a docker image with a single command, or directly go live on AppEngine, no longer need to worry about subsequent maintenance.
February 6, 2019
Share Jike messages with your Telegram friends in a graceful manner.
Share Jike messages to your Telegram friends elegantly. Use Jikeview Bot to parse Jike links and convert them into the most user-friendly graphic content for Telegram users, supporting GIFs, videos, and multiple images. Come and experience it!
February 1, 2019
Getting Started with Surface Go
"Getting Started with Surface Go" is an article that introduces the user experience of Surface Go, mainly focusing on its advantages such as portability and battery life, but also mentions issues related to touch screen experience and performance. The article introduces the purchasing experience and usage tips, and concludes that Surface Go is suitable for users who need a portable device for work and study.
January 21, 2019
Attempting Real-Time Rendering of "Screenshots"
This article introduces how to use HTML and CSS to render screenshots in real-time within the article. The article elaborates on how to render HTML and CSS, including inline styles, `<style>` tags, and CSS file loading, along with example demonstrations.
January 17, 2019
Building a blog with Notion
Building a blog with Notion solves problems found on other platforms, including the inability to customize domain names, poor user experience, and the hassle of static blogs, etc. Notion's API is semi-public, allowing web pages to be created through the API, and treating Notion as a CMS similar to Wordpress to manage blogs. The page loading speed is improved through backend rendering and CDN services, while the use of Cloudflare's services enhances SEO efficiency. By configuring the Table Page, establishing corresponding columns and views, the content and display of articles are controlled. Ultimately, the goal of building a blog with Notion is achieved.
January 9, 2019
Introducing the philosophy of refactoring, and how to refactor code in daily practice. The most striking part of the article is the author's philosophy on refactoring, emphasizing that refactoring is a major project, but this project should be interspersed in daily development to ensure the robustness of future systems. At the same time, the article mentions that the development process needs to be divided into two aspects, feature development and code refactoring, which cannot be carried out simultaneously. This point is crucial because the goals of the two are different, and doing them at the same time will turn the code into a tangled mess.
January 8, 2019
Recalling a Google Cloud Ban
The experience of being banned by Google Cloud, when using Docker Image, the authorization file was made public, and the project was suspended. It is necessary to pay attention to the way of managing authorization files and the risk of placing private keys in the project directory.
January 1, 2019
A few products I liked in 2018
A few products I liked in 2018: Windows Subsystem Linux and Notion.
November 23, 2018
Bitbucket Pipeline + Docker + Gradle Automatic Deployment Practice
Bitbucket Pipeline + Docker + Gradle Automatic Deployment Practice. Use Bitbucket Pipeline service to achieve continuous integration, and package the project into a docker image, updating the code by pulling the latest image. Use Gradle Docker Build to handle Docker packaging, use GCR to host the image, and deploy using vps instances. Achieve automatic deployment by writing Pipeline scripts.
September 12, 2018
Zhejiang University Router Configuration Guide
Zhejiang University Router Configuration Guide, introduces the methods of using a router in a campus network environment. This includes using a Linux client and simulated login methods, as well as the usage of a campus network verification script.
August 10, 2018
Practical Implementation of Reverse Proxy Cross-Domain on Github Pages
Configure nginx reverse proxy and letsencrypt to solve the cross-domain issue of web apps on Github Pages. By forwarding the front-end traffic to the nginx server, and then using nginx reverse proxy to proxy the front-end to Github Pages, and the API to the backend server. At the same time, configure certbot of letsencrypt to implement Https redirection.
August 9, 2018
Recalling a Deployment on GitHub Pages
This article mainly introduces how the author deployed a small toy written in React to Github Pages. The article details the problems encountered during the deployment process and their solutions, which is very practical for developers who need to deploy their projects to Github Pages.
November 16, 2016
A Brief Analysis of RxActivityResult Principle
This article introduces the principles and source code analysis of the RxActivityResult library, which implements data interaction between two Activities by launching a proxy Activity. By packaging Intent and callback interfaces, it launches HolderActivity and provides it with the Request, then HolderActivity starts the target Activity and accepts the returned results, finally passing the results to the subscribers through the callback. In addition, the article also mentions a similar library, RxPermissions.