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.
What's inside Alan Wei's Blog
- 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.
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:
- Simplified Installation: Distributed as a single binary with no dependencies.
- Automatic HTTPS: Automatically manages and renews SSL certificates via Let's Encrypt and ZeroSSL for all sites by default.
- 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.
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.
Introduction to the Symbol primitive type
Introduced in ES6,Symbolis 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 aTypeError).typeof Symbol(); // => "symbol"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
yieldkeyword.Key differences from regular functions:
- Declaration: Defined using
function*instead offunction. - Control Flow: Use the
yieldkeyword to pause execution. While a regular function can onlyreturnonce, a generator canyieldmultiple 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!"; }- Declaration: Defined using
Overview of data transfer methods in Node.js Worker Threads
Communication between Node.js Worker Threads can be achieved using a
MessageChannelfor two-way communication. Data can be passed between threads using three primary approaches:- Cloning: Creating a copy of the data for the receiving thread.
- Sharing: Using
SharedArrayBufferto allow multiple threads to access the same memory. - Transferring: Using a
transferListto move ownership of the data to a single thread, restricting access for the sender.
Overview of Flutter's scrolling and layout model
Flutter utilizes two primary layout models: the
RenderBoxbox model and theSliver(RenderSliver) on-demand list layout.Scrolling is managed by three key roles:
- Scrollable: Handles touch gestures and determines scroll offsets to build the Viewport.
- Viewport: The visible window/area of the list.
- Sliver: The elements displayed within the Viewport.
Layout Process:
Scrollabledetects a scroll and builds theViewportbased on the offset.ViewportpassesSliverConstraintsto theSliver.Sliverbuilds and lays out childRenderBoxcomponents on-demand and stores its position and drawing info in aSliverGeometryobject.
Coordinate System:
- Main Axis: The direction of scrolling (default is vertical).
- Cross Axis: The direction perpendicular to the scroll.
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.
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.NotImplementedExceptionfor 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.Weband compatible with any OWIN host. - NuGet Distribution: Distributed via NuGet for rapid iteration and updates.
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.
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.Understand and use Operator-Pending mode in Vim
Operator-Pending mode is a transient state activated after an operator (likedfor delete) is pressed, but before a motion or text object (likewfor 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.