Moonglade

Modern Markdown blogging with AI-powered localization and search.

All Posts


Quick Start: VS Code Python Development Environment Setup Guide (2025 Edition)

This article provides a detailed demonstration of the complete process for building an efficient Python development environment using `uv`, `Ruff`, and `Ty`. First, it covers managing virtual environments and dependencies with `uv`, leveraging its high-performance characteristics to quickly install libraries such as `numpy`, `pandas`, and `Streamlit`. It also demonstrates how to configure domestic mirror sources to accelerate the download of large packages. Next, it delves into configuring VS Code with the `Ruff` plugin to automatically format code, clean up unused imports, and auto-fix syntax issues upon saving, significantly enhancing code cleanliness and development efficiency. Following this, the `Ty` tool is introduced for static type checking, complementing `Ruff`'s limitations in type safety by detecting potential type errors before code execution, with real-time diagnostics enabled via a VS Code plugin. Finally, the article compares the applicable scenarios of `Anaconda` and `uv`, recommending that beginners or research collaboration environments continue using `Anaconda`, while enterprise-level developers or advanced users pursuing ultimate efficiency and code quality should prioritize the combination of `uv`, `Ruff`, and `Ty` to achieve a more concise, fast, and standardized Python development experience.

Views 336
Python VS Code VSCode ruff ty uv

Linux Docker root and rootless modes

This article provides an in-depth analysis of the core differences between Docker in Root mode and Rootless mode. Root mode operates at the system-wide level, storing data in `/var/lib/docker`. It offers full privileges but has lower security. Rootless mode runs with regular user permissions, isolates data within the user directory, and leverages user namespace technology to enhance security and enable independent instances for multiple users. However, it is limited by CPU and I/O constraints and certain network functionalities. The article points out that because the data storage and service configurations of the two modes are completely independent, they cannot share images and containers. Based on the current actual needs, which do not require advanced features, the author decided to disable Root mode and fully adopt Rootless mode. The text details how to manage user-level services using `systemctl --user`, corrects the misconception that `systemctl` is limited to system-level usage, and compares the configuration file paths, socket locations, and storage directories in both modes. Additionally, it discusses the Rootless capabilities of applications such as Podman and Caddy, summarizes the advantages and limitations of Rootless mode in development, testing, and shared hosting scenarios, and provides a practical guide for managing containers more securely and flexibly in a Linux environment.

Views 457
AnduinOS Docker comparison-analysis configuration-management docker-containerization linux-containers rootless-docker security-best-practices

Find Your Clipboard Assistant for AnduinOS

This article documents the author's process of migrating tools after switching from Windows to AnduinOS, a GNOME-based distribution, in order to address the lack of a multi-entry clipboard history feature. The article first explains the importance of the built-in clipboard tool in Windows 11 for development scenarios. It then describes how to install and configure the GNOME extension `clipboard-indicator` on AnduinOS as an alternative. The core steps include: first, verifying the GNOME Shell version via the command line and selecting the matching extension version based on the official support list (e.g., GNOME 42 corresponds to `v47`); second, downloading the specified version's archive from the GNOME Extensions website and extracting it into the specific folder under the `/usr/share/gnome-shell/extensions` directory; finally, enabling the extension using the `gnome-extensions enable` command. After installation, users can find the clipboard icon in the status bar and customize settings and shortcuts. It is recommended to set the shortcut to `win+v` to replicate the Windows experience. The article specifically notes that in terminal environments, copy and paste must be performed using `ctrl+shift+c` and `ctrl+shift+v` to avoid conflicts with default terminal control commands. This extension effectively resolves efficiency pain points in the new system, providing developers with smooth, rapid multi-text transfer capabilities, significantly improving...

Views 97
AnduinOS GNOME extensions Windows alternative clipboard productivity tool terminal

How to Enjoyably Develop .NET with AnduinOS

This article aims to provide .NET developers with a guide for setting up a development environment in VSCode on AnduinOS or any Linux system that closely mimics the Visual Studio experience. It begins by noting that, due to the lack of a free Visual Studio and the absence of a Rider Community Edition, VSCode emerges as an ideal alternative. The core content recommends the C# extension and its key settings, such as enabling OmniSharp decompilation support, EditorConfig, and the Roslyn analyzer, to enhance basic functionality. For advanced needs, it introduces the C# Dev Kit and its intelligent completion components, while cautioning about its commercial licensing restrictions and account login requirements. Additionally, it recommends Roslynator as a lightweight alternative for code analysis and refactoring, along with practical plugins for automatically generating XML documentation comments and completing namespaces. The article also briefly discusses the pros and cons of GitHub Copilot. The author emphasizes that these configurations can significantly improve development efficiency and invites readers to share further optimization suggestions, aiming to help developers achieve a smoother C# development experience on Linux platforms.

Views 206
.NET AnduinOS C# VSCode development-environment dotnet github-copilot vscode-plugins

Reflections on Design Patterns in Software Development

As a senior .NET developer, the author reflects on the dangers of blindly advocating design patterns and rigid thinking in software development, advocating for critical thinking and flexible application. The author argues that tools should serve actual needs rather than dogma, pointing out that JavaScript, with its full-stack capabilities and rich ecosystem, holds immense value in both front-end and back-end development. To this end, the author used GPT-4 to convert video tutorials into text and wrote the concise tutorial "JavaScript: From Beginner to Off the Rails." This book is designed specifically for experienced engineers, covering core concepts such as variables and asynchronous programming. It aims to help readers quickly master JS skills, break free from dependence on a single tech stack, adapt to a rapidly changing technological environment, and achieve the transition from novice to proficient developer.

Views 82
JavaScript beginner-tutorial high-concurrency programming rapid-development web-development

