jason12306 Technical Articles
website·Indexed 30 days ago
https://jason12306.github.ioA collection of technical guides and notes covering Web3 (Solidity, Ethereum, TronWeb, web3-js), Linux administration (MySQL 5.7, MongoDB, Nginx SSL/WSS, PM2), frontend development (React CSS, Chrome Extensions, Flutter), and computer science fundamentals including knowledge graphs, microservices, and concurrency (processes, threads, and locking mechanisms).
What's inside jason12306 Blog
- Hydration is the process where client-side JavaScript 'activates' static HTML sent by a server (SSR) or a static generator (SSG). While the server provides HTML for fast initial load and SEO, the page is initially non-interactive. Hydration attaches event listeners and state management to the existing DOM, transforming the static page into a fully interactive Single Page Application (SPA).
Compare Pessimistic Locking and Optimistic Locking
Locking strategies are used to manage concurrent access to data.
Pessimistic Locking assumes conflicts are likely. It locks the data immediately upon reading, preventing other transactions from accessing or modifying it until the current transaction is complete. This ensures strong consistency but reduces concurrency and can lead to deadlocks.
Optimistic Locking assumes conflicts are rare. It does not lock data during reads. Instead, it checks if the data was modified by another transaction at the time of commit (usually via a version number or timestamp). If a conflict is detected, the update fails, and the application must handle the retry logic. This maximizes read performance and avoids deadlocks but requires a mechanism to handle update failures.
Understand the JavaScript Event Loop and Task Queueing
The JavaScript Event Loop is a mechanism used to manage the execution of asynchronous operations. It distinguishes between two types of tasks: macrotasks and microtasks. The event loop ensures that the main thread remains responsive by scheduling these tasks for execution after the current synchronous code has finished.Understand how private npm repositories function
A private npm repository acts as a proxy between the developer and the public registry. When a user runsnpm install, the private server checks if the requested module is a local private module or a previously cached public module. If found, it returns the module directly. If the module is a public one that hasn't been cached yet, the server requests it from an upstream source (such as the official npm registry or the Taobao mirror), caches it locally, and then returns it to the user.Understand the problems solved by JavaScript Promises
Promises are used in JavaScript to address two primary asynchronous programming challenges:
- Callback Hell: When the output of one asynchronous function is required as the input for the next, leading to deeply nested callbacks. Promises solve this via chainable
.then()calls. - Concurrent Asynchronous Requests: Managing multiple simultaneous requests and their collective error handling is simplified using
Promise.all.
- Callback Hell: When the output of one asynchronous function is required as the input for the next, leading to deeply nested callbacks. Promises solve this via chainable
Understand the Vue component rendering pipeline
The Vue rendering process follows a specific pipeline to transform templates into actual DOM elements. The flow is as follows:
- Compilation: The
<template>is compiled into arenderfunction. This can happen during a build step (ahead-of-time) or via a runtime compiler (just-in-time). The render function's purpose is to return a Virtual DOM (vnode) tree. - Mounting: The runtime renderer executes the render function to create the Virtual DOM tree and then creates actual DOM nodes based on that tree. This step is executed as a reactive effect, meaning it tracks all reactive dependencies used during the process.
- Updating: When a reactive dependency changes, the effect re-runs, creating a new Virtual DOM tree. The renderer compares the new tree with the old one (the diffing/patch process) and applies only the necessary changes to the real DOM.
- Compilation: The
Handle unhandled errors with Exception Filters
NestJS includes a built-in exception layer that catches all unhandled exceptions thrown by the application code. When an exception is caught, this layer automatically sends an appropriate, user-friendly response to the client.Understand the difference between Processes and Threads
In operating system terms:
- A Process is the smallest unit of resource allocation by the operating system (e.g., launching an application).
- A Thread is the smallest unit of CPU scheduling. Threads cannot exist independently and must rely on a process.
Integrate Nacos as a Service Registry for Service Discovery
In a Spring Cloud architecture, Nacos acts as the Service Registry to enable service discovery. This allows the API Gateway to automatically retrieve service URIs from the registry and implement dynamic load balancing without hardcoding service locations.Understand the difference between CSS Grid and Flexbox
CSS Grid is a two-dimensional layout system that divides a container into rows and columns to create cells, allowing items to be positioned in a grid. In contrast, Flexbox is a one-dimensional axis-based layout system, meaning it can only manage the position of items along a single axis (either row or column). Grid is generally more powerful for complex layouts that require both row and column control.Understand the different types of frontend automated testing
Frontend automated testing involves running test code to verify that target code meets specific expectations. There are four primary types of tests used to ensure software quality:
- Unit Testing: Tests the smallest pieces of code in isolation, such as utility libraries or shared sub-components. These should be the most numerous and have the highest coverage. High testability in unit tests usually indicates low coupling and better code quality.
- Integration Testing: Tests how multiple modules (which have already passed unit tests) work together. It is applied to highly coupled functions, wrapped components, or combinations of components to ensure the combined interface behaves as expected.
- UI Testing: Tests the frontend in a real browser environment but decoupled from the actual backend. It relies on Mock servers and data to simulate backend responses. This is closely aligned with the development flow in decoupled frontend/backend architectures.
- End-to-End (E2E) Testing: Validates the entire application including all dependencies in an environment that mimics the real user experience. It uses real data and real backend services to test complete user flows, such as logging into a site or completing a purchase.
Core components of a Knowledge Graph system
Building a comprehensive knowledge graph system requires five primary functional stages:
- Knowledge Modeling: Defining and organizing abstract knowledge, attributes, and relationships into a multi-level hierarchy to be converted into a physical database.
- Knowledge Acquisition: Transforming data from various sources and structures (structured, semi-structured via parsing, knowledge indexing, and knowledge reasoning) into graph data while ensuring validity and completeness.
- Knowledge Fusion: Merging duplicate or overlapping information from multiple sources using fusion computation engines or manual operations.
- Knowledge Storage: Implementing a flexible, diverse, and scalable storage solution tailored to the specific business scenario.
- Knowledge Application: Providing analysis and utility capabilities such as graph retrieval, knowledge computation, and visualization. This typically includes SDKs for graph basic applications, structural analysis, semantic applications, Natural Language Processing (NLP), data acquisition, and statistics.