slience\me Technical Notes

website·Indexed 29 days ago

https://slienceme.cn

A collection of technical guides and cheat sheets covering a wide range of development tools and technologies, including Git, GitHub, Linux, Ubuntu, Kylin V10, Nginx, Redis, ElasticSearch, Spring, Python (Matplotlib, YOLO, Anaconda), and virtualization tools like VMware, VirtualBox, and Vagrant.

Tokens
107.4K
Snippets
625
Records
742
Agent score
50%

What's inside slience\me Notes

  1. Overview of Factory Design Patterns

    The Factory pattern encapsulates object creation logic, hiding the instantiation process from the client and providing a common interface. It is generally divided into three types:

    1. Simple Factory: A basic class that creates objects based on input.
    2. Factory Method: Defines an interface for creating an object but lets subclasses decide which class to instantiate.
    3. Abstract Factory: Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
  2. Overview of LangChain4j

    LangChain4j is a library designed to simplify integrating LLMs into Java applications. It provides three primary value propositions:

    1. Unified API: Provides a consistent interface for 15+ LLM providers (e.g., OpenAI, Google Vertex AI) and 20+ embedding stores (e.g., Pinecone, Milvus), allowing developers to switch providers without rewriting code.
    2. Comprehensive Toolbox: Offers ready-to-use abstractions for prompt templates, chat memory management, function calling, agents, and Retrieval-Augmented Generation (RAG).
    3. Rich Examples: Provides a set of reference implementations for common LLM-driven application patterns.
  3. Overview of frp (Fast Reverse Proxy)

    frp is a high-performance reverse proxy application designed for intranet penetration. It allows users to expose local services (e.g., Web servers, databases, SSH) located behind a NAT or firewall to the public internet by using a relay node with a public IP address. It supports multiple protocols including TCP, UDP, HTTP, HTTPS, QUIC, KCP, and WebSocket, and features P2P communication to bypass server relay for lower latency.
  4. Overview of the Singleton Design Pattern

    The Singleton pattern is a creational design pattern that ensures a class has only one instance and provides a global point of access to that instance. It is primarily used to avoid the overhead of frequent creation and destruction of globally used classes, thereby saving system resources.

    Key components of a Singleton implementation:

    1. Private Constructor: Prevents external code from instantiating the class.
    2. Private Static Variable: Holds the unique instance of the class.
    3. Public Static Method: Provides the access point to the instance, creating it if it does not yet exist.
  5. Overview of Zipkin Distributed Tracing

    Zipkin is an open-source distributed tracing system designed for microservices architectures. It allows developers and operators to track the execution path of a request as it flows through multiple services, helping to locate performance bottlenecks and root causes of failures.
  6. Overview of MySQL High Availability Solutions

    There are several common approaches to achieving high availability (HA) in MySQL:

    • MySQL-MMM (Master-Master Replication Manager): A Perl-based open-source project that monitors master-master replication and handles failover by mapping real database IPs (RIP) to Virtual IPs (VIP). It uses a monitor to migrate VIPs to available nodes when a failure occurs.
    • MHA (Master High Availability): A mature solution focused on fast failover and master promotion, typically completing the switch within 0-30 seconds while maximizing data consistency.
    • InnoDB Cluster: A complete solution consisting of MySQL Shell (management), MySQL Router (client routing), and MySQL Server. It supports automatic failover, strong consistency, read-write splitting, and horizontal scaling.
  7. Overview of Redis and its use cases

    Redis is an open-source, high-performance key-value (NoSQL) database developed in C. It supports multiple data types to suit various storage needs and is designed for high-concurrency scenarios. Common application scenarios include:

    • Caching (data queries, short connections, news/product content)
    • Online friend lists for chat rooms
    • Task queues (e.g., flash sales, ticketing systems)
    • Application leaderboards
    • Website visit statistics
    • Data expiration handling (precision down to milliseconds)
    • Session separation in distributed cluster architectures.
  8. Introduction to NumPy and ndarray

    NumPy is a numerical computing library in Python. Its core object is the ndarray (n-dimensional array), which provides a high-performance alternative to Python's native lists for numerical data. Unlike Python lists, ndarray requires all elements to be of the same type, allowing for vectorized operations and C-level implementation that bypasses the Global Interpreter Lock (GIL) for better performance.
    import numpy as np
    
    # Creating a 2D ndarray
    score = np.array([[80, 89, 86, 67, 79],
                      [78, 97, 89, 67, 81],
                      [90, 94, 78, 67, 74],
                      [91, 91, 90, 67, 69],
                      [76, 87, 75, 67, 86],
                      [70, 79, 84, 67, 84],
                      [94, 92, 93, 67, 64],
                      [86, 85, 83, 67, 80]])
  9. Install Anaconda on Linux

    To install Anaconda, first determine your system architecture using uname -m (e.g., x86_64 for 64-bit x86). Download the corresponding installer from the Anaconda website and follow these steps:

    1. Run the installer script.
    2. Accept the license agreement by typing yes.
    3. Confirm the installation path (default is usually /home/user/anaconda3).
    4. When prompted to initialize Anaconda by running conda init, type yes to automatically update your shell profile (e.g., .bashrc).
    5. Restart the terminal or source the profile to activate the base environment.
    # Example installation command
    bash Anaconda3-2023.09-0-Linux-x86_64.sh
    
    # Verify installation
    conda -V
  10. Understand Redis Sentinel for High Availability

    Redis Sentinel provides high availability by monitoring Redis instances and automating failover. It solves the problem of manual intervention required when a master node fails. Sentinel provides three primary functions:

    1. Monitoring: Constantly checks if Master and Slave instances are functioning correctly.
    2. Notification: Notifies administrators or applications via API when a monitored Redis instance has a problem.
    3. Automatic Failover: Automatically promotes a slave to master if the master database fails.

    Detection Mechanism: Sentinel uses three periodic tasks to determine node health:

    • Every 10s: Sends inforeplication to get the latest topology.
    • Every 2s: Sends node info and health judgments to the _sentinel_:hello channel.
    • Every 1s: Sends ping commands for heartbeat detection.

    If a heartbeat is missed, the node is marked as 'Subjectively Down'. If a quorum of sentinels agrees, it becomes 'Objectively Down', triggering a leader election (via Raft algorithm) to coordinate the failover.

  11. Understand the removal of mapping types in Elasticsearch 7.x and 8.x

    Elasticsearch removed the concept of 'types' to improve data processing efficiency. In earlier versions, fields with the same name across different types were treated as the same field in Lucene, causing conflicts and performance degradation.

    Version Changes:

    • Elasticsearch 7.x: Specifying types in requests is deprecated. The include_type_name parameter defaults to false. The _default_ mapping type is removed. The endpoint _doc is now a permanent part of the path representing the endpoint name, not a document type.
    • Elasticsearch 8.x: Specifying types in requests is no longer supported, and the include_type_name parameter is removed.

    Migration Strategy: Migrate from multi-type indices to single-type indices, where each document type has its own independent index.

    # Elasticsearch 7.x+ Indexing patterns
    # For explicit IDs:
    PUT {index}/_doc/{id}
    
    # For auto-generated IDs:
    POST {index}/_doc
  12. Understand the Ubuntu directory structure

    Unlike Windows, which uses drive letters (e.g., C:, D:), Ubuntu uses a single root directory denoted by /. Key directories include:

    • /: The root directory
    • /bin: Contains executable binary files
    • /etc: Contains system configuration files
    • /home: Contains user home directories