Skip to content

Instantly share code, notes, and snippets.

View tsonglew's full-sized avatar
:octocat:
I may be slow to respond.

Tsonglew tsonglew

:octocat:
I may be slow to respond.
View GitHub Profile
@tsonglew
tsonglew / docker-run-curve.sh
Last active July 25, 2023 16:32
docker-run-curve.sh
## a k8s operator tutorial: https://betterprogramming.pub/build-a-kubernetes-operator-in-10-minutes-11eec1492d30
# create kubernetes cluster in docker
kind create cluster --image=kindest/node:v1.21.2
# load curve2operator image to kind node
kind load docker-image curve2operator/curve-operator:v1.0.6
@tsonglew
tsonglew / BaseRetryableGrpcClient.java
Created July 9, 2022 10:44
some base retryable grpc client
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import java.io.IOException;
import java.io.InputStreamReader;
@tsonglew
tsonglew / zookeeper.yml
Created October 13, 2021 11:17
zookeeper with docker compose
# docker-compose -f ./zookeeper.yml up -d
version: '3'
services:
zookeeper:
image: zookeeper
ports:
- 2181:2181
restart: on-failure
@tsonglew
tsonglew / ipc.py
Created July 6, 2021 08:53
python ipc demo
import argparse
import json
import sys
import time
from multiprocessing.connection import Client, Listener
parser = argparse.ArgumentParser()
parser.add_argument("--type", type=str)
args = parser.parse_args()
@tsonglew
tsonglew / wav&pcm.py
Created June 1, 2021 06:11
pcm2wav and wav2pcm
import numpy as np
import wave
def wav2pcm(wavfile, pcmfile, data_type=np.int16):
f = open(wavfile, "rb")
f.seek(0)
f.read(44)
data = np.fromfile(f, dtype= data_type)
data.tofile(pcmfile)
$ env PYENV_DEBUG=1 pyenv install -v 3.6.4
+(/usr/local/bin/pyenv:23): enable -f /usr/local/bin/../libexec/pyenv-realpath.dylib realpath
+(/usr/local/bin/pyenv:30): '[' -z '' ']'
++(/usr/local/bin/pyenv:32): type -p greadlink readlink
++(/usr/local/bin/pyenv:32): head -1
+(/usr/local/bin/pyenv:32): READLINK=/usr/bin/readlink
+(/usr/local/bin/pyenv:33): '[' -n /usr/bin/readlink ']'
+(/usr/local/bin/pyenv:58): '[' -z /Users/kasheemlew/.pyenv ']'
+(/usr/local/bin/pyenv:61): PYENV_ROOT=/Users/kasheemlew/.pyenv
+(/usr/local/bin/pyenv:63): export PYENV_ROOT
package main
import (
"crypto/rand"
"errors"
"flag"
"fmt"
"io"
"net"
@tsonglew
tsonglew / docker-compose.yml
Created December 9, 2020 04:48
etcd docker compose file
version: '3'
services:
etcd1:
image: "quay.io/coreos/etcd:v3.4.7"
entrypoint: /usr/local/bin/etcd
command:
- '--name=etcd1'
- '--data-dir=/etcd_data'
- '--initial-advertise-peer-urls=http://etcd1:2380'
- '--listen-peer-urls=http://0.0.0.0:2380'
@tsonglew
tsonglew / purge_docker_logs.sh
Created October 23, 2020 02:32
remove docker containers log on remote machines
#!/bin/bash
echo "Will purge logs on ${IPS[@]}"
echo "Using SSHUSER: ${SSHUSER}, SSHKEY_PATH: ${SSHKEY_PATH}, ${SSHPORT}"
for ip in "${IPS[@]}";
do
echo "Running purge docker on ${ip}"
ssh -i ${SSHKEY_PATH} -o StrictHostKeyChecking=no ${SSHUSER}@${ip} -p${SSHPORT} << 'ENDSSH'
export DOCKER_PATH_PREFIX="/var/lib/docker/containers/"
for id in $(sudo ls ${DOCKER_PATH_PREFIX});
@tsonglew
tsonglew / Go.Dockerfile
Created October 15, 2020 06:14
Go 项目 Dockerfile 模板
FROM golang:alpine AS builder
# Set necessary environmet variables needed for our image
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
GOPROXY=https://goproxy.cn
# Move to working directory /build