Skip to content

Blog

Full-Stack Authentication and Authorization Solution

For SaaS development, authentication and authorization are often too tedious to build from scratch in development environments, yet essential for production. This article explains the most cost-effective solution in one go. Core Concepts Authentication Determining the identity of a user. Authorization Determining whether to grant permissions based on the user’s identity. OAuth2 An authorization protocol.

Read more →

Hello, world!

\[ \LaTeX: \text{Hello, world!} \] main.c 1 puts("Hello, world!"); main.cpp 1 std::println("Hello, world!"); main.go 1 fmt.Println("Hello, world!") main.rs 1 println!("Hello, world!") main.cpp 1 IO.println("Hello, world!"); main.kt 1 println("Hello, world!"); Program.cs 1 Console.WriteLine("Hello, world!"); main.py 1 print("Hello, world!") index.js 1 console.log("Hello, world!"); query.sql 1 SELECT 'Hello, world!';

Read more →

LaTeX

Distributions TeX Live: The most mainstream and versatile distribution, supporting Linux, macOS, and Windows. This is what the texlive-* packages in most Linux distributions provide. Suitable for servers, CI, Linux/macOS/cross-platform projects. The TeX Users Group also refers to MiKTeX as the other major free TeX distribution alongside TeX Live. MacTeX: The most recommended choice on macOS — essentially TeX Live packaged for Mac, bundled with Mac-related tools like TeXShop, BibDesk, and Ghostscript. BasicTeX: A slimmed-down version of MacTeX, also based on TeX Live. Ideal for those who don’t want to install a multi-GB package and prefer to install missing components on demand. MiKTeX: Very popular among Windows users, also supports Linux/macOS. Key features include on-demand installation of missing packages and a relatively user-friendly GUI management experience. Best suited for Windows desktop users. TinyTeX: A lightweight LaTeX distribution based on TeX Live. Cross-platform, portable, and especially suited for R Markdown / Quarto / Pandoc / CI scenarios. Tectonic: A modern, single-binary TeX/LaTeX engine based on XeTeX and TeX Live resources. Focuses on automatic dependency downloads, reproducible builds, and minimal configuration. It’s more of a “modern LaTeX build toolchain” rather than a traditional full-scale distribution. ConTeXt Standalone / ConTeXt Suite: Primarily aimed at ConTeXt users, not the first choice for traditional LaTeX users. It’s a complete, independently updatable ConTeXt distribution that can coexist with an existing TeX Live installation. Historically there were also teTeX, proTeXt, fpTeX, gwTeX, etc., but these are generally not recommended for new installations today. For example, teTeX has ceased maintenance and has since been succeeded by TeX Live. Underlying Engines pdfLaTeX: Previously the most mainstream LaTeX engine. Advantages: stable, fast, best compatibility. Disadvantages: poor native Unicode and system font support. Chinese documents require packages like CJK and ctex, which are less natural compared to XeLaTeX / LuaLaTeX. XeLaTeX: Its biggest feature is native Unicode and system font support — you can directly use system fonts like Song, Source Han Sans, Times New Roman. Extremely common in Chinese documents. LuaLaTeX: A more modern direction, supporting Unicode, OpenType fonts, and also embedding Lua scripting capabilities for more complex typesetting automation. It’s considered one of the recommended directions for the future, though template compatibility may sometimes lag behind pdfLaTeX / XeLaTeX. Installing TeX Live on Linux 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 cd /tmp # Download the installer wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz tar -xzf install-tl-unx.tar.gz cd install-tl-2026 # year changes over time # Install sudo perl ./install-tl \ --no-interaction \ --scheme=small \ --no-doc-install \ --no-src-install # Configure TL_YEAR=$(ls /usr/local/texlive | sort -n | tail -1) # get the current installed year version echo "export PATH=/usr/local/texlive/$TL_YEAR/bin/x86_64-linux:\$PATH" >> ~/.bashrc # add to PATH source ~/.bashrc # Verify lualatex --version tlmgr --version Recommended Must-Have Packages Math Formulas Package Description Install Command amsmath Core math environments such as align, cases — almost essential tlmgr install amsmath mathtools Superset of amsmath, fixes known bugs and extends with more commands tlmgr install mathtools amsfonts / amssymb Math symbols like ℝ ∀ ∈, \mathbb blackboard bold font family tlmgr install amsfonts unicode-math Use Unicode math fonts under XeLaTeX/LuaLaTeX tlmgr install unicode-math physics \dv, \pdv derivatives, Dirac brackets, and other physics convenience commands tlmgr install physics bm \bm{} math bold, more robust than \boldsymbol tlmgr install bm Graphics & Drawing Package Description Install Command graphicx \includegraphics for inserting images — almost essential tlmgr install graphics tikz / pgf Vector drawing language for flowcharts, circuit diagrams, mind maps, etc. tlmgr install pgf pgfplots Scientific data charts based on TikZ (line/bar/polar plots) tlmgr install pgfplots float The H option forces float placement — figures and tables stay put tlmgr install float subcaption Side-by-side subfigures with independent numbering, replaces the legacy subfig tlmgr install caption wrapfig Text-wrapped figure layouts tlmgr install wrapfig Tables Package Description Install Command booktabs Three-line tables (\toprule \midrule \bottomrule) — standard for academic papers tlmgr install booktabs tabularx The X column auto-fills remaining width — no more manual column width calculations tlmgr install tabularx multirow \multirow for cells spanning multiple rows tlmgr install multirow longtable Multi-page tables with automatic page breaks tlmgr install longtable array >{}<{} column pre/post hooks, extended p/m/b column types tlmgr install array tabularray A new-generation table package with a more intuitive syntax — recommended for new projects tlmgr install tabularray Bibliographies & References Package Description Install Command biblatex Modern bibliography management, supports styles like GB/T, APA, Chicago tlmgr install biblatex biber Recommended BibLaTeX backend, replacing the legacy BibTeX tlmgr install biber natbib \citet{}, \citep{} for natural science citation formats tlmgr install natbib Chinese Language Support Package Description Install Command ctex All-in-one Chinese typesetting: fonts, punctuation, layout — one-stop configuration tlmgr install ctex xeCJK Fine-grained control over Chinese/English mixed-line spacing under XeLaTeX tlmgr install xecjk zhnumber Chinese numeral formatting: 一, 二, 三… automatic chapter number conversion tlmgr install zhnumber Code Typesetting Package Description Install Command listings Code syntax highlighting, supports 50+ languages, highly customizable tlmgr install listings minted Beautiful code highlighting via Pygments (requires Python) tlmgr install minted fancyvrb Enhanced verbatim environment with line numbers and frames tlmgr install fancyvrb Page Layout Package Description Install Command geometry Page dimensions and margin settings — safer than setting parameters manually tlmgr install geometry fancyhdr Custom headers/footers with automatic chapter name insertion tlmgr install fancyhdr titlesec Deep customization of section title fonts, colors, and spacing tlmgr install titlesec setspace 1.5× / double line spacing — commonly used for thesis formatting tlmgr install setspace parskip Paragraph spacing instead of first-line indentation — European typesetting style tlmgr install parskip Hyperlinks Package Description Install Command hyperref PDF hyperlinks, bookmarks, metadata — must be loaded last tlmgr install hyperref cleveref \cref{} auto-adds prefixes like “fig.”, “table”, “section” — load after hyperref tlmgr install cleveref xurl Line-break URLs at any character to prevent overflow beyond page boundaries tlmgr install xurl Fonts & Colors Package Description Install Command fontspec Load system OpenType fonts under XeLaTeX/LuaLaTeX tlmgr install fontspec xcolor Color support; [svgnames] enables 147 standard color names tlmgr install xcolor microtype Character protrusion and micro-spacing adjustments — significantly improves paragraph typesetting quality tlmgr install microtype Utility Packages Package Description Install Command enumitem Full list customization: spacing, label format, nesting levels tlmgr install enumitem siunitx \SI{9.8}{\metre\per\second\squared} for physical unit typesetting tlmgr install siunitx csquotes Language-aware smart quotes, essential companion to biblatex tlmgr install csquotes tcolorbox Colored info boxes, theorem boxes, sidebar highlight decorations tlmgr install tcolorbox todonotes \todo{} margin notes for to-dos — invaluable during the writing and revision phase tlmgr install todonotes soul Text decoration effects like \hl{highlight}, \st{strikethrough} tlmgr install soul Important Notes Load order: xcolor → graphicx → amsmath → hyperref (last) → cleveref (after hyperref) Chinese users: Just install ctex directly — no need to separately install xeCJK Bibliography: Recommended combination is biblatex + biber, paired with the gb7714-2015 style for Chinese-language references Check installed packages: tlmgr info <package-name>

