Shimakaze's Dock (岛风的船坞)

website·Indexed 31 days ago

https://blog.shimakaze.dev/

A personal technical blog featuring articles and tools on .NET, C#, MSBuild, WPF, Vue, and Linux. Content includes guides on stable-diffusion-webui-docker deployment, RA2 modding (CSF and MIX file formats), WSL registry, and various Windows system theme integrations.

Tokens
16.3K
Snippets
64
Records
102
Agent score
56%

What's inside Shimakaze's Dock

  1. Overview of the Markdown Indexer architecture

    The Markdown Indexer is a tool that parses Markdown source files directly to build Algolia search indices, bypassing the need for HTML crawlers. This approach ensures that index updates are synchronized with deployments (via GitHub Actions), remains unaffected by UI/theme changes, and provides full control over the index structure.

    The core engine follows a five-step process:

    1. Scans the document directory for all Markdown files.
    2. Parses each file to extract frontmatter and body content.
    3. Invokes processors to generate index data.
    4. Groups data by index name.
    5. Performs a batch upload to Algolia.
  2. Generate routes based on file system structure with unplugin-vue-router

    The unplugin-vue-router plugin automatically generates Vue Router routes based on the directory structure of the src/pages/ folder. For example, a file at ./src/pages/demo/[id].vue will automatically map to the route /demo/:id.
  3. Understand the RA2 CSF file structure

    CSF files store all string resources required by Red Alert 2. The file is divided into two main sections: a fixed-length 24-byte File Header and a Body consisting of multiple labels.
  4. Parse the RA2 MIX file header

    The MIX file header contains metadata about the archive. There is no magic code to identify the file type.
    offsettypeDescription
    0x00uint32Flag (indicates if the file is encrypted or has a checksum)
    0x04uint16Number of files
    0x06uint32Size of the file body
  5. Shimakaze OS Boot Process and Requirements

    Shimakaze OS is a .NET-based operating system running on a Linux kernel.

    Boot Sequence:

    1. Linux Kernel starts initramfs $\rightarrow$ /sbin/init (mounts rootfs).
    2. Rootfs $\rightarrow$ /sbin/init (mounts VFS, starts CoreCLR).
    3. Execution $\rightarrow$ /bin/dotnet /usr/lib/init/init.dll.

    Required Components:

    • Linux Kernel (with NTFS drivers)
    • C Standard Library (musl), GCC runtime (libgcc), C++ Standard Library (libstdc++)
    • Unicode globalization (libicu), Kerberos (krb5), OpenSSL, CA Certificates, and Timezone data (tzdata)
    • .NET Core Runtime and PowerShell
    • C# (AOT) and C# (JIT) init loaders
    • initramfs
  6. Understand the role of .NET Application Hosts (AppHost)

    An Application Host (AppHost) is a native executable provided by the .NET team (or custom-created) that acts as a wrapper for a .NET assembly. Its primary responsibilities are to locate and start the .NET runtime, load the assembly, find the pointer to the Main method, and invoke it. AppHosts are typically bundled with the .NET SDK or downloaded from NuGet.org as Microsoft.NETCore.App.Host.<RID> packages.
  7. Modify the boot logo on Xiaomi Redmi Note 7 (MIUI 12/12.5)

    To change the boot logo on a Xiaomi device, you need to extract the original splash.img (sometimes named logo.img), replace the image content with a new BMP file of the exact same dimensions and format, and flash the patched image back to the device via fastboot. This process was specifically tested on the Redmi Note 7 with MIUI 12/12.5.
  8. Deploy stable-diffusion-webui-docker using Docker Compose

    To deploy the stable-diffusion-webui-docker project, ensure Docker is installed. The process involves cloning the repository, downloading the necessary assets, and then launching the desired UI profile.
    # 1. Clone the project
    git clone https://github.com/AbdBarho/stable-diffusion-webui-docker --depth=1
    cd stable-diffusion-webui-docker
    
    # 2. Download assets
    docker compose --profile download up --build
    
    # 3. Run the UI (Replace 'auto' with invoke, auto-cpu, sygil, or sygil-sl as needed)
    $ui = 'auto'
    docker compose --profile $ui up --build
  9. Implement inline routing in Vue using template-router

    The template-router Vite plugin allows developers to define routes directly within .vue files, eliminating the need to manually update a central router.ts file whenever a new page is added. This is achieved by adding path and layout attributes to the <template> block of a Vue component.
    <template path="/path" layout="Layout">
      <!-- Component content -->
    </template>
  10. Install Docker Desktop for Windows

    Follow these steps to install Docker Desktop on Windows:

    1. Download the Docker Desktop for Windows installer.
    2. Open the "Turn Windows features on or off" dialog.
    3. Enable "Windows Hypervisor Platform".
    4. Enable "Windows Subsystem for Linux" (WSL).
    5. Enable "Virtual Machine Platform".
    6. Run the Docker installer.
    7. Restart the computer.
  11. Activate a firewalld service in a specific zone

    After defining a service XML, you must identify the active zone and explicitly add the service to that zone to allow traffic.
    # 1. Find the active zone (e.g., 'public')
    firewall-cmd --get-active-zones
    
    # 2. Add the service to the active zone permanently
    firewall-cmd --zone=public --add-service=<service_name> --permanent
    
    # 3. Reload firewall configuration to apply changes
    firewall-cmd --complete-reload
    
    # 4. Verify the service is configured
    firewall-cmd --get-services | grep <service_name>
  12. Best practices for .NET locking and synchronization

    Follow these guidelines to ensure performance and prevent deadlocks:

    1. Use readonly lock objects: Prevent the lock object from being modified.
    2. Minimize lock granularity: Only protect the absolute minimum amount of code necessary.
    3. Prevent deadlocks: Acquire multiple locks in a consistent order, use Monitor.TryEnter with timeouts, or use Channel to avoid locks entirely.
    4. Prefer lock-free solutions: Use Interlocked for atomic operations or immutable data structures.
    5. Never use sync locks in async code: Using lock around an await call can cause deadlocks. Use SemaphoreSlim.EnterAsync() instead.
    // ❌ WRONG: Sync lock in async code
    lock (_lockObj)
    {
        await SomeAsync(); // Risk of deadlock
    }
    
    // ✅ CORRECT: Async lock
    await using (await _semaphore.EnterAsync())
    {
        await SomeAsync();
    }