Code Snippet
Disclaimer
The code snippet is provided for reference and learning purposes only. Users should use it at their own risk. I, along with the related developers, shall not be held responsible for any direct or indirect losses caused by the use of this code snippet, including but not limited to data loss, computer malfunctions, program errors, etc.
Embed Dependenices without any plugin in Gradle
The simplest way to embed dependencies in Gradle without any plugin
groovykotlin
Expand variables like {version} in resource file for Gradle
Transform resource file with variables like {version} to real value
groovykotlin
Equivalent JavaScript Class in Function
Classes are a template for creating objects, built on prototypes. A JavaScript class is a type of function. So you can convert a class to a function.
javascript
Use Collector to merge multiple JSON objects into one
Turn Stream<JsonObject> to single JsonObject
java
Read VarInt (variable integer) from DataStream
Variable-width integers, or varints, are at the core of the wire format. They allow encoding unsigned 64-bit integers using anywhere between one and ten bytes, with small values using fewer bytes. Each byte in the varint has a continuation bit that indicates if the byte that follows it is part of the varint.
java
Using CompletableFuture in Kotlinx.Coroutine
Await the result of CompletableFuture in Kotlinx.Coroutine
kotlin
Print stack trace of an exception in Kotlinx.Coroutine
By default, Kotlinx.Coroutine will not print stack trace of an exception. This snippet will print stack trace of an exception.
kotlin
Calculate MD5 of a file in Rust
An example of using md5 and file to calculate MD5 of a file in stream
rust
Generate random string or bytes in Rust
An example of using create::rand and Iterator to generate random string or bytes
rust