关于 xiantang | 咸糖

目前在新加坡工作,同时比较喜欢开源和投资。

RSS 地址: https://vim0.com/index.xml

请复制 RSS 到你的阅读器,或快速订阅到 :

xiantang | 咸糖 RSS 预览

Neovim: No Crash Incremental Selection

2024-07-11 23:16:09

When I use neovim treesitter incremental selection, it randomly crashes, but I cannot stable reproduce it. And I found some issues and complaints about this issue, but no solution. So I decide to write a blog post to record this issue and the solution. related issues: https://www.reddit.com/r/neovim/comments/10wwkft/comment/j7qla2q/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button https://github.com/neovim/neovim/issues/24336 https://github.com/neovim/neovim/issues/25254 https://www.reddit.com/r/neovim/comments/18dn4qt/treesitter_incremental_selection/ TL;DR paste this https://github.com/xiantang/nvim-conf/blob/7c0d6cbf6d9fd7b6a8960de887db1109332419bf/lua/plugins/treesitter.lua#L62-L132 into your neovim configuration file. this is my treesitter incremental selection configuration: 1 2 3 4 5 6 7 8 9 incremental_selection = { enable = true, keymaps = { init_selection = true, node_incremental = "v", node_decremental = "<BS>", }, }, sometime when I use v to expand the selection, it crashes, and it’s a Segmentation fault, and I have the report:

Nixos use old version software

2024-07-08 23:42:39

NixOS users often face situations where the latest software versions have issues, but the NixOS channel only offers the fixed versions. Here’s how to use an older version of software: According to the blog post How to use old versions of software in NixOS, you can follow these steps to use an older software version: Search for the old version of the software Use https://lazamar.co.uk/nix-versions/ to search for old packages.

Yabai Sometimes Puts Windows Below Other Windows

2024-07-01 23:08:16

