elvinn.wiki Knowledge Base

website·Indexed 32 days ago

https://elvinn.wiki/

A personal technical wiki covering frontend development (React, Vue, TypeScript), backend common situations (locking mechanisms, log rotation), networking (HTTPS, CDN), and programming languages like C++ and Node.js. It also includes LeetCode problem-solving techniques, personal project documentation, and annual reading notes from 2020 to 2026.

Tokens
27.7K
Snippets
104
Records
181
Agent score
62%

What's inside elvinn.wiki

  1. Overview of memo online notepad

    memo is a minimalist online notepad and todo-style application. It is built on Tencent Cloud Base (CloudBase) and provides core features including GitHub authentication for login and seamless data synchronization across devices.
  2. Overview of MySQL Server Log Types

    MySQL utilizes several types of server logs to track different aspects of database operation:

    • Error log: Records issues occurring during server startup, runtime, or shutdown.
    • General query log: Records client connections and all executed queries (including read operations).
    • Slow query log: Records queries that exceed the long_query_time threshold.
    • Binary log (Binlog): Records data modification events (write operations).
    • Relay log: Records data changes synchronized from a primary server to a replica.
    • DDL log / meta log: Records operations that modify or delete table structures.
  3. Use AsyncLocalStorage to maintain state across asynchronous flows

    AsyncLocalStorage allows you to store data in a web request or any asynchronous process so that it can be accessed by subsequent sub-processes (including nested callbacks and async functions) without explicitly passing the data as arguments. It provides a way to achieve local-storage-like behavior within an asynchronous execution context.

    Compatibility:

    • Experimental since v13.10.0 and v12.17.0.
    • Stable since v16.4.0.
  4. Understand the overhead of copy constructors in C++

    In C++, copy constructors can introduce significant performance overhead when objects are returned from functions or passed as temporaries, as they perform deep copies of resources (e.g., allocating new memory and copying large arrays). This is especially wasteful when the source object is a temporary that will be destroyed immediately after the copy.
    class Test {
        int * arr{nullptr};
    public:
        Test():arr(new int[5000]{1,2,3,4}) {}
        // Copy constructor: performs expensive deep copy
        Test(const Test & t) {
            if (arr == nullptr) arr = new int[5000];
            memcpy(arr, t.arr, 5000*sizeof(int));
        }
        ~Test(){ delete [] arr; }
    };
    
    Test createTest() {
        return Test(); // Potential for multiple copy constructor calls
    }
  5. Understand cryptocurrency fundamentals

    Cryptocurrency is a form of electronic money that is non-physical and operates on a decentralized network, meaning it does not rely on central authorities like central banks or payment platforms (e.g., Alipay, WeChat Pay). It utilizes an anonymous network where identities are represented by strings of characters.
  6. Understand the advantages and disadvantages of React Hooks

    Introduced in React 16.8, Hooks provide several architectural benefits but introduce new complexities for developers.

    Advantages:

    1. Stateful Functional Components: Transforms functional components from pure presentational components into components that can manage their own state and side effects.
    2. Logic Reuse without Nesting: Allows reuse of state-related logic without changing the component hierarchy, serving as an alternative to Render Props and Higher-Order Components (HOCs).
    3. Unified Lifecycle Logic: Consolidates code that was previously scattered across multiple lifecycle methods such as componentDidMount, componentDidUpdate, and componentWillUnmount.

    Disadvantages and Caveats:

    1. Dependency Management: Incorrectly handling dependency arrays in Hooks can lead to bugs where effects are triggered unnecessarily or fail to trigger when required.
    2. Granularity Trade-offs: Finding the right level of abstraction for custom Hooks is challenging; too granular leads to fragmented code and increased complexity, while too coarse reduces reusability.

    Core Principle: The underlying mechanism of Hooks is based on arrays rather than magic.

  7. Understand Node.js V8 Memory Structure

    Node.js uses the V8 engine, which manages memory via a Resident Set divided into Stack and Heap.

    Stack: Managed by the OS; stores primitive data types and function call frames. Heap: Managed by V8; consists of several spaces:

    • New Space (Young Generation): Small space for new objects, cleaned using the Scavenge (Minor GC) algorithm.
    • Old Space (Old Generation): Stores objects that survive Minor GC. Uses Mark-Sweep & Mark-Compact (Major GC). Divided into Pointer space (objects with pointers) and Data space (objects without pointers, e.g., strings).
    • Code Space: Stores executable code segments.
    • Large Object Space: Stores objects exceeding the regular heap object size limit (Page::kMaxRegularHeapObjectSize); these are not moved during GC.
  8. Understand video container formats (Packaging)

    A video container format (e.g., .mp4, .flv, .mov, .ts, .rmvb) is a method of organizing video data. It does not determine the video quality itself, but rather how the following components are stored: metadata (duration, bitrate, key-frames), video codec format, audio codec format, and subtitle format. Because the container is just an organizational layer, you can convert between containers without losing quality (lossless conversion) if the underlying codecs remain the same.
  9. Understand how HTTPS secures data transmission

    HTTPS (Hypertext Transfer Protocol Secure) addresses three primary vulnerabilities of plain-text HTTP: data eavesdropping, data tampering (man-in-the-middle attacks), and server impersonation. It achieves security by inserting SSL (Secure Socket Layer) or TLS (Transport Layer Security) between the HTTP application layer and the TCP transport layer to provide encryption and data verification.
  10. Understand Tree Shaking principles and requirements

    Tree Shaking is an optimization technique that removes unused code (dead code) from JavaScript bundles using static analysis. It works by parsing code into an Abstract Syntax Tree (AST), building a dependency graph from the entry point, marking unused code, and removing it.

    Critical Requirement: Tree Shaking requires ES6 module syntax (import/export). It does not support CommonJS (CJS) because CJS modules are dynamic and dependencies are resolved at runtime, making static analysis impossible.

  11. Understand pnpm and its advantages over npm

    pnpm (performant node package manager) is a drop-in replacement for npm that optimizes dependency management using a centralized store and symlinks/hard links. It addresses three primary issues found in npm's flattened node_modules structure:

    1. Disk Space Efficiency: Unlike npm, which installs dependencies per project, pnpm stores all packages in a single global content-addressable store on the disk. Multiple projects share the same package versions via hard links, preventing redundant copies of the same dependency across different projects.
    2. Elimination of Phantom Dependencies: In npm's flattened structure, a project can access a package that is a dependency of one of its own dependencies, even if it isn't listed in package.json. pnpm prevents this by using a non-flat directory structure, ensuring only explicitly declared dependencies in package.json are accessible to the application code.
    3. Resolution of Doppelgangers: When multiple dependencies require different versions of the same package, npm may create multiple redundant copies of the same version in different sub-directories. pnpm's linking mechanism ensures that identical versions of a package are stored only once, improving installation speed, reducing bundle size, and ensuring that singleton patterns in libraries work correctly across the dependency tree.
  12. Understand the basic principles of Hot Module Replacement (HMR)

    Hot Module Replacement (HMR) allows developers to update, add, or remove modules in a running application without a full page refresh, preserving the application state. The process generally follows these steps:

    1. File Monitoring: The build tool (e.g., Vite) monitors source files for changes.
    2. Client Notification: The Dev Server notifies the browser via WebSocket when a change occurs.
    3. Module Update: The browser requests the updated module code via the HMR API.
    4. Module Replacement: The framework (e.g., Vue, React) replaces the old module with the new one while maintaining state.