Skip to content

Instantly share code, notes, and snippets.

View linux-china's full-sized avatar

Libing Chen linux-china

View GitHub Profile
@linux-china
linux-china / object-relations.puml
Created August 5, 2019 17:30
Composite, Aggregate and Relation
@startuml
class Building {
- apartments
}
Building --* Apartment: contains >
class Car {
- wheels
}
https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d
@linux-china
linux-china / kotlin2native.sh
Created August 16, 2018 22:58
Kotlin script to native image
kotlinc -include-runtime hello.kt -d hello.jar
native-image -jar hello.jar
@linux-china
linux-china / FoodOrder.kt
Created August 14, 2018 17:09
Kotlin Builder Pattern Demo
package org.mvnsearch.builder
class FoodOrder private constructor(builder: FoodOrder.Builder) {
val bread: String?
val meat: String?
init {
this.bread = builder.bread
this.meat = builder.meat
@linux-china
linux-china / envoy-schema.json
Last active June 1, 2022 23:13
Envoy configuration json schema for Json and Yaml
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Envoy Proxy config schema",
"description": "JSON Schema for Envoy Proxy config",
"type": "object",
"properties": {
"admin": {
"type": "object",
"description": "Configuration for the local administration HTTP server",
"properties": {
@linux-china
linux-china / FilenameComparator.java
Created February 26, 2018 05:58
Order Versioned File Names Semantically in Java
public final class FilenameComparator implements Comparator<String> {
private static final Pattern NUMBERS =
Pattern.compile("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
private static final Pattern FILE_ENDING =
Pattern.compile("(?<=.*)(?=\\..*)");
@Override
public final int compare(String o1, String o2) {
if (o1 == null || o2 == null)
@linux-china
linux-china / TcpIpPropertySourceConfig.java
Created January 6, 2018 10:54
Spring Boot to set server.address
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Arrays;
import java.util.Collections;
@linux-china
linux-china / auto_load_bashrc.sh
Created August 30, 2017 06:36
Use .bashrc.d directory instead of bloated .bashrc
for file in ~/.bashrc.d/*.bashrc;
do
source “$file”
done
@linux-china
linux-china / bitmap_redis.java
Last active July 23, 2017 02:15
bitmap with Redis in Java
@Test
public void testBitGet() {
//redisTemplate.opsForValue().setBit("user2.flags",0,true);
BitSet value = redisTemplate.execute(new RedisCallback<BitSet>() {
public BitSet doInRedis(RedisConnection redis) throws DataAccessException {
return fromByteArrayReverse(redis.get("user.1.flags".getBytes()));
}
});
System.out.println(value);
}
@linux-china
linux-china / kotlin-maven.xml
Last active July 24, 2017 07:58
Kotlin maven plugin in pom.xml
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>