Read more →

My Experience of Using Rust

Advantages Error handling is a step ahead of Go, more robust. A more robust service is less worrisome. Error declaration (very intuitive) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #[derive(Debug, thiserror::Error)] pub enum InfoFetchError { #[error("Failed to send HTTP request: {0}")] SendHttpRequestError(reqwest::Error), #[error("HTTP response error: {0}")] HttpResponseError(reqwest::Error), #[error("HTTP response body error: {0}")] HttpResponseBodyError(reqwest::Error), #[error("Script element not found")] NoScriptError, #[error("Script processing error")] ProcessScriptError, #[error("JSON parsing error: {0}")] JsonParseError(#[from] serde_json::Error), #[error("No PlayItem")] NoPlayItemError, } Error handling (very robust, forces error checking) 1 2 3 4 5 6 7 8 9 10 let resp = req .send() .await .map_err(|e| InfoFetchError::SendHttpRequestError(e))? .error_for_status() .map_err(|e| InfoFetchError::HttpResponseError(e))?; let text = resp .text() .await .map_err(|e| InfoFetchError::HttpResponseBodyError(e))?; Pattern matching may have a bit of a learning curve, but it is very powerful once mastered.

Read more →

OpenMVS Hands-on Experience

Environment Preparation Install Docker (Windows platform will be used as an example below) Pull images 1 2 docker pull colmap/colmap docker pull openmvs/openmvs-ubuntu Prepare several photos (You can use https://github.com/cdcseacave/openMVS_sample/tree/master/images ) Create a project folder C:\Users\mioyi\project images 00000.jpg 00001.jpg … Steps Use COLMAP to generate sparse point clouds 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 # Start Docker container docker run -it --rm \ --gpus=all \ # Mount GPU, optional -v C:\Users\mioyi\project:/data \ # Mount project folder colmap/colmap # colmap container # Reconstruction cd /data colmap automatic_reconstructor \ --workspace_path . \ --image_path ./images \ --sparse 1 --dense 0 # Run undistortion (to adapt for OpenMVS) mkdir dense colmap image_undistorter \ --image_path /data/images \ --input_path /data/sparse/0 \ --output_path /data/dense \ --output_type COLMAP \ --max_image_size 2000 # Convert to TXT format (to adapt for OpenMVS) colmap model_converter \ --input_path /data/dense/sparse \ --output_path /data/dense/sparse \ --output_type TXT # Exit container exit Use OpenMVS to generate textures 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # Start Docker container docker run -it --rm \ -v C:\Users\mioyi\project:/data \ # Mount project folder openmvs/openmvs-ubuntu cd /data/dense # Convert to OpenMVS format /openMVS_build/bin/InterfaceCOLMAP -i . -o scene.mvs --image-folder images # 1. Densify point cloud /openMVS_build/bin/DensifyPointCloud scene.mvs # 2. Reconstruct mesh /openMVS_build/bin/ReconstructMesh scene_dense.mvs # 3. Refine mesh (optional) /openMVS_build/bin/RefineMesh scene_dense_mesh.mvs # 4. Texture mesh /openMVS_build/bin/TextureMesh scene_dense_mesh.mvs # Exit container exit The texture result is located at C:\Users\mioyi\project\dense\scene_dense_mesh_texture.png

Read more →

Peeling Back the Disguise of "Pure Friendship"

https://www.zhihu.com/question/1999285005235545066 “Why do all my male friends eventually confess their feelings to me? Is there really no pure friendship between men and women?” Before you throw this question into the void, hold off on feeling aggrieved. Accompanying such bewilderment, two vastly different extreme arguments often emerge online: one side criticizes men as being overly results-oriented, acting like machines that only care about efficiency and game theory; the other side mocks women for completely lacking boundaries and deliberately releasing “availability signals,” using “pure friendship” as a fig leaf to harvest emotional value.

Read more →

Portability Issues in C/C++

1. Data Type Sizes The Problem Integer and pointer sizes vary across different platforms. 1 2 3 4 5 6 7 8 9 10 // ❌ Non-portable assumptions int x = ptr; // Assuming a pointer fits in an int (fails on 64-bit systems) long l = 5L; // long is 32-bit on Windows 64, but 64-bit on Unix // ✅ Portable solutions #include <stdint.h> int32_t x; // Exactly 32 bits uint64_t y; // Exactly 64 bits intptr_t ptr_i; // Integer capable of holding a pointer size_t sz; // Used for sizes 2. Endianness The Problem Different CPUs store multi-byte values in different ways.

Read more →

Reverse-Engineering the Mobile QQ (QQNT) Database: A Complete Walkthrough

Goal: Export the complete private chat history between QQ account <my-qq> and a friend <their-qq> from an iPhone. All I had: the QQ app’s “Container directory” and an empty Python virtual environment. Result: Fully decrypted nt_msg.db (227 MB, 55,635 pages, all HMACs verified), exported 24,341 messages as JSON. This article is an honest record of the entire process — every detour, failed attempt, reference found, and final breakthrough. Tech stack: macOS + Python 3.13 + pycryptodome.

Read more →

SeaweedFS Ultimate Guide

The official SeaweedFS Wiki is written terribly, so after many days of research I came up with a solution. Docker Compose Configuration Warning Do not set volumeSizeLimitMB too large; SeaweedFS will pre‑allocate volume space, and by default a single collection (corresponding to an S3 bucket) will create at least 7 volumes, which can quickly lead to insufficient disk space.

Read more →

Self-hosted RustDesk Service

Docker compose: docker-compose.yml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 services: hbbs: container_name: hbbs image: rustdesk/rustdesk-server:latest command: hbbs volumes: - ./data:/root network_mode: "host" depends_on: - hbbr restart: unless-stopped hbbr: container_name: hbbr image: rustdesk/rustdesk-server:latest command: hbbr volumes: - ./data:/root network_mode: "host" restart: unless-stopped Firewall TCP 21115/21118 UCP 21116

Read more →