Chi Vincent's Blog and Documentation

website·Indexed 31 days ago

https://chivincent.net/

A personal technical blog and documentation site covering software development topics including PHP, Laravel, Python, FastAPI, and Go. Content includes tutorials on integrating Kratos auth in Laravel, PHP FFI with libcurl, LeetCode problem analysis, and guides on using Docusaurus for static site generation.

Tokens
34.8K
Snippets
158
Records
217
Agent score
53%

What's inside Chi Vincent

  1. Overview of PHP FFI

    FFI (Foreign Function Interface), introduced in PHP 7.4, allows PHP to call functions and use data structures from dynamic libraries (.dll on Windows, .dylib on macOS, and .so on Unix-like systems) without writing a full PHP extension.

    Caveats:

    • Security/Stability: FFI operates at a low level and can cause memory leaks, IO leaks, or compromise the operating system if used incorrectly.
    • Performance: Accessing data structures via FFI can be slower (potentially 2x or more) than accessing native PHP arrays or objects, though it may use less memory in some cases.
  2. Overview of PHP's evolution and the impact of Laravel

    PHP initially gained popularity due to its low learning curve and ability to rapidly produce Minimum Viable Products (MVPs). However, this high degree of freedom led to inconsistent standards. Around 2010, PHP faced a decline due to performance issues and competition from Ruby on Rails and Node.js. The release of PHP 7 (2015) and the rise of the Laravel framework revitalized the ecosystem by introducing modern architectural patterns and standardization (PSR), allowing PHP to compete more effectively with other backend frameworks.
  3. Overview of FastAPI framework features

    FastAPI is a lightweight web framework based on Starlette and Pydantic. Unlike monolithic frameworks, it follows a "micro-framework" design similar to Gin (Go), offering developers high flexibility with no mandated folder structure; a complete API service can be built within a single file (e.g., app.py or main.py). A key feature is its ability to automatically generate API documentation based on Pydantic models, significantly reducing the manual effort required for documentation.
  4. Overview of FastAPI features and design

    FastAPI is a lightweight Web framework based on Starlette and Pydantic. Unlike full-stack frameworks (such as Laravel), FastAPI follows a "micro-framework" philosophy similar to Gin (Go), providing a lean core and allowing developers to install additional components as needed. It does not enforce a specific folder structure, enabling the creation of an entire API service within a single file (e.g., app.py or main.py). A key feature is its ability to automatically generate API documentation using Pydantic Models, significantly reducing the manual effort required for documentation.
  5. Use Sabaki as a cross-platform Go board software

    Sabaki is an open-source, cross-platform Go board software (MIT License) based on Electron. It supports Windows, macOS, and Linux, and provides full Traditional Chinese language support.
  6. Understand Animation data structure (Anime*.bin)

    The Anime*.bin file contains animation data. The address found in AnimeInfo*.bin points to a sequence of Action data, which consists of one Header followed by multiple Frames.
  7. Install containerd and nerdctl on Raspberry Pi (ARM64)

    To run Portaler Zone on a lightweight container runtime on Manjaro Linux ARM, install containerd and nerdctl. Note that nerdctl should be installed via binary release rather than AUR for ARM64 architecture.
    # Install and start containerd
    sudo pacman -S containerd
    sudo systemctl start containerd
    sudo systemctl enable containerd
    
    # Install nerdctl binary for ARM64
    wget -O nerdctl.tar.gz https://github.com/containerd/nerdctl/releases/download/v0.14.0/nerdctl-0.14.0-linux-arm64.tar.gz
    tar -xf nerdctl.tar.gz
    sudo cp nerdctl /usr/local/bin/nerdctl
  8. Understand Redis SDS (Simple Dynamic String) design

    Redis uses SDS instead of standard C strings to solve two primary issues:

    1. Binary Safety: Standard C strings use \0 (NULL Byte) as a terminator, meaning any NULL byte within a UTF-8 string would be interpreted as the end. SDS stores the length explicitly, allowing it to contain binary data including NULL bytes.
    2. O(1) Length Retrieval: Standard C strings require $O(n)$ time to calculate length via strlen(). SDS stores the length in the header, allowing constant-time access.
  9. Use Google Drive as a Git server with git-remote-gdrive

    The git-remote-gdrive tool allows developers to use Google Drive as a Git remote. It leverages the gitremote-helpers extension mechanism: by placing a git-remote-gdrive executable in the system $PATH, Git can handle custom protocols like gdrive://. To avoid Google Drive API rate limits and performance issues associated with many small files in the .git/ directory, the tool bundles Git information into larger single files.
    # Example usage for cloning a repository from Google Drive
    git clone gdrive://{path}
  10. Use Laravel Horizon for robust Queue Worker management

    Laravel Horizon provides a supervisor architecture using a Master Supervisor (Parent Process) and multiple Supervisor (Child Processes). This architecture allows Horizon to monitor and manage worker states more effectively than the native queue:work command.

    Key benefit: When a job causes a worker to crash due to a Timeout or Out of Memory error, Horizon's supervisor architecture can handle the restart of the worker process, reducing the total reliance on external container restart policies or Supervisord (though using them in tandem is still recommended).

  11. Portaler Zone Architecture Overview

    Portaler Zone is a community tool for Albion Online designed to share map information. It is a decoupled project consisting of the following components:

    Backend Services:

    • API: An Express-based HTTP API.
    • Bin ETL: Parses Albion Online resources.
    • Discord Bot: Facilitates map sharing within Discord servers.
    • Dependencies: Requires PostgreSQL and Redis.

    Frontend Services:

    • frontend: A React-based dashboard for displaying information.
    • homepage: A static website built with Gatsby.