Yabai Sometimes Puts Windows Below Other Windows I’ve been using yabai on my company’s MacBook and noticed it sometimes places windows below others, a behavior not observed on my personal MacBook. By running yabai -m query --windows, I discovered differences in window layouts between the two machines: 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 26 27 28 29 30 31 32 33 34 35 [ { "id": 140, "pid": 1087, "app": "iTerm2", "space": 2, "level": 0, "layer": "normal", "opacity": 1.

Summary of 2022

2023-01-01 16:30:40

Today is the first day of 2023, I want to write a year-end summary, to review some things in 2022. It is also a review of myself. Year-end Summary of 2022 2022 was not a very smooth year, it seems that everyone is not doing particularly well due to the economic downturn. Work I have been working in Singapore for more than a year and a half. Because Singapore does not have four seasons, every day is actually similar to the previous one.

Using neovim as a PDE (Personalized Development Environment)

2022-10-29 20:45:20

This article will not tell you how to configure neovim step by step, but will tell you some “Tao” about PDE, not the specific practice of “Art”. Introduction to neovim and PDE Seeing TJ’s YouTube introduced the use of neovim as a PDE, it was interesting, so I tried it myself, it felt good, so I recorded it. What is neovim Neovim is a branch of vim, vim is a text editor, neovim is a branch of vim, its goal is to provide a better vim, not a substitute for vim.

Shell is a good productivity tool

2022-09-12 14:34:53

If a sequence of three commands is executed twice in a row, it is recommended that you write it as a Shell script – blog.fleeto.us Recently, I increasingly realize that shell can replace python as the second language for devops engineers. Because daily work may be repetitive, many repetitive operations in work can be reduced by shell scripts to reduce mental burden. Let me give you an example:

Using the 80/20 Rule to Learn awk Effortlessly

2022-06-29 22:14:09

The length only accounts for 20%, but the effectiveness reaches 80% - 80/20 Rule What can you learn from this article? In this article, we will learn how to use the 80/20 rule to effortlessly learn the linux text processing command awk. After reading this article, you will learn a fast learning method, and how to use awk to process text and stdout. Recently, while learning awk, I found that there are really many details.

Guide to Settling in Singapore After Physically Crossing the Wall

2022-06-12 21:33:31

What can you get from reading this article This article mainly talks about some things you need to do after coming to work in Singapore. By reading this article, you can get some necessary things you need to do after landing in Singapore, such as renting a house, applying for a bank card, etc., to prevent everyone from stepping into pitfalls. Renting a House The first important thing after coming to work in Singapore is to rent a house.

Using Docker Compose to Set Up Your Own Development Environment

2022-05-05 22:08:34

Docker is not a new technology, but a tool that puts old wine in new bottles. Actually, I used Docker when I was in college, around 2017, when Docker was in its heyday. It was just used to start various lightweight applications, such as magnetic link downloaders, personal network disks, etc. Until recently, my understanding of Docker was still relatively vague. As I continued to encounter requirements at work, I also continued to understand Docker, so I decided to write an article to summarize my recent use of Docker.

Some Practices and Thoughts on Writing Maintainable Code

2022-04-10 23:08:16

Some Practices and Thoughts on Writing Maintainable Code Recently, I have been modifying a piece of historical code that has a distinct style and has been handled by many hands. I found that there are many mistakes in the design of the code. This makes it very difficult for me to modify the code and add new features. This article is written with personal emotions, so there may be some subjectivity.

Why do I use bidirectional links for note-taking?

2022-02-27 23:15:45

The value of a person lies in finding connections between memorized information. I previously recommended bidirectional link software to my friends for rote memorization, and many people asked me “Why use bidirectional links? What are the benefits?”. I will write a short article here to answer these questions. I have tried many note-taking software before, such as Notion, Evernote, and even Typora managed directly with git. Most of the time, I didn’t have the motivation to take notes.

About Anxiety and Procrastination

2022-02-20 21:17:20

Procrastination always allows us to live in peace, but the problem does not disappear. – “Pomodoro Technique Illustrated” Current Issues Stress causes anxiety, there is always a lot of pressure in Internet companies, some come from overly high OKRs, some come from colleagues' push, and even you will put a lot of pressure on yourself. For me, it might be all of these, and possibly the pressure given by the morning meeting and weekly report.

Golang: How to Handle Growing Interfaces

2022-02-13 20:23:51

The bigger the interface, the weaker the abstraction. Go Proverbs Let’s start with the conclusion. If your Golang interface has too many functions that make it difficult for you to expand horizontally, then split it into multiple interfaces according to its responsibilities, and then use embed to combine them. Problem Encountered Recently, when refactoring a component that manages configurations, we have an interface and more than 5 structs implement this interface.

Using the Pomodoro Technique to Better Utilize Your Time

2022-02-03 00:48:05

For me, it’s easy to fall into a state of working all day, being busy all day but not knowing what I’m busy with, leading to anxiety the next day, not knowing what to say at the morning meeting, and only being able to do things that make me feel like I can talk. Why introduce the Pomodoro Technique: To solve this problem, I thought of many methods, such as writing a TODO list every day, but I still wasted a lot of time due to various interruptions, which made it impossible for me to complete the tasks in my original TODO list.

How to kill a process and its descendants in Unix?

2022-01-24 21:49:48

Recently, I was maintaining an open source project called air on the weekend. It is a hot loading code tool for Golang, which will monitor local file changes and then automatically reload. Problem encountered Recently, I encountered a particularly interesting problem, that is, when using the kill -9 pid command to kill the process, although it will kill its child process, its grandchild process will still survive. Background In short, our hot loading component will run commands, and then will monitor file changes, once the file changes, it will kill the previous process, then recompile the code, and then execute the running command.

Golang: Making Your Zero Values More Useful

2022-01-16 15:04:40

Make the zero value useful. –Go Proverbs Let’s start with the Golang blog: The zero value When memory is allocated to store a value, whether by declaration or by calling make or new, and no explicit initialization is provided, the memory is given a default initialization. Each element of this value is set to its type’s zero value: false for booleans, 0 for integers, 0.0 for floats, "" for strings, and nil for pointers, functions, interfaces, slices, channels, and maps.

Using Mock and Interface for Golang Unit Testing

2022-01-07 01:37:56

At work, I often find that many engineers' Golang unit tests are problematic, just simply calling code for output, and it will include various IO operations, making the unit test unable to run everywhere. Using Mock and Interface for Golang Unit Testing This article will introduce how to do unit testing correctly in Golang. What is unit testing? Characteristics of unit testing Unit testing is a very important part of quality assurance.

Some Details About Golang Slice

2021-12-21 01:37:56

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

2021-11-10 08:00:00

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

2021-10-14 01:37:56

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

2021-06-01 20:55:56

“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

2021-05-19 14:40:53

“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

2021-05-15 14:40:53

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

2021-04-26 14:40:53

“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?

2021-04-02 14:40:53

​ “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

2020-04-09 01:37:56

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

2020-04-06 16:33:34

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

2020-04-06 01:37:56

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?

2020-04-06 01:37:56

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

2020-04-05 01:37:56

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

2020-04-03 01:37:56

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

2020-04-03 01:37:56

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

2020-04-01 01:37:56

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

2020-01-15 17:51:36

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

2020-01-15 17:26:53

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

2020-01-15 16:33:34

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

2019-10-20 01:37:56

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.

How to distinguish between == and .equals() method in Java

2019-02-24 14:40:53

Generally speaking, equals() and "==" operator are used to compare whether two objects are equal, but there are many differences between the two: The main difference is that .equals() is a method, == is an operator. Use == to compare references, referring to whether they point to the same memory address. Use .equals() to compare the content of objects, comparing values. If .equals is not overridden, it will default to calling the nearest superclass to override this method.

2018 Year-end Summary

2018-12-30 14:40:53

It’s the end of the year, so I’m going to write a little summary of 2018. This year, there have been losses and gains. The loss was the failure of a relationship that didn’t work out, and the gain was a general improvement in my personal quality. Let’s not dwell on what’s lost. Let’s talk about the gains. The gains can be divided into three aspects: physical, technical, and financial.

Java Collection Expansion

2018-12-07 01:37:56

Collection Expansion ArrayList The default capacity of ArrayList is 10, so if you need to handle large amounts of data with ArrayList, you need to use the method of explicitly specifying the capacity. This can reduce unnecessary expansion operations. The main reason is that the expansion operation of ArrayList requires extra space, and it uses the Arrays.copyOf method for copying: 1 2 3 4 5 6 7 8 9 10