Timestamps in computer systems

This is a brief note to organize the currently known timestamp counting standards for different computer systems. The question of how to express time is an ancient one. In the West, the year of Jesus’ birth was widely used as the “Gregorian calendar”, while in ancient China, people used the “Heavenly Stems and Earthly Branches” method of chronology, using a combination of the ten Heavenly Stems and twelve Earthly Branches, cycling once every sixty years.

Getting Started with IPv6

I don’t want to get into the specific design details of IPv6 technology, I just want to give a brief overview from a user’s perspective. As you know, IPv4 is 32 bits (4 bytes) and has 232 addresses, or 4.2 billion addresses. IPv6 is 128 bits (16 bytes), and there are 2128, or 3.4×1038, or 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses. For IPv4 address, according to the global population of 5 billion and one device per person, it is far from enough, not to mention multiple devices per person, especially in the era of Internet of Things.

Cgroup memory leak causing container not to be created

Sometimes you may find that K8S fails to create a Pod with the following error message. 1 2 3 OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: mkdir /sys/fs/cgroup/memory/kubepods/burstable/podxxx/xxx: cannot allocate memory: unknown" You can see the same error in the docker logs. 1 2 3 4 5 6 $ journalctl -u docker Mar 20 00:04:33 k8sworker06-new dockerd[3176]: time="2023-03-20T00:04:33.461528517+08:00" level=error msg="Handler for POST /v1.

Global variables in Golang

C is one of the ancestors of Go, and Go inherits a lot of C syntax and expressions, including global variables, although Go does not directly give the definition of global variables in its syntax specification, but those who have already started Go know that the package exported variable in Go plays the role of a global variable. exported variables are similar to C global variables in terms of advantages, disadvantages, and usage.

UPS Nut Configuration Tutorial

1. Nut installation Here I use Ubuntu Server 22.04 system, the installation can be done directly with one apt command: 1 apt install -y nut 2. Nut service components Before configuring Nut, we need to understand the components of Nut and their roles. Nut mainly contains three core services: nut-driver: This service is responsible for communicating with the UPS via a specific driver. nut-server: This service uses nut-dirver to communicate with the UPS and to publish the UPS status via web services.

Getting Started with APISIX, the cloud-native API gateway

Apache APISIX is a cloud-native API gateway under the Apache Software Foundation that is dynamic, real-time, and high-performance, providing rich traffic management features such as load balancing, dynamic upstream, grayscale release (canary release), service circuit break, speed limit, defense against malicious attacks, authentication, observability, and more. We can use Apache APISIX to handle traditional north-south traffic, as well as east-west traffic between services. It also supports use as a Kubernetes Ingress Controller.

Using AppArmor to Restrict App Permissions

It is well known that in cloud-native environments, we can control application access to resources in the cluster through RBAC mechanisms, but these are not enough for production environments, where the host is still a security risk when applications have access to host resources (e.g. Linux privilege words, network access, file permissions). For this situation, the Linux kernel security module AppArmor supplements standard Linux user and group-based permissions to limit the application to a limited set of resources and also serves as a protection for the Pod from unwanted attacks.

Redis is unable to schedule Slave after stopping Master node in Sentinel mode

When I manually kill the service at the redis master node, the slave node cannot be scheduled. The slave Sentinel error log is as follows. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 13322:X 16 Mar 2023 05:56:05.855 * Sentinel new configuration saved on disk 13322:X 16 Mar 2023 05:56:05.855 # +vote-for-leader 56633d20baa5b74afdabb4284967c899fa616471 26 13322:X 16 Mar 2023 05:56:05.

Using mobx to take over all state in react

Among react hooks, useEffect is the most commonly used hooks function, but its api experience of manually managing dependency state has been criticized for a long time, and there are countless articles on how to use useEffect properly in the community, but it still doesn’t stop the fact that more newcomers have a hard time using this api properly, which is also jokingly called the react newbie wall. Moreover, react is the only popular web framework that requires manual management of hooks dependencies.

Go Subtest

Unit testing is a crucial part of software development, and its existence includes but is not limited to the following aspects. Improving code quality: Unit testing ensures correctness, reliability and stability of code, thus reducing code defects and bugs. Reduce regression testing costs: When modifying code, unit testing can quickly check whether it affects the functionality of other modules, avoiding the cost of regression testing the entire system. Promote teamwork: Unit testing can help team members better understand and use the code written by each other, improving the readability and maintainability of the code.