How to Develop a Large Language Model Chatbot in 5 Minutes

This article aims to guide readers in quickly developing a chatbot based on a large language model within 5 minutes, serving as an introductory practice for exploring LLM application development. The tutorial uses Python combined with the LlamaIndex and Gradio libraries, leveraging the free API provided by the Groq platform to host the Llama3-70b model, achieving a low-cost solution that runs smoothly without requiring a high-performance GPU. The development workflow covers managing dependencies with Poetry, creating the project structure, configuring API keys to ensure security, and writing the core code logic. The core section uses LlamaIndex to construct a message list containing the system prompt, conversation history, and current input, and calls the stream_chat method to implement streaming responses, simulating a natural typing effect; simultaneously, it utilizes Gradio to quickly build a web interactive interface, supporting context memory functionality. The article also demonstrates how to generate a shared link for others to access via the share parameter, and tests the model's capabilities through a series of fun and challenging questions, verifying its performance in logical reasoning and context retention. Although there are minor flaws such as occasionally ignoring translation instructions, this solution demonstrates the powerful performance of Llama3-70b among open-source models, providing developers with an effective path to advance from basic chatbots to more complex LLM applications.

Views 418
AI chatbot gradio llama3 70b poetry stream chat

You might be writing .NET code that has memory leaks!

This article systematically reviews six common memory leak scenarios in .NET development and their corresponding mitigation strategies, aiming to help developers avoid production incidents. It first explains the concepts of managed and unmanaged memory, pointing out that failing to properly release resources prevents the GC from reclaiming them. The specific scenarios include: anonymous methods capturing class members forming strong references, with a recommendation to use local variables instead; event subscriptions preventing subscriber release, requiring timely unsubscription or the use of weak references; static variables, especially collection types, which can grow indefinitely and are not collected by the GC; using mutable collections as caches in long-lived objects, which can easily lead to memory exhaustion, with a recommendation to switch to `IMemoryCache` with expiration mechanisms; failure to call `Dispose` leading to unmanaged resource leaks, where using `using` statements is preferred over relying on finalizers due to their higher performance overhead; and direct memory operations such as `unsafe`, which require extra caution. The article emphasizes that even experienced developers can make mistakes, and that mastering these patterns and maintaining disciplined coding habits are crucial to effectively improving application stability and avoiding out-of-memory exceptions.

Views 124
.NET Circular Dependencies Closure Issues Memory Caching Issues Memory Leaks Unmanaged Resources

5-Minute Introduction to .NET Unit Testing

This article is an introductory tutorial on C# unit testing. Using BookService as an example, it provides a detailed demonstration of the complete process of writing tests with xUnit, NSubstitute, and FluentAssertions. The article first introduces the basic construction of test classes, including creating mock objects with NSubstitute, initializing the system under test, and preparing test data. It then focuses on writing test methods, distinguishing between the [Fact] and [Theory] attributes: [Fact] is used for testing a single scenario and follows the standard Arrange (setup), Act (execution), and Assert (verification) structure; [Theory] combined with [InlineData] supports multiple sets of input parameters, making it particularly suitable for verifying exception throwing or boundary conditions. The tutorial also demonstrates how to use Arg.Any<T> to handle arbitrary parameters, and introduces methods for running tests and viewing results via the dotnet test command or an IDE. The article emphasizes improving code readability through normalized test method naming conventions (such as Method_Scenario_ExpectedResult), and points out that unit testing can effectively prevent missed parameter validation, making it an important practice for ensuring code quality.

Views 174
.NET Test nsubstitute tdd unit testing xunit

Using Moq Events to Discuss the Importance of Unit Testing

The prominent .NET unit testing library Moq sparked intense community controversy after it was discovered that the library scans local Git configurations during the build process and sends users' email addresses to check their sponsorship status. This led some developers to condemn the author and resulted in the emergence of alternative solutions such as CleanMoq. Using this incident as a starting point, the article delves into the core value of unit testing, pointing out that it can significantly enhance code quality, maintainability, and refactoring efficiency. Conversely, the absence of unit testing can lead to a vicious cycle of fragile code, increased project risks, and reduced development efficiency. Although this incident did not trigger widespread discussion domestically, the author reflects on the fact that small and medium-sized companies in the region generally lack a habit of writing unit tests. This is attributed to cost considerations and time pressures, which ultimately result in declining software quality. The article calls on local developers and enterprises to place greater importance on unit testing, breaking the dilemma where a lack of tests prevents refactoring and code rot slows down development. The author also plans to share introductory tutorials on unit testing in the future.

Views 109
.NET Code Quality Software Development Software Development Methodology Test unit testing

How to Build an Image-to-Text Tool in 3 Minutes

This article introduces an open-source solution for building an image-to-text tool, aiming to address the lack of open-source image recognition and description capabilities in existing AI tools. The author utilizes the Salesforce blip-image-captioning-large model API provided by the HuggingFace platform, combined with the Laf cloud development platform, to complete deployment within 3 minutes without the need to purchase GPU servers. The specific steps include registering a HuggingFace account to obtain an Access Token, creating an application on the international version of Laf and configuring environment variables, and writing JavaScript cloud functions to handle image uploads, validation, and calling the HuggingFace interface to retrieve descriptive text. To adhere to the zero-cost principle, the frontend page is also implemented by directly returning HTML code through another Laf cloud function, including features for file selection, preview, and result display. Ultimately, users only need to access the generated URL to upload images and obtain English descriptions. In the future, translation interfaces can be integrated, or models supporting Chinese can be substituted to optimize the user experience.

Views 199
AI API Integration Computer Vision Frontend Development Image Processing LafStack