Finding the Kth Largest Number in a Large Amount of Unordered Data

Find the Kth largest value in an unordered long array of millions. The requirement is, of course, that the faster you find it, the better. top K questions As soon as the problem is described, many people will associate it with the top K problem, which is discussed extensively in both the algorithm and engineering fields, and it is easy to encounter similar problems in actual projects, so I also took the opportunity to summarize it into an article.

Golang Cron V3 Timed Tasks

Recently I need to use the timed task function in golang, I use a cron library, the current version is v3, the Internet is quite a lot of v2 tutorials, record the use of the method. In the old version of the library, the default cron expression is not the standard format, the first bit is the definition of the second level. Now the v3 version can use the standard cron expression directly, mainly see the godoc documentation section

Web Components Getting Started Example Tutorial

Components are the direction of front-end development, and the popular React and Vue are both component frameworks. Google has been pushing for native components for browsers due to its mastery of the Chrome browser, namely the Web Components API. Compared to third-party frameworks, native components are simple and straightforward, intuitive, don’t have to load any external modules, and have a small amount of code. It is still evolving, but is

Introduction to Spring Cloud Bus

The Spring Cloud Bus positions itself as a messaging bus within the Spring Cloud system, using a message broker to connect all nodes of a distributed system. The official Reference documentation for the Bus is relatively simple, so simple that it doesn’t even have a diagram. This is the most 2.1.0 version of the Spring Cloud Bus code structure (less code) Bus Example Demonstration Before we analyze the implementation of the Bus, let’s look at two simple examples of using Spring Cloud Bus.

Build Streaming Applications Based on Flink Sql

Since the release of Flink 1.10.0, many exciting new features have been released. In particular, the Flink SQL module is evolving very fast, so this article is dedicated to exploring how to build a fast streaming application using Flink SQL from a practical point of view. This article will use Flink SQL to build a real-time analytics application for e-commerce user behavior based on Kafka, MySQL, Elasticsearch, Kibana. All the

Pitfalls of os.popen function and Pipe in Python

I recently wrote a few simple scripts in Python to process some data, and since it’s just a simple function, I just use print to print the log. The task occasionally throws some exceptions when running. Because I have print logs in different places, the place where the error is reported is not quite the same every time, which leads to very strange results; sometimes this piece of code is

Tutorials for using resty

resty is an HTTP client library for the Go language. resty is powerful and feature-rich. It supports almost all HTTP methods (GET/POST/PUT/DELETE/OPTION/HEAD/PATCH, etc.) and provides an easy-to-use API. Quick Use The code in this article uses Go Modules. Create the directory and initialize. 1 2 $ mkdir resty && cd resty $ go mod init github.com/darjun/go-daily-lib/resty Install the resty library. 1 $ go get -u github.com/go-resty/resty/v2 Here we get the information on the first page of Baidu.

Golang - Number of Threads in the Running Program

Programmers who are a little bit introduced to the Go language know that the GOMAXPROCS variable can limit the maximum number of threads that can concurrently run the user-state Go code operating system, and you can even change the size of the maximum number of threads at program runtime by calling the function func GOMAXPROCS(n int) int, but when you read the documentation further, or more When you read the documentation further, or go deeper into Go language development, you will find that the actual number of threads is larger than the number you set, sometimes much larger than the value you set, and even more tragically, even when your concurrent tasks are backed up to no more than a few, the number of threads has not come down, wasting memory space and CPU scheduling for nothing.

Deeper Into the Go Module - the Pesky V2

The Go module not only follows the semantic version specification 2.0.0, but also goes a step further by giving deeper meaning to the major in the semantic version. X.X: For the case where the major version number (major) is 0, it implies that your current API is still in an unstable state, and the new minor version may not be backward compatible. X.X: the current API is in a stable state, the increase of minor only means the increase of new feature, the API is still backward compatible X.

Some Tips for Using Json in Go

