In February 2020, Wang Yin trolled the type system of Java, saying. One of the more advanced interview questions about a programmer’s understanding of the Java type system is this: 1 2 3 4 5 6 public static void f() { String[] a = new String[2]; Object[] b = a; a[0] = "hi"; b[1] = Integer.valueOf(42); } Which line in this code is wrong? Why? If some version of Java
How to report errors via Kubernetes events
There is a Kubernetes webhook maintained within the group that intercepts pod creation requests and makes some changes (e.g. adding environment variables, adding init-container, etc.). The business logic itself is simple, but it’s hard to handle if errors are generated in the process. Either you directly prevent the pod from being created, then there is a risk that the application will not start. Either ignore the business logic, then it
Memory-based communication for gRPC calls
Apache Dubbo has the injvm method of communication, which can avoid the latency caused by the network, and also does not occupy the local port, which is a more convenient way of RPC communication for testing and local verification. I recently saw containerd’s code and found that it has similar requirements. But using ip port communication, there may be port conflict; using unix socket, there may be path conflict. I
Webpack Quick Start
This tutorial is for webpack beginners. This is also some notes I put together for newbies as I learn webpack myself. I. What is webpack? As a javascript front-end developer, you must know about webpack and the various modules. webpack is a packaging tool that bundles (packages) various modules together. The supported modules are: CommonJS AMD CSS import Images url Es module webpack bundles all modules together and makes them
The mystery of the React hook
As we all know, React has two forms of components, class components and function components, and developers can use class components and function components to achieve the same purpose and build the exact same page. Since I came across React last August, I have been using function components because they are recommended by my company. I have to say that function components are much better than class components. You can
Built-in Generics in TypeScript
*ypeScript provides some of the more useful generic types, but we often overlook them. In this section we’ll look at these generics together. Generic types Partial<Type> From a type, constructs a new type, where all properties of the new type are derived from the original type and all properties of the new type are optional. 1 2 3 4 5 6 interface Todo { title: string; description: string; } type
Babel Getting Started Tutorial
This tutorial is an introductory level tutorial for newcomers. The tutorial references the official documentation. It is assumed that you already have the necessary development environment such as node, npm (or yarn) installed. I. JavaScript’s Compiler Babel is a compiler for JavaScript. I don’t think the word compiler is very accurate to describe Babel, because JavaScript doesn’t need to be pre-compiled to run like C++ or C#, JavaScript is an
Detailed explanation of the tsconfig.json file
I personally like TypeScirpt, write code with Ts to be more comfortable than Js too much, can greatly improve the efficiency of writing code, reduce the workload of code maintenance. Because I have the foundation of C++ and C#, I can get started with Ts quickly. Although there is no difficulty in using it, but for a long time, did not go to understand the compilation process and configuration of
In-depth understanding of TypeScript's module system
Before the advent of ES2015, JavaScript did not have a native module system (ES Module) and had to resort to third-party RequireJS and SystemJS to use the module functionality. A module is essentially a JS/TS file, similar to a sandbox environment, that uses import statements to introduce the APIs and values of other modules, and export statements to expose its own APIs and values. TypeScript natively supports the syntax of
Using namespace to encapsulate data in TypeScript
I. namespace - namespace If you are familiar with C++, Java, C#, etc., namespace should not be new to you. namespace can be used to encapsulate a piece of code, and code outside namespace cannot directly access the code inside namespace. Namespaces are defined by the namespace keyword. The format is as follows. 1 2 3 namespace namespace_name { // 命名空间内部代码 } In
The Complete Guide to TypeScirpt Type Declarations
A Type Declaration or Type Definition file is a TypeScript file with a .d.ts file extension. What is the difference between them and a normal .ts file? What are their characteristics? Next, let’s take a deeper look. I. The .d.ts files Type declaration files have the suffix .d.ts and contain only type-related code, not logical code. Their purpose is to provide type information to the developer, so they are only
Comprehensive analysis of the JS this keyword
The this problem is one of the most complex problems in JavaScript, and even experienced programmers can inadvertently fall into the this keyword pit. Whenever a function is defined, this is automatically defined inside the function (even if the this keyword is not used inside the function). Function call location Before understanding this, let’s understand function call location. The call position of a function is where the function is called,
A brief introduction to Web Workers
“JavaScript is single-threaded”, Js developers have always thought so. But today we are going to introduce multi-threaded programming in JavaScript, you heard me right, I am talking about Multi-Threaded Programming - Web Workers . I. Preface Web Workers is a feature of the browser (the host environment), not a standard feature of JavaScript, so what does it do? Suppose you click a button on a page and it triggers the
C# read and write xml documents
C# read and write xml documents mainly through XmlDocument, XmlReader and XmlWriter three classes to achieve. XmlReader only has read functionality. XmlWriter has only write functionality. XmlDocument has both Read and Write functionality. Read This article, read the xml document for the online xml document (non-local files, replaced by local documents can also be), you can use your browser to open this document address: http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml to view the contents of
How computers store floating point numbers - IEEE754
Years ago when I was studying C++ at university, I learned that IEEE 754 is the most common way of representing floating point numbers in computers today. But since I work with it very little, I often forget the specific details of this standard, so I wrote this article to document it in detail.
How do you represent numbers? There are many ways to represent numbers. For example, the most common way we use when writing - fixing the position of the decimal point, placing a decimal point in the middle of several numbers to represent a decimal, or a whole number if there is no decimal point.
package.json Guide
Description The package.json file must be a JSON formatted file and not a JavaScript Object.
Most of the points that will be covered in this section are related to the configuration settings described in config.
name If you are publishing a package, name and version are the most important and essential fields. name and version must be able to be combined into a completely unique identifier. If the package generates an update, then the version field must also be updated to generate a new unique name-version identifier.
Pulsar transaction implementation principle
Apache Pulsar is a multi-tenant, high-performance inter-service messaging solution that supports multi-tenancy, low latency, read/write separation, cross-territory replication, fast scaling, flexible fault tolerance, and other features. This article will briefly introduce some concepts and principles of Pulsar server-side message acknowledgement. Preface Before transactional messages were available, the highest level of messaging assurance supported in Pulsar was to ensure that a Producer’s messages were saved exactly once on a single partition
CSS font-variation The charm of changeable fonts
Today, I saw an interesting effect on CodePen - GSAP 3 ETC Variable Font Wave.
Preview Link: https://codepen.io/Chokcoco/pen/BamYMYg
It is implemented with the JS animation library GSAP. Take a look.
I wondered if I could use CSS to achieve the same effect. After trying it out, I managed to achieve the original effect using pure CSS.
The core of the above effect is the animation of the text, which changes from thinner and tighter to thicker and farther apart.
Pkill command in Linux
This article describes the basics of the Linux pkill command.
pkill is a command-line program that can be sent to a running process based on a specified standard signal. A process can be specified by its full or partial name, the user running the process, or other attributes.
The pkill command is part of the procps (or procps-ng) package, which is pre-installed in almost all Linux distributions. pkill is a wrapper for the pgrep program, which prints a list of matching processes only.
How to install Tomcat 9 on CentOS 8
Apache Tomcat is an open source implementation of Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. It is one of the most widely used application and web servers in the world today. Tomcat is easy to use and has a robust ecosystem.
This tutorial describes how to install Tomcat 9.0 on CentOS 8.
Install Java Tomcat 9 requires Java SE 8 or higher. We will install OpenJDK 11 , which is an open source implementation of the Java platform.