10 great JavaScript string tricks

We call a sequence of characters a string. This is one of the basic types found in almost all programming languages. Here we show you 10 great tips about JS strings. 1. How to duplicate a string multiple times JS strings allow simple repetition. Unlike copying a string purely by hand, we can use the string REPEAT method. 1 2 3 4 5 const laughing = '

Crate and mod in Rust

crate Let’s start with the official definition. A crate is a binary or library. The crate root is a source file that the Rust compiler starts from and makes up the root module of your crate (we’ll explain modules in depth in the “Defining Modules to Control Scope and Privacy” section). A package is one or more crates that provide a set of functionality. A package contains a Cargo.toml file

Improving Directory Cache Performance

Introduction In Increasing the Effectiveness of Directory Caches by Deactivating Coherence for Private Memory Blocks, the authors describe a dynamic predictive approach to diverting memory regions that are only used by one processor Cache performance can be improved by discarding the coherence protocol. Using directory-based consistency protocols in most shared-memory multicore processors would not result in insufficient bus bandwidth, but recording all memory blocks in main memory would require the use of a large amount of storage requirements.

Golang Common Interview Questions

1. What are the advantages or features of Go compared to other languages? Go allows cross-platform compilation, compiling a binary executable that can be deployed directly on the corresponding system and run. Go inherently supports high concurrency at the language level, through goroutine and channel. channel is based on the CSP concurrency model, which is called ``sharing memory through communication’’; Go implements its own scheduling mechanism in the runtime: GMP,

Collecting logs of containers in k8s with fluentd

Background When maintaining a k8s cluster, a very common requirement is to persist the logs, on the one hand to facilitate future traceability, and on the other hand to aggregate the logs of the replicate out of the same service. In my current needs, I only need to persist the logs and do not need to do additional analysis. So I did not deploy a service like ElasticSearch to index the logs.

Researching how k8s networks work

I’ve been using k8s for a while now, and I’ve encountered problems with iptables and other things that cause problems with the network between k8s nodes, so I wanted to look into how the k8s network works. Docker Networking Let’s start by looking at how Docker networking is implemented. Docker first creates a bridge called bridge0. 1 2 3 4 5 6 7 $ ip a show docker0 3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:c4:87:73:bf brd ff:ff:ff:ff:ff:ff inet 172.

Cache coherence protocol analysis

Write-invalidate and Write-update There are two basic cache coherence ideas. write-invalidate: when writing data, set this Cache Line in other Cache to Invalid write-update: when writing data, write the new result to other Cache that has this Cache Line Write-once protocol The write-once protocol defines four states. Invalid: indicates that the block is not legal Valid: indicates that the block is legal and may be shared, and that the data has not been modified Reserved: indicates that the block is legal, not shared, and that the data has not been changed Dirty: means the block is legal, not shared, and the data has been modified, which is different from the memory.

Implementing io_uring based asynchronous random file reading in Rust

In a nutshell: In skyzh/uring-positioned-io, I wrapped the underlying io_uring interface provided by Tokio and implemented io_uring based asynchronous random file reading in Rust. You can use it like this. 1 ctx.read(fid, offset, &mut buf).await?; This article introduces the basic use of io_uring, then describes the implementation of an asynchronous read file library I wrote, and finally does a benchmark to compare performance with mmap. Click here to visit the GitHub project.

Interface and implementation of io_uring

io_uring is an asynchronous I/O interface provided by Linux. io_uring was added to the Linux kernel in 2019, and after two years of development, it has now become very powerful. This article introduces the io_uring interface based on Linux 5.12.10. The implementation of io_uring is mainly in fs/io_uring.c. User State API for io_uring The implementation of io_uring uses only three syscalls: io_uring_setup , io_uring_enter and io_uring_register. They are used to

Exploring String Implementation Through Redis Source Code

Overview I’ve been learning C through Redis recently, and I have to say that Redis code is really neatly written. This article is a comprehensive and in-depth explanation of the source code implementation of the Redis data structure, so I hope you can learn something from it. The source code for Redis strings is placed in two files, sds.c and sds.h. The implementation has been stripped out into a separate

SRV records in DNS

SRV record is an abbreviation for Server Resource Record, a record of service resources provided by a server supported in the DNS server’s database, whose main purpose is to indicate what services a server is capable of providing. Simply put, an SRV record is a simple piece of information about which computer provides which service. SRV records are the new face of DNS records, and were only defined in RFC 2052, so many older versions of DNS servers do not support SRV records.

Redirection in the Linux Shell

