Some Details About Golang Slice

Some Details About Golang Slice In Golang, there are two types of data: One is an array with a fixed length, called Array, and the other is an array with an unlimited length, called Slice. Distinguish Between Array and Slice The difference between Array and Slice is: Array is of fixed length, and the length of Array is part of the type, so the length of Array cannot be changed,

Summary of Commonly Used Principles in Computing

Commonly Used Principles in Computing When writing code, we often have some insights and experiences. These experiences have long been summarized into principles by the predecessors. In the past year, I have been collecting various principles and constantly applying and practicing them. KISS Principle The KISS Principle is an acronym for Keep It Simple, Stupid. The KISS principle refers to the principle that simplicity should be emphasized in design. Summarizing the experience of engineering professionals in the design process, most system designs should remain simple and pure, without incorporating unnecessary complexity, so that the system can operate optimally.

Relearning English Grammar

Background I feel that there are still many deficiencies in my English, so I studied some English grammar a while ago. In fact, many of them are things that need to be learned in junior high school, but I didn’t take it seriously at that time, and I didn’t learn anything from the teacher. I can’t say that I gave everything back to the teacher, because the scenarios where English is needed in work are increasing, so I still followed Youtube and learned a lot, so I wrote this summary article.

Office Worker's Recent Half-Year Experience in Learning and Practicing Fund Investment Portfolio

“Everyone should invest, the sooner the better. Even if you keep losing money, at least you will learn how to lose less after ten years. Instead of waiting until ten years later when you are forced to invest, you lose most of your principal at once” –@xiaodotdo Preface Because I stepped into work from school, I was actually a bit richer than when I was studying, and I was also quite frugal, so I had a lot of money left every month when I got paid.

Guide to Physically Crossing the Wall to Singapore During the Pandemic

“The difficulty of living abroad is smaller than imagined, but the determination needed to go abroad is greater than imagined” –@FreiheitYu The author wrote this article in early 2021, and there may be discrepancies due to the relaxation and tightening of immigration policies, for reference only. Preface This is a very struggling and bumpy experience. Under the situation of the pandemic, I still chose to come out from my country

About me

About me Welcome! I am Xiantang. This is my personal website, where I blog about things I learn or think about in my daily life. I hope you like it. My personal telegram channel is https://t.me/xiantang. I like programming and can use many languages, such as: Golang https://github.com/cosmtrek/air is my main language currently. Scala https://github.com/xiantang/redislimiter I have written some services. Python https://github.com/xiantang/Spider I have written some crawlers. Java https://github.com/xiantang/JerryMouse I have written a simple web container.

Soft Skills: A Guide for Lower-Level Employees in Big Companies

“I found that many articles and interviews are about how to get into big companies, but actually surviving in big companies is also a skill” Preface The author recently changed jobs, chose to follow his heart, and did not continue to work in the previous company. Taking advantage of the recent resignation, I quickly calmed down and output my previous experience. Although I only stayed in the previous company for almost a year (the previous company referred to in this article is a certain company), I still learned some of the working methods and processes of big companies.

Soft Skills: How do I acquire knowledge and information?

​ “We are all hunters in the wilderness of the information age, surviving in the vast wilderness of information.” - “Why Become an Information Predator” ​ In the era of mobile internet with information explosion, every internet giant is trying to build their own “information cocoon”, trying to recommend you some things you are interested in, and gradually your life will be shackled in a cocoon-like cage. As a [hacker] who yearns for freedom, naturally, he cannot be restricted by such a cage.

Implementation of Distributed Token Bucket Algorithm

What is the Token Bucket Algorithm? The token bucket algorithm is a rate limiting algorithm, which is the opposite implementation of the leaky bucket algorithm. The leaky bucket algorithm leaks at a certain frequency rate, and our requests can be imagined as the faucet above. The token bucket algorithm, on the other hand, periodically puts tokens into the bucket, and each request will get a token from the token bucket. If there are no tokens in the bucket, the request is rejected or blocked until a token can be obtained.

Implementing an AtomicInteger