GPT-4 shock release: large multimodal model, far ahead, top 10% of mock bar exam scores!

We’ve created GPT-4, the latest milestone in OpenAI’s effort in scaling up deep learning. GPT-4 is a large multimodal model that, while less capable than humans in many real-world scenarios, exhibits human-level performance on various professional and academic benchmarks. https://openai.com/research/gpt-4 At 1am today, the Open AI team tweeted the official announcement that GPT-4 is here! GPT-4 will be one of the largest and most powerful language models developed by OpenAI, and OpenAI hopes to improve the language understanding and generation capabilities of GPT-4 by using more training data and higher model parameters.

self vs Self

In the process of learning the swift language, you will constantly find some unbelievable syntax of swift. After learning it, I often ask myself, “Is it really necessary? Before learning it, who would have thought that self and Self are different? Keyword self Scenario 1 Prefix self. The prefix self. is the most commonly used scenario, when the keyword self, similar to the this keyword in other languages, represents the instance of the current code run during the coding process.

Is Go an object-oriented programming language?

Golang has been open source for 13 years, and in the recent TIOBE ranking of programming languages for March 2023, Go once again broke into the top 10, moving up two spots from Go’s ranking at the end of 2022. Many first-time Go developers, many of whom come from the OO (object-oriented) language camp like Java, Ruby, etc., ask the first question they ask after learning Go: Is Go an OO language?

Talking about IaC: Infrastructure as Code

In fact, the concept of IaC has been around for a long time. This article briefly talks about the past, present, and future of IaC. IaC’s Past IaC actually has a long enough history. First, let’s look at the core features of IaC. The end product is a machine readable product. It could be a piece of code, or it could be a preparation file. based on machine readable products, can further rely on existing VCS systems (SVN, Git) to do versioning.

GCC and G++

GCC/G++ is used to compile and link C/C++ programs, long story short, a compiler. Its history is not described here, so those who are interested can check it out for themselves. Compilation process of C/C++ Before introducing GCC/G++, let’s briefly explain the process of compiling and linking C/C++ to generate executable files. Source file preprocessing: c preprocessing (cpp.exe) to process macros in source files, etc. 1 cpp hello.c > hello.i Compile: gcc/g++ compiles the preprocessed code into an assembly program, the -S option indicates the generation of an assembly program file (.

Links & Libraries

Virtual Memory The first thing we need to have a clear idea of what we normally call memory is that what we are talking about is actually virtual memory, not manipulation of real physical memory. On a bare metal machine without an operating system installed, the memory we are dealing with is physical memory. As computers evolved, a program called an “operating system” was installed on the computer, which took over all the hardware resources and provided us with a layer of abstraction.

Several ways to run services in the background on Linux

There are several common ways to run programs in the background of Linux. ctrl+z screen nohup supervisor systemd The following practice is based on the Ubuntu2204 system, but theoretically other Linux distributions are also applicable. 1. Distinguish usage scenarios If the command takes a little longer to execute and you don’t need to see the output, use & as a background run flag or use ctrl+z to hang the process in the background after running, combined with jobs and fg to switch the background tasks of the current session.

GMP Model for Go Scheduler

Go implements a goroutine scheduler in its own runtime for the efficiency of its goroutine execution and scheduling. The following is a simple code to show the goroutine of a Go application at runtime for better understanding. The Go scheduler is part of the Go runtime, and the Go runtime is built into your application 1 2 3 4 5 6 for i := 0; i < 4; i++ { go func() { time.

Automatic update of running Docker containers

Nowadays, everyone is definitely containerizing their services, and how to effectively manage and upgrade the containers without affecting the existing services is an important issue. However, in the CI/CD flow, there are definitely two steps that are necessary, the first is to package the environment into a Docker Image and upload it to the company’s private Docker Registry, after uploading, connect to the machine via SSH and pull the new image file, and then restart the running service through the Graceful Shutdown mechanism.

Usage of Python __slots__

Python is a dynamic language, and you can add or subtract properties or methods to instances or classes dynamically. But using the __slots__ attribute can qualify class or instance properties and methods; without __slots__ the instance properties and methods are contained in the instance’s __dict__ dictionary, and the class properties and methods are contained in the class’s __dict__ dictionary. The following problems may occur when using __slots__ as written in the normal way.