I often see other people’s shell scripts followed by a 2>&1, and have never bothered to look deeper, so today this topic will be the starting point to expand and learn about the topic of redirection in the linux shell. Special things First, let’s look at some special things in linux to lay the groundwork for the rest of the content. Special files /dev/null empty, you can import garbage content

Learning the SUID mechanism in Linux

What is SUID SUID abbreviation bit, the full English name is Set owner User ID up on execution, it is a special file permissions, to enable users (such as Bob) with other users (such as root user) permissions to run a program, without the need to use sudo to temporarily elevate privileges. In the same category there is SGID, so without going into detail, the principle is the same as

How Do Onion Service Work?

Communication flow The communication to be described here is the process by which a user connects to the Onion service through the tor browser. For ease of expression, Alice is used here to denote the client and Bob to denote the server. Step 1: The server side sets up its own introductory node The server uses introduction points to forward the introduction messages from the client in order not to reveal its IP.

IPFS Beginner's Manual

Introduction to IPFS IPFS is known as InterPlanetary File System. It is a network transport protocol designed to create persistent and distributed storage and shared files, a content-addressable peer-to-peer hypermedia distribution protocol. All the global nodes in the IPFS network will constitute one distributed file system, and everyone in the world will be able to store and access the files inside IPFS through the IPFS gateway. Originally designed by Juan

Kubernetes Pod Delete Operation Source Code Analysis

For example, now I have an application with an update policy of Recreate, and then execute the delete command as follows. 1 2 3 4 5 ☸ ➜ kubectl get pods NAME READY STATUS RESTARTS AGE minio-875749785-sv5ns 1/1 Running 1 (2m52s ago) 42h ☸ ➜ kubectl delete pod minio-875749785-sv5ns pod "minio-875749785-sv5ns" deleted Observe the application status on another terminal before deleting it. 1 2 3 4 5 6 7 8 9 10 11 12 ☸ ➜ kubectl get pods -w NAME READY STATUS RESTARTS AGE minio-875749785-sv5ns 1/1 Running 1 (2m46s ago) 42h minio-875749785-sv5ns 1/1 Terminating 1 (2m57s ago) 42h minio-875749785-h2j2b 0/1 Pending 0 0s minio-875749785-h2j2b 0/1 Pending 0 0s minio-875749785-h2j2b 0/1 ContainerCreating 0 0s minio-875749785-sv5ns 0/1 Terminating 1 (2m59s ago) 42h minio-875749785-sv5ns 0/1 Terminating 1 (2m59s ago) 42h minio-875749785-sv5ns 0/1 Terminating 1 (2m59s ago) 42h minio-875749785-h2j2b 0/1 Running 0 17s minio-875749785-h2j2b 1/1 Running 0 30s As you can see from the above process, the Pod becomes Terminating after we execute the kubectl delete command, and then disappears.

GoBGP Principles and Practices

GoBGP is an open source tool developed in Go language and running on Linux systems that provides control plane functionality for the BGP protocol. Compared to Quagga/FRRouting, GoBGP has better performance and shorter convergence time, and can be used for larger networks, such as acting as an IXP router. GoBGP can be configured via the gRPC API using multiple languages such as Python, C++, and of course the CLI. goBGP

10 useful custom hooks vue.js

Vue was the first JS framework I ever used. You could say that Vue was one of the first doors into the JavaScript world for me. For now, Vue is still a great framework. With the advent of the composition API, Vue is only going to get bigger. In this post, I’ll cover 10 useful custom hooks that will make our code look even better. useWindowResize This is a basic hook, as it is used in many projects.

Analysis of GC implementation in Go language

In the various widely circulated C rules, there is generally this mysterious rule that no local variables can be returned. 1 2 3 4 5 int * func(void) { int num = 1234; /* ... */ return &num; } When the function returns, the stack frame of the function (stack frame) is destroyed, and the memory referenced by the destroyed location is lightly confused with data, and heavily segmentation fault.

Musk became a major shareholder of Twitter caused a "shock": some people made a billion before others, some resigned, some angry mockery

In the past few days, the news of Tesla CEO Elon Musk joining the board of directors has caused a “shock” in the tech world. Musk has made $1 billion since becoming Twitter’s largest shareholder According to SEC filings, Tesla CEO Musk “quietly” bought $2.89 billion – 9.2 percent of witter shares – from January through April of this year. Although Musk only owns 9.2% of Twitter, this is already higher than all individual and institutional Twitter holdings, knowing that Twitter founder Jack Dorsey’s share is only 2.