What is AtomicInteger As the name suggests, AtomicInteger is an Integer with atomic operations. The difference between AtomicInteger and a regular Integer is that AtomicInteger uses a CAS method to make Integer’s increment and other operations atomic. Knowledge needed before implementation First, let’s look at the increment operation of AtomicInteger: 1 2 3 4 5 6 7 8 public final int incrementAndGet() { for (;;) { int current = get();

What is Minor GC/Major GC

What is Minor GC/Major GC First, let’s popularize the classic heap layout of JVM: For the classic JVM heap layout, there are two clear areas, the first is the Young area, which generally stores young objects or objects that have just been created. The second is the Old area, also known as the old generation, which generally stores longer-lived objects or objects promoted from the young area. For the young area, we have three areas, one is the Eden area, and the other two are Survivor areas of equal size.

Where is the GC root?

What is GC Root First of all, we know the marking algorithm, the JVM’s marking algorithm can be understood as a reachability algorithm, so all reachability algorithms will have a starting point, and this starting point is the GC Root. That is, it is necessary to find all living objects through the GC Root, and then all the remaining unmarked objects are the objects to be recycled. Characteristics of GC Root Objects that are alive at the current moment!

Design and Implementation of the Leaky Bucket Algorithm

What is the Leaky Bucket Algorithm? As the name suggests, the Leaky Bucket algorithm uses a leaky bucket to limit traffic. Because there is a hole at the bottom of the bucket, it will leak water at regular intervals, and we can imagine the traffic as water falling into the bucket from above. This leads to two situations. If the speed at which traffic is injected into the bucket is

Pointing to offer

No2 Singleton Pattern 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 class No2TwiceCheckSingleton { private volatile static No2TwiceCheckSingleton instance = null; private static final Object sybObj = new Object(); // 一定记住要私有化构造器,不然人家还是能够创建 private No2TwiceCheckSingleton() { } static No2TwiceCheckSingleton

Singleton Pattern

What is the Singleton Pattern? The Singleton Pattern, also known as the Singleton, is a commonly used software design pattern and is one of the creational patterns. In this design pattern, the class of the singleton object must ensure that only one instance exists. Pros and Cons Pros: There is only one instance in memory, reducing memory overhead. Cons: It violates the Single Responsibility Principle, and there is no interface,

TCP Study for Interviews

What is TCP TCP is a full-duplex, byte-stream protocol based on the IP protocol. TCP provides end-to-end accurate transmission. Acknowledges each byte Handles poor network conditions Timeout retransmission Congestion control Efficiency improvement Uses sliding window protocol TCP is a connection-oriented protocol. Since it is connection-oriented, how is this connection established? That is, the following question is how to establish a virtual link using a three-way handshake.

How Actor Handles Blocking Messages

I noticed in the business code that a lot of import scala.concurrent.ExecutionContext.Implicits.global is used as the thread pool for executing Future inside the Actor. I didn’t think there was a problem before. But after reading the akka source code, it seems a bit inappropriate. Let’s briefly talk about the architecture of Actor When an Actor sends a message to another Actor, it sends this message to the recipient’s mailbox The mailbox is a class that implements Runnable, so it can be executed by a thread pool.

Analysis of Akka Source Code

1 2 3 4 5 6 7 8 9 10 11 12 13 14 object Main1 extends App { val system = ActorSystem("HelloSystem") val jazzListener = system.actorOf(Props[Listener]) val musicListener = system.actorOf(Props[Listener]) system.eventStream.subscribe(jazzListener, classOf[Jazz]) // jazzListener 订阅 Jazz 事件 system.eventStream.subscribe(musicListener, classOf[AllKindsOfMusic]) // musicListener 订阅 AllKindsOfMusic 以及它的子类 事件 // 只有 musicListener 接收到这个事件 system.eventStream.publish(Electronic("Parov Stelar")) // jazzListener

How to learn Scala

Background: When I first came to a company with Scala as its technology stack, I spent a long time setting up the environment. After finally getting the project up and running, I found the code inside to be very strange. There were no loops, and data operations were a function nested within another function. This was very puzzling. So, driven by business needs and curiosity, I began to learn about Scala.

AES Requires Limiting SEED Length

I wrote a utility class to encrypt and decrypt the app field in the database There are no problems running unit tests in the local environment, but bugs appear in the production environment. The reason for this is that the online environment does not support the AES algorithm Provider. It needs to be solved by adding a third-party package that supports it under the ext package or introducing a third-party library.