Alan Wei's Blog

website·Indexed 31 days ago

https://blog.alanwei.com/

A technical blog featuring tutorials and guides on a wide range of topics, including WireGuard NAT-to-NAT traversal using DNS-SD, Caddy server basics, SSH port forwarding, dotnet-script, and development tips for TypeScript, JavaScript, and React. The site also covers big data ecosystems like Hadoop, Hive, and Spark, as well as infrastructure notes on Docker, Maven, and GitHub Actions.

Tokens
195.5K
Snippets
1.2K
Records
1.5K
Agent score
54%

What's inside Alan Wei's Blog

  1. Overview of WireGuard NAT-to-NAT Traversal via DNS-SD

    WireGuard uses Cryptokey Routing, associating public keys with IP addresses (AllowedIPs). While it supports IP roaming, establishing a connection between two peers both behind NATs (without fixed public IPs or port forwarding) requires a way to dynamically discover both the public IP and the public port of the peer. This guide proposes a solution using DNS-SD and STUN-like mechanisms to enable direct UDP hole punching between peers, avoiding the latency and cost of a central hub-and-spoke VPN gateway.
  2. Overview of Caddy Web Server features

    Caddy is a powerful, extensible platform written in Go used for serving sites, services, and applications. Key advantages over Nginx include:

    1. Simplified Installation: Distributed as a single binary with no dependencies.
    2. Automatic HTTPS: Automatically manages and renews SSL certificates via Let's Encrypt and ZeroSSL for all sites by default.
    3. Native HTTP API: Allows configuration changes to be made dynamically via an HTTP API without manual file edits.

    Note: While easier to set up, Caddy may have a smaller ecosystem and lower raw performance compared to Nginx, though it is sufficient for most personal use cases.

  3. Overview of specialized Hadoop ecosystem components

    Beyond core storage and processing, the ecosystem includes specialized libraries and systems for specific tasks:

    • Mahout: A distributed machine learning library.
    • Protobuf: A library and encoding format for data exchange.
    • ZooKeeper: A high-consistency distributed coordination service for managing configuration and synchronization.
  4. Introduction to the Symbol primitive type

    Introduced in ES6, Symbol is the seventh primitive data type in JavaScript. Unlike strings or objects, every symbol is guaranteed to be unique. Symbols are immutable and cannot have properties assigned to them (attempting to do so in strict mode results in a TypeError).
    typeof Symbol(); // => "symbol"
  5. Introduction to ES6 Generator Functions

    Generator functions are a special type of function in ES6 that can be paused and resumed. Unlike regular functions that run to completion, generators allow for multiple exit and entry points using the yield keyword.

    Key differences from regular functions:

    • Declaration: Defined using function* instead of function.
    • Control Flow: Use the yield keyword to pause execution. While a regular function can only return once, a generator can yield multiple times.
    function* quips(name) {
      yield " Hello " + name + "!";
      yield " Hope you like this ES6 intro ";
      if (name.startsWith("X")) {
        yield " Your name " + name + " starts with X, cool!";
      }
      yield " See you next time!";
    }
  6. Overview of data transfer methods in Node.js Worker Threads

    Communication between Node.js Worker Threads can be achieved using a MessageChannel for two-way communication. Data can be passed between threads using three primary approaches:

    1. Cloning: Creating a copy of the data for the receiving thread.
    2. Sharing: Using SharedArrayBuffer to allow multiple threads to access the same memory.
    3. Transferring: Using a transferList to move ownership of the data to a single thread, restricting access for the sender.
  7. Overview of Flutter's scrolling and layout model

    Flutter utilizes two primary layout models: the RenderBox box model and the Sliver (RenderSliver) on-demand list layout.

    Scrolling is managed by three key roles:

    1. Scrollable: Handles touch gestures and determines scroll offsets to build the Viewport.
    2. Viewport: The visible window/area of the list.
    3. Sliver: The elements displayed within the Viewport.

    Layout Process:

    • Scrollable detects a scroll and builds the Viewport based on the offset.
    • Viewport passes SliverConstraints to the Sliver.
    • Sliver builds and lays out child RenderBox components on-demand and stores its position and drawing info in a SliverGeometry object.

    Coordinate System:

    • Main Axis: The direction of scrolling (default is vertical).
    • Cross Axis: The direction perpendicular to the scroll.
  8. Overview of ECMAScript 6 (ES6) impact and compatibility

    ECMAScript 6 (ES6) represents a major version upgrade to the JavaScript core language. It introduces significant new language and library features ranging from syntactic sugar (e.g., arrow functions, string interpolation) to complex new concepts (e.g., proxies, generators, iterators, and the for-of loop).

    ES6 is designed for maximum backward compatibility; existing JavaScript code written for previous versions (like ES5) will continue to run normally. Many modern browsers implement ES6 features incrementally.

  9. Overview of ASP.NET Identity features and advantages

    ASP.NET Identity is a modern membership system designed for Web, Phone, and Tablet applications. It replaces legacy systems (like ASP.NET Membership and Simple Membership) by providing a flexible, decoupled framework for authentication and authorization. Key features include:

    • Broad Framework Support: Works across ASP.NET MVC, Web Forms, Web API, and SignalR.
    • Schema Control: Developers have full control over the user and profile data schema (e.g., adding custom fields like birthdates).
    • Storage Flexibility: Uses Entity Framework (EF) Code First by default for database persistence, but can be easily swapped for NoSQL, Azure Storage Tables, or SharePoint without requiring System.NotImplementedException for unsupported relational operations.
    • Unit Testability: Designed to be unit-testable, unlike previous membership systems.
    • Claims-Based Authentication: Supports claims-based identity, allowing for rich user identity descriptions beyond simple boolean role memberships.
    • Social Login Integration: Easy integration with external providers such as Azure Active Directory, Facebook, Google, and Twitter.
    • OWIN Integration: Built on OWIN middleware, making it independent of System.Web and compatible with any OWIN host.
    • NuGet Distribution: Distributed via NuGet for rapid iteration and updates.
  10. Overview of OkHttp features

    OkHttp is an efficient HTTP client that provides several built-in performance and reliability features:

    • HTTP/2 support: Allows requests to the same host to share a single socket.
    • Connection Pooling: Reduces request latency when HTTP/2 is unavailable.
    • GZIP Compression: Reduces the size of downloaded resources.
    • Response Caching: Prevents redundant network requests.
    • Automatic Retries: Automatically retries requests when network issues occur or fails over to alternative IP addresses for services with multiple IPs (IPv4/IPv6).
    • Modern TLS Support: Includes TLS 1.3 ALPN and certificate pinning.
    • API Design: Uses a fluent builder pattern for immutable requests and supports both synchronous blocking calls and asynchronous callbacks.
  11. Understand the role of YARN in the Hadoop ecosystem

    YARN (Yet Another Resource Negotiator) serves as the central scheduling system for the Hadoop ecosystem. It manages resource allocation across the cluster, ensuring that different components and tools can operate concurrently and orderly by coordinating which tasks have access to specific resources at any given time.
  12. Understand and use Operator-Pending mode in Vim

    Operator-Pending mode is a transient state activated after an operator (like d for delete) is pressed, but before a motion or text object (like w for word) is provided. It acts as a state machine that only accepts motion commands to complete the operation. This mode allows for the creation of custom operators and motions to extend Vim's vocabulary. You can cancel an operation and return to Normal mode by pressing <Esc> while in this mode.