Skip to content

Instantly share code, notes, and snippets.


LI Zhennan nanmu42

View GitHub Profile
nanmu42 / Flink: throttle messages to walkaround deadlock under heavy iteration feedback
Last active Oct 11, 2021
Flink: throttle messages to walkaround deadlock under heavy iteration feedback load
View Flink: throttle messages to walkaround deadlock under heavy iteration feedback
xykong /
Last active Dec 13, 2022
Export Kubernetes cluster resource to yaml.
#!/usr/bin/env bash
readonly SCRIPT=$(basename "$0")
readonly VERSION='1.0.0'
readonly AUTHOR=''
readonly SOURCE=''
# For script running robust
set -o nounset # to exit when your script tries to use undeclared variables
set -o errexit # to make your script exit when a command fails
nanmu42 / fileserver.go
Created Mar 6, 2021
Golang Quick Static File Server
View fileserver.go
package main
import (
var (
madkoding /
Last active Nov 26, 2022
Install Docker-CE script for Deepin Linux
# Shell script to add docker-ce to Deepin Linux repositories
# Remove old docker
sudo apt-get remove -y docker docker-engine containerd runc
# Install dependencies
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
nanmu42 / openinbrowser.go
Created May 20, 2019
Golang: Open URL in Browser
View openinbrowser.go
func openBrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
nanmu42 / Dockerfile
Last active Jan 29, 2021
Minimal-sized Golang Docker Image
View Dockerfile
FROM golang:1-alpine as golang
RUN apk --no-cache add git zip tzdata ca-certificates
# avoid go path, use go mod
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-s -w -extldflags "-static"" ./cmd/appnamehere
WORKDIR /usr/share/zoneinfo
# -0 means no compression. Needed because go's
# tz loader doesn't handle compressed data.
RUN zip -r -0 / .
nanmu42 / pkcs7padding.go
Last active Dec 20, 2022
Golang PKCS7 Padding/Unpadding
View pkcs7padding.go
// pkcs7strip remove pkcs7 padding
func pkcs7strip(data []byte, blockSize int) ([]byte, error) {
length := len(data)
if length == 0 {
return nil, errors.New("pkcs7: Data is empty")
if length%blockSize != 0 {
return nil, errors.New("pkcs7: Data is not block-aligned")
padLen := int(data[length-1])
nanmu42 /
Last active Apr 5, 2022
Update tmux to latest version
#!/usr/bin/env bash
set -e
# dependecies
apt update
apt install -y git automake build-essential pkg-config libevent-dev libncurses5-dev byacc
# where our temp file locates
rm -rf /tmp/tmux
den-crane / gist:6eff375752a236a456e1b3dc2ca7db62
Last active Dec 11, 2022
Clickhouse example AggregatingMergeTree, (max, min, avg ) State / Merge
View gist:6eff375752a236a456e1b3dc2ca7db62
CREATE TABLE requests (
request_date Date,
request_time DateTime,
response_time Int,
request_uri String)
ENGINE = MergeTree(request_date, (request_time, request_uri), 8192);