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 / multipass_completion.fish
Last active April 20, 2023 07:48
multipass shell completion for zsh & bash
complete -c multipass -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
complete -c multipass -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
complete -c multipass -n "__fish_use_subcommand" -f -a "delete" -d 'Delete instances'
complete -c multipass -n "__fish_use_subcommand" -f -a "exec" -d 'Run a command on an instance'
complete -c multipass -n "__fish_use_subcommand" -f -a "find" -d 'Display available images to create instances from'
complete -c multipass -n "__fish_use_subcommand" -f -a "get" -d 'Get a configuration setting'
complete -c multipass -n "__fish_use_subcommand" -f -a "help" -d 'Display help about a command'
complete -c multipass -n "__fish_use_subcommand" -f -a "info" -d 'Display information about instances'
complete -c multipass -n "__fish_use_subcommand" -f -a "launch" -d 'Create and start an Ubuntu instance'
complete -c multipass -n "__fish_use_subcommand" -f -a "list" -d 'List all available instances'
@linux-china
linux-china / RSocketBrokerClient.java
Created September 25, 2020 00:04
Alibaba RSocket Broker Client jbang test script
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.slf4j:slf4j-simple:1.7.30
//DEPS org.projectlombok:lombok:1.18.12
//DEPS com.alibaba.rsocket:alibaba-rsocket-core:1.0.0-SNAPSHOT
import com.alibaba.rsocket.encoding.JsonUtils;
import com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder;
import com.alibaba.rsocket.metadata.RSocketMimeType;
import com.alibaba.rsocket.upstream.UpstreamCluster;
import com.alibaba.rsocket.upstream.UpstreamManager;
@linux-china
linux-china / template.json
Created September 23, 2020 21:56
tgm template.json
{
"name": "spring-boot-java",
"repository": "https://github.com/tgm-templates/spring-boot-java",
"description": "Spring Boot App with Java",
"variables": [
{
"name": "groupId",
"description": "Maven groupId"
},
{
@linux-china
linux-china / Application.java
Last active September 25, 2020 03:14
Simple Spring Boot App
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.springframework.boot:spring-boot-starter:2.3.4.RELEASE
package demo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@linux-china
linux-china / cloudflare_kv_bindings.js
Last active August 26, 2020 20:49
CloudFlare KV JavaScript API with jsdoc support
/**
* cloudflare KV Namespace
*/
class KVNameSpace {
/**
* Write key-value pairs
* @param {string} key - key
* @param {(string|ArrayBuffer|ReadableStream)} value - value
* @param {{[expiration]: number, [expirationTtl]: number, [metadata]: {}}} [options] - putting options
* @return {Promise}
@linux-china
linux-china / wait.ts
Created May 25, 2020 17:56
wait for TypeScript
function wait(ms: number):Promise<undefined> {
return new Promise(resolve => setTimeout(resolve, ms));
}
await wait(1000);
@linux-china
linux-china / MemoryAppender.java
Last active July 28, 2021 20:08
Memory Appender for logback
/*
*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* 1. Definitions.
*
@linux-china
linux-china / welcome.ts
Created May 12, 2020 23:03
Welcome.ts for Deno
console.log("Welcome to Deno!")
@linux-china
linux-china / WebSocketConfig.java
Created January 17, 2020 19:05
WebSocketConfig for WebFlux
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.HandlerMapping;
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
import org.springframework.web.reactive.socket.WebSocketHandler;
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;
import java.util.HashMap;
import java.util.Map;
@linux-china
linux-china / Makefile
Created October 12, 2019 23:24
Makefile for Emscripten
WASM_MODULE = cpp17
CC = em++
CXXFLAGS = --bind -O3 -x c++ -std=c++17 -s ALLOW_MEMORY_GROWTH=1 -s 'MALLOC="emmalloc"'
.PHONY : all clean
all: $(WASM_MODULE).wasm ## Build all Wasm
$(WASM_MODULE).wasm: $(WASM_MODULE).cpp ## Compile cpp17.wasm
$(CC) $(CXXFLAGS) -o $(WASM_MODULE).js $(WASM_MODULE).cpp