AbeiBiji (阿北笔记)

website·Indexed 31 days ago

https://www.abeibiji.cn

A personal knowledge base and blog by Abei, featuring technical notes on AI Agents, JVM, Vue3, and OpenCV, as well as STM32 tutorials, LeetCode algorithmic solutions in Java, and hardware equipment reviews. The site also includes personal essays, travel logs, and project documentation for a Partner Matching System.

Tokens
25.8K
Snippets
91
Records
142
Agent score
50%

What's inside AbeiBiji

  1. Choose a Java Redis client based on project requirements

    Depending on the project architecture and performance needs, choose one of the following Java clients for Redis:

    • Spring Data Redis: Best for Spring-based projects with standard requirements; easiest to implement.
    • Jedis (+ Jedis Pool): Best for non-Spring projects that prioritize simplicity and have moderate performance requirements.
    • Lettuce: Best for non-Spring projects requiring high performance, asynchronous support, and connection pooling.
    • Redisson: Recommended for distributed systems requiring distributed features such as distributed locks and distributed collections.
  2. JVM (Java Virtual Machine) Overview

    The Java Virtual Machine (JVM) provides the following core functionalities:

    • Bytecode Execution: Real-time interpretation of bytecode instructions into machine code for computer execution.
    • Memory Management: Automatic allocation of memory for objects and methods.
    • Garbage Collection: Automatic mechanism to reclaim memory from objects that are no longer in use.
    • Just-In-Time (JIT) Compilation: Optimizes 'hot' code paths to improve execution efficiency.
  3. Understand core JVM functions

    The Java Virtual Machine (JVM) provides three primary capabilities:

    1. Interpretation and Execution: Translates bytecode instructions into machine code in real-time for computer execution.
    2. Memory Management: Automatically allocates memory for objects and methods and provides a garbage collection mechanism to reclaim unused objects.
    3. Just-In-Time (JIT) Compilation: Optimizes 'hot' code paths to improve execution efficiency, bridging the performance gap between Java and languages like C/C++ while maintaining cross-platform compatibility.
  4. Apply Prompt Engineering techniques for better AI responses

    Improve the quality of AI outputs by applying these three fundamental prompting techniques:

    1. Role Specification: Clearly define the task and the persona the AI should adopt.
    2. Detailed Instructions & Examples: Provide specific requirements and the desired output format to reduce ambiguity.
    3. Structured Formatting: Guide the AI's reasoning by requesting specific structures like tables or lists.
    # Example 1: Role Specification
    System: You are an experienced Python teacher, skilled at explaining programming concepts to beginners.
    User: Please explain list comprehensions in Python, including basic syntax and 2-3 practical examples.
    
    # Example 2: Detailed Instructions
    Please provide a social media marketing plan for a new smartwatch. The plan should include:
    1. Target audience description
    2. Three content themes
    3. Content type suggestions for each platform
    4. Posting frequency suggestions
    Example format: Target Audience: [Description] | Content Themes: [Theme 1, 2, 3]...
    
    # Example 3: Structured Formatting
    Analyze the strengths and weaknesses of Tesla. Please answer in a table format with the following columns:
    - Strength (at least 3 items)
    - Brief analysis of each strength
    - Weakness (at least 3 items)
    - Brief analysis of each weakness
    - Recommendations
  5. Partner Matching System Technical Stack

    The Partner Matching System is built using the following technology stack:

    Frontend:

    • Framework: Vue 3
    • UI Library: Vant UI (Mobile component library)
    • Build Tool: Vite
    • Deployment: Nginx (Single machine)

    Backend:

    • Language/Framework: Java with Spring Boot
    • Persistence/ORM: SpringMVC, MyBatis, and MyBatis Plus
    • Database: MySQL
    • Caching: Redis
    • API Documentation: Swagger and Knife4j
  6. Standard enterprise project development workflow

    The typical lifecycle for developing an enterprise project follows these sequential steps:

    1. Requirement Analysis
    2. Design (Overview and Detailed Design)
    3. Technology Selection
    4. Initialization / Integration of required technologies
    5. Prototype/Demo development
    6. Implementation of business logic (Coding)
    7. Testing (Unit Testing)
    8. Code Submission and Peer Review
    9. Deployment
    10. Release
  7. Anatomy of fundus images for medical image analysis

    When analyzing fundus images, the following anatomical structures are key components:

    • Optic Disc (OD): A pale red circular structure (approx. 1.5mm diameter) located about 3mm nasal to the macula.
    • Optic Cup (OC): A physiological depression within the optic disc. The ratio of the cup diameter to the disc diameter is the Cup-to-Disc ratio (C/D); a normal C/D is approximately 0.3 and generally does not exceed 0.5.
    • Retinal Arteries and Veins: Large vessels radiating from the optic disc. Arteries appear bright red, while veins appear dark red, with a typical diameter ratio of 2:3.
    • Macula: Located at the center of the posterior pole; it is avascular and characterized by a pinhead-sized light reflex at the fovea centralis.
    • Retina: The innermost layer of the eyeball wall. While normally colorless and transparent, it appears deep orange-red in fundus photography due to the underlying vascular choroid.
  8. Ensure data consistency using @Transactional

    Use the @Transactional annotation to ensure atomicity when updating multiple related tables (e.g., inserting into both the team table and the user-team relationship table). This prevents partial failures where a team is created but the user is not successfully linked to it.
    @Transactional(rollbackFor = Exception.class)
  9. Configure virtual environment and project dependencies

    Use virtualenv to isolate the project environment and install the required Python packages from requirement.txt.
    # Install virtualenv
    pip3.9 install virtualenv
    
    # Create virtual environment
    mkdir envs
    virtualenv envs/mosaic --python=python3.9
    
    # Activate environment
    source envs/nb/bin/activate
    
    # Install dependencies
    pip install -r requirement.txt
  10. Approach for generating naked-eye images from fundus images and refractive power

    To generate naked-eye images based on fundus images and refractive power (diopters), consider a multi-disciplinary approach combining the following strategies:

    1. Image Processing and Segmentation: Pre-process fundus images to extract key features such as the eyeball edge and retina using image enhancement, edge detection, and segmentation algorithms.
    2. Refractive Power Integration: Use refractive power data to infer refraction and astigmatism. Integrate this by adjusting image parameters (e.g., contrast, brightness) to simulate the visual effects of different refractive powers.
    3. Visual Simulation and Modeling: Develop a visual simulation model using machine learning or deep learning. Train the model on existing datasets to learn the mapping between fundus images, refractive power, and the resulting naked-eye images.
    4. Medical Domain Expertise: Consult ophthalmologists to understand the physiological relationship between fundus structures, refractive errors, and perceived visual output.
  11. Integrate Alibaba Cloud DashScope LLM via Java SDK

    To integrate Alibaba Cloud's LLMs (like Qwen) into a Java project using the official SDK, follow these steps:

    1. Add Dependency: Include the dashscope-sdk-java in your pom.xml.
    2. Authentication: Obtain an API Key from the Alibaba Cloud Bailian platform.
    3. Implementation: Use the SDK to make direct calls to the model. This method provides better type support and error handling compared to raw HTTP requests.
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>dashscope-sdk-java</artifactId>
        <version>2.20.6</version>
    </dependency>
  12. Install FFmpeg with x264 support from source

    The project requires FFmpeg. This involves a multi-step process: installing YASM, NASM, the x264 library, and finally FFmpeg itself, followed by updating system environment variables.
    # 1. Install YASM
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
    tar -xvf yasm-1.3.0.tar.gz
    cd yasm-1.3.0
    ./configure && make && make install
    
    # 2. Install NASM and x264
    wget http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.xz
    tar xvJf nasm-2.13.03.tar.xz
    cd nasm-2.13.03
    ./configure && make && make install
    
    yum -y install git
    git clone https://code.videolan.org/videolan/x264.git
    cd x264
    ./configure --prefix=/usr/local/x264 --enable-shared --enable-static
    make && make install
    
    # Add x264 to environment (edit /etc/profile)
    # export PKG_CONFIG_PATH=/usr/local/x264/lib/pkgconfig
    source /etc/profile
    
    # 3. Install FFmpeg
    wget http://ffmpeg.org/releases/ffmpeg-5.1.3.tar.gz
    tar -xvf ffmpeg-5.1.3.tar.gz
    cd ffmpeg-5.1.3
    ./configure --prefix=/usr/local/ffmpeg5.1.3 --enable-gpl --enable-libx264 --extra-cflags="-I/usr/local/x264/include" --extra-ldflags="-L/usr/local/x264/lib"
    make && make install
    
    # Add FFmpeg to PATH (edit /etc/profile)
    # export PATH=$PATH:/usr/local/ffmpeg/bin
    source /etc/profile
    
    # Update shared libraries (edit /etc/ld.so.conf and add /usr/local/x264/lib)
    ldconfig