LuoJia's Technical Blog

website·Indexed 30 days ago

https://blog.luojia.work

A collection of technical guides and tutorials covering Linux and macOS command-line efficiency, shell scripting (sed, awk, grep), network tools (curl, wget, OpenSSH), containerization with Docker and Vagrant, and development workflows involving Node.js, VSCode, and Unity.

Tokens
104.1K
Snippets
672
Records
763
Agent score
47%

What's inside LuoJia Blog

  1. Overview of VS Code Neovim extension

    The VS Code Neovim extension (asvetliakov.vscode-neovim) differs from simulation plugins like vscode-vim by embedding a native Neovim instance as a backend. This allows for nearly 100% compatibility with Vim/Neovim operations, including support for init.vim/init.lua configurations and Neovim-specific plugins, while maintaining VS Code's native features like LSP diagnostics, auto-completion, and debugging.

    Key benefits include:

    • Full coverage of native Neovim functions and complex commands (e.g., :normal!, @ macros).
    • Seamless Insert mode handled by VS Code (supporting native snippets and auto-completion).
    • Better performance by avoiding key-interception latency common in simulators.
  2. Overview of OpenSSL and SSL/TLS

    OpenSSL is an open-source toolkit and command-line suite providing end-to-end secure communication. It implements the SSL (Secure Sockets Layer) and TLS (Transport Layer Security) protocols to ensure:

    1. Data Encryption: Using symmetric keys to prevent interception.
    2. Identity Authentication: Using digital certificates to prevent Man-in-the-Middle (MITM) attacks.
    3. Integrity Verification: Using hash algorithms to ensure data has not been tampered with.

    Modern implementations primarily use TLS 1.2 and 1.3.

  3. Overview of You-Get command-line downloader

    You-Get is a lightweight, cross-platform command-line download tool designed to extract videos, audio, images, and subtitles/danmaku from major domestic and international platforms such as Bilibili, YouTube, Douyin, and Tencent Video.
  4. Overview of Vagrant for VirtualBox

    Vagrant is a virtualization environment management tool developed in Ruby. Its primary purpose is to provide a "standardized development environment" by defining virtual machine parameters—such as system images, network settings, and hardware resources—within a configuration file called the Vagrantfile.
  5. Understand AWK core syntax and execution flow

    AWK operates on a "PATTERN { ACTION STATEMENTS }" framework.

    • PATTERN: Determines when the action is triggered (e.g., matching a specific line, field, or range). If omitted, the action is executed for every line.
    • ACTION: A sequence of statements (separated by semicolons) defining what to do when a pattern matches.
    • Execution Flow: AWK reads input line by line; if a line matches the pattern, the corresponding action is executed.
  6. Understand LVM Architecture (PV, VG, LV)

    LVM (Logical Volume Manager) allows for dynamic disk space management by abstracting physical storage into a flexible pool. It consists of three layers:

    1. Physical Volume (PV): The smallest storage unit. It is a physical partition (e.g., /dev/sdb1) or an entire disk initialized with LVM metadata.
    2. Volume Group (VG): A storage pool created by combining one or more PVs. A PV can only belong to one VG.
    3. Logical Volume (LV): The final usable unit carved out of a VG. LVs can be formatted with a file system (e.g., ext4, xfs) and mounted as directories. They support dynamic expansion and reduction.
  7. Use the until loop for reverse logic repetition

    The until loop in Shell scripts executes a block of commands repeatedly as long as the test command returns a non-zero value (condition is false). The loop terminates immediately once the test command returns 0 (condition becomes true). This is the opposite of a while loop, which runs as long as the condition is true.
  8. Manually install OpenSSL 3.4.0 on MacOS M1/M2 (Monterey)

    When Homebrew fails to upgrade OpenSSL due to dependency conflicts or repository issues on M1/M2 Macs running MacOS Monterey, a manual compilation from source is required. This process ensures the correct architecture (arm64) is used and avoids system compatibility problems.

    Prerequisites

    • Hardware: M1/M2 chip (arm64).
    • OS: MacOS Monterey (12.x).
    • Tools: wget (or curl) and make. If make is missing, install Xcode Command Line Tools via xcode-select --install.

    Installation Steps

    1. Remove existing Homebrew OpenSSL: Prevent path conflicts by forcing removal of existing versions.
    2. Download Source: Fetch the stable source package from the official OpenSSL website.
    3. Configure: Use the darwin64-arm64-cc target for M1/M2 chips and specify a prefix path (e.g., /opt/homebrew/Cellar/openssl@3/3.4.0) to avoid permission issues in /usr/local.
    4. Compile: Run make with parallel jobs (e.g., -j4 or -j8) to speed up the process.
    5. Install: Use sudo make install with specific manual directory (MANDIR) and suffix (MANSUFFIX) settings.
    6. Path Configuration: Manually move the binary, include, lib, and ssl directories to the prefix path and create a symbolic link to /usr/local/bin/openssl so the system can locate the command.
    # 1. Uninstall old Homebrew versions
    brew uninstall --force openssl openssl@3
    
    # 2. Download and extract
    wget https://www.openssl.org/source/openssl-3.4.0.tar.gz
    tar -xvf openssl-3.4.0.tar.gz
    cd openssl-3.4.0
    
    # 3. Configure for M1/M2 (arm64)
    ./Configure darwin64-arm64-cc --prefix=/opt/homebrew/Cellar/openssl@3/3.4.0
    
    # 4. Compile and Install
    make -j4
    sudo make install MANDIR=/opt/homebrew/Cellar/openssl@3/3.4.0/share/man MANSUFFIX=ssl
    
    # 5. Organize files and create symlink
    sudo mkdir -p /opt/homebrew/Cellar/openssl@3/3.4.0/bin
    sudo mv ./apps/openssl /opt/homebrew/Cellar/openssl@3/3.4.0/bin/
    sudo mv ./include /opt/homebrew/Cellar/openssl@3/3.4.0/
    sudo mv ./lib /opt/homebrew/Cellar/openssl@3/3.4.0/
    sudo mv ./ssl /opt/homebrew/Cellar/openssl@3/3.4.0/
    
    sudo rm -f /usr/local/bin/openssl
    sudo ln -s /opt/homebrew/Cellar/openssl@3/3.4.0/bin/openssl /usr/local/bin/openssl
  9. Install CloudWatch Agent on Ubuntu

    Install the CloudWatch Agent using the official AWS S3 deb package for amd64 architecture. If dependency errors occur during installation, use apt -f install to resolve them.
    # Download the latest CloudWatch Agent for Ubuntu amd64
    wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
    
    # Install the package
    sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
    
    # Fix unmet dependencies if they occur
    sudo apt update && sudo apt -f install -y
  10. OpenSSL Component Architecture

    OpenSSL consists of three primary components:

    1. libcrypto: The core library implementing symmetric, asymmetric, and hashing algorithms. It provides C language interfaces for developers.
    2. libssl: The protocol library built on top of libcrypto. It handles SSL/TLS handshakes, session management, and certificate verification.
    3. openssl CLI: The command-line tool used by administrators to generate keys, sign certificates, encrypt files, and calculate hashes.
  11. Basic gawk command syntax and usage

    gawk (GNU awk) is a lightweight programming language used for structured text processing, such as extracting columns, performing calculations, and generating reports. The basic command structure is: gawk [options] 'program' file(s). If no file is specified, gawk reads from standard input (STDIN).
    gawk [options] 'program' file(s)