This article summarizes the problems and solutions I usually encounter in my projects regarding the interconversion between go language JSON data and structs. Basic Serialization First let’s look at the basic usage of json.Marshal() (serialization) and json.Unmarshal (deserialization) in the Go language. 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 type Person struct { Name string Age int64 Weight float64 } func main() { p1 := Person{ Name: "Qimi", Age: 18, Weight: 71.

Write a Springboot Shell Script

As a Java developer, you will use SpringBoot to develop Web applications in many scenarios, and the current microservices mainstream SpringCloud components are also built based on SpringBoot. The SpringBoot application is deployed to the server and requires an O&M script. In this article, we try to summarize the shell scripts used in production before and write a reusable SpringBoot application operation and maintenance script based on our experience, thus

Learn React hooks easily: useEffect() as an example

Recently I’ve come to realize that React hooks are very useful and I’ve reacquainted myself with the React framework. Here’s how to understand hooks properly, and to analyze useEffect(), one of the most important hooks, in depth. The content will be as common as possible, so that friends who are not familiar with React can also read. React’s two sets of APIs Previously, there was only one set of React API, but now there are two: the class API and the function-based hooks API.

The Underlying Implementation of Annotations in the Jdk

Using Java for several years, annotations are a common type, especially in some frameworks will be a lot of annotations to do component identification, configuration or strategy. But has not been deeply to explore the JDK annotations in the end what is the bottom is how to achieve? So refer to some information, to do a slightly more detailed analysis. JDK annotations description Refer to JLS-9.6 inside JavaSE-8 for a description of the annotations as follows.

Installing SonarQube in Centos7

SonarQube is a code quality management open platform that integrates thousands of automatic static code analysis rules designed to improve the quality and security of developers’ code, enabling developers to write cleaner, safer code. Three main and larger features are provided. Code reliability support: catch and alert errors in code in advance, thus avoiding undefined behaviors affecting end users. Application Security Support: Fixes vulnerabilities that could compromise applications and learns AppSec through security hotspots (simply understood to mean that it will learn and identify new vulnerabilities).

About Service Worker and Pwa

Service Worker is a script that the browser runs in the background independent of the web page. A PWA (Progressive Web App) is a web application, but similar in look and feel to a native app. Before we talk about Service Worker and PWA, let’s take a brief look at what Web Worker is. Web Worker What is Web Worker? The Web Worker is a built-in thread in the browser

Fixing the Problem of Lost Code After Git Revert and Merge Again

Our project uses GitLab for code management, and when I upgraded the system to SpringBoot 2.0, the branch was merged to the Master branch. During the actual deployment, I found that a child dependency of a two-party package that I depended on had not been upgraded, causing a service to fail to drop through. Since it took time to fix the bipartite package, we decided to Revert the Master branch in order not to affect the subsequent release of other features.

How to Perfectly Copy Base64 Images to the System Pasteboard

I recently came across a small knowledge point during development. Here is a Base64 encoded image that I want to copy into the system pasteboard, how can I solve this? For example, here is a picture. I can convert to Base64 encoding by using the Base64 conversion tool at https://www.base64-image.de/ and the result is as follows. An image is something like data:image/png;base64,ivBor2… Such encoding. Q: Now I have an image in this format, how can I copy it into the system pasteboard?

Spring Event Publishing and Listening Mechanism

Spring provides the ApplicationContext event mechanism to publish and listen to events, which is a very useful feature. Spring has some built-in events and listeners, such as before the Spring container starts, after the Spring container starts, after the application fails to start, etc. The listeners on these events will respond accordingly. Of course, we can also customize our listeners to listen to Spring’s original events. Or we can customize

The Popular Java Json Library Jackson

Jackson is a JSON (return) serialization tool in the Java ecosystem, which is efficient, powerful, and secure (without as many security vulnerabilities as Fastjson). It is also widely used, with Spring Boot/Cloud, Akka, Spark and many other frameworks using it as the default JSON processing tool. Dependency To use Jackson, you need to add the following dependencies to your project (note: you don’t need to add them manually when using

Running Go Generic Code Locally

Last year Ian Lance Taylor and Robert Griesemer released a new draft of Go generics (The Next Step for Generics), and the response from Gopher at home and abroad was overwhelming, with everyone interpreting the draft and this article, and feeling that this version of Go generic design is basically close to Go’s generic goals, and in short, much better than the previous one. Ian also provided an online compilation tool, go2go, to get a taste of Go generic programming.