n-notes Knowledge Base

website·Indexed 31 days ago

https://n-notes.tkzt.cn/

A personal collection of technical notes covering LeetCode problem solutions (AC!AC!AC!), basic computer science skills like sorting and greedy algorithms, quick-start guides for Go, Vue, and Spring Boot 2, and miscellaneous technical tips on X Window, Git, and FRP.

Tokens
30.9K
Snippets
148
Records
185
Agent score
50%

What's inside n-notes

  1. Overview of X Window System Architecture

    The X Window System is a standard toolkit and protocol for building graphical user interfaces on Unix-like operating systems. Unlike higher-level libraries like GTK or Qt, X provides a basic framework for drawing, keyboard/mouse events, and window management, but does not define UI widgets (e.g., buttons or text boxes).

    It utilizes a client-server model: the client application decides what to do, and the X server (the local display program) handles user input and performs the actual drawing.

  2. Overview of Spring Boot features and goals

    Spring Boot is designed to simplify the creation of production-ready, standalone Spring applications by adhering to the philosophy of "convention over configuration."

    Key features include:

    • Standalone Execution: Creates applications that can run independently.
    • Embedded Servers: Includes built-in Tomcat, Jetty, or Undertow, eliminating the need to deploy WAR files.
    • Starter Dependencies: Provides starter packages to simplify build configurations.
    • Auto-Configuration: Automatically configures the Spring framework and third-party libraries.
    • Production-Ready Tooling: Includes built-in metrics, health checks, and configuration loading.
    • No XML/Code Generation: Avoids the need for XML configuration files or generated boilerplate code.
  3. Compare Vue and React core architectures

    Both use Virtual DOM and component-based architecture, but differ in implementation:

    • Update Strategy: React updates the component and all its children by default (unless shouldComponentUpdate is used). Vue tracks dependencies for more precise updates.
    • State Management: React state is read-only and updated via setState. Vue uses data binding (via Object.defineProperty and publish-subscribe patterns).
    • Ecosystem: Vue provides official libraries for routing and state (Vue Router, Vuex), while React relies more on community-driven libraries.
  4. Handle non-null assertions and optional properties

    In TypeScript, you can use the definite assignment assertion operator ! when declaring a variable that will be initialized later but is not null/undefined, preventing the compiler from complaining about missing initializers.
    let foo!: string; // Definite assignment assertion
  5. Understand the Utility-First philosophy of Tailwind CSS

    Tailwind CSS is a utility-first CSS framework designed for rapidly building custom user interfaces. Unlike 'Semantic First' approaches that use descriptive class names (e.g., .card), Tailwind provides atomic utility classes that each typically represent a single CSS property. This allows developers to build components by composing these small 'building blocks' directly in the HTML, reducing the need to write custom CSS and eliminating the mental burden of naming classes.
  6. Understand Bayer Filter Array and RGB Interpolation

    RAW images often use the Bayer filter array, where pixels are sampled in patterns (e.g., RGRG in odd rows and GBGB in even rows). To reconstruct a full RGB image, missing color channels for each pixel are interpolated from neighbors. A simple linear interpolation/averaging method is:

    • For a pixel B:
      • R = average of 4 surrounding R pixels (top-left, bottom-left, top-right, bottom-right)
      • G = average of 4 surrounding G pixels (top, bottom, left, right)
      • B = the pixel's own value.
  7. Core Spring concepts: IOC and AOP

    Two fundamental pillars of the Spring framework are:

    • IOC (Inversion of Control): Also known as Dependency Injection. It shifts the responsibility of object instantiation from the class itself to a container. Instead of class A manually instantiating class B (A Call B), class A waits for the container to provide B (A Wait For B), which decouples classes and makes the system easier to maintain when dependencies change.
    • AOP (Aspect Oriented Programming): Uses dynamic proxy technology to separate repetitive cross-cutting concerns (such as logging or transaction management) from the main business logic, preventing the need to duplicate code across multiple methods.
  8. Understand MQTT Protocol Basics

    MQTT (Message Queuing Telemetry Transport) is a lightweight communication protocol based on the publish/subscribe model and runs over TCP/IP. It is designed for low bandwidth, low overhead, and small packet sizes, making it ideal for IoT and sensor data transmission.
  9. Understand the core concept of Dynamic Programming (DP)

    Dynamic Programming is a method of solving complex problems by discovering a state transition relationship (a recurrence relation). By defining a state transition equation, the algorithm can iterate through various intermediate states to find the global optimal solution.
  10. Go Language Core Characteristics

    Go is a statically typed, compiled language that produces machine-runnable binary instructions. Key characteristics include:

    • Native support for Unicode (UTF-8 encoding).
    • Built-in concurrency support.
    • Automatic memory management and Garbage Collection (GC).
    • No reference passing (though it has reference types).
    • Pointers are supported, but pointer arithmetic is forbidden to prevent bugs.
    • Strict and unified coding style.
  11. Find the single element in an array using XOR

    To find the single element in an array where every other element appears exactly twice, you can use the XOR (^) bitwise operation. This approach leverages two fundamental properties of XOR:

    1. Any number XORed with itself results in zero (x ^ x = 0).
    2. Any number XORed with zero remains unchanged (x ^ 0 = x).

    By iterating through the entire array and applying XOR to all elements, all pairs will cancel each other out, leaving only the single unique element as the final result.

    /**
     * @param {number[]} nums
     * @return {number}
     */
    var singleNonDuplicate = function (nums) {
      let result = 0;
      for (const i of nums) {
        result ^= i;
      }
      return result;
    };
  12. Initialize a Spring Boot project using Spring Initializr

    All Spring Boot applications should be based on Spring Initializr to quickly pull required dependencies and initial configurations. For a basic web service, the spring-boot-starter-web dependency is required. When using Maven, the spring-boot-starter-parent provides default dependency management and the spring-boot-maven-plugin is used for packaging.
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" ...>
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.3.2.RELEASE</version>
            <relativePath/>
        </parent>
        <groupId>com.example</groupId>
        <artifactId>rest-service</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </project>