Skip to content

Instantly share code, notes, and snippets.

View caryyu's full-sized avatar
😀
Welcome to AMA!

: ask me anything :) caryyu

😀
Welcome to AMA!
View GitHub Profile
@caryyu
caryyu / example.md
Last active March 5, 2020 02:39
把某个目录下的所有文件及内容拷贝至 Java 的 Properties 文件格式中

比如某个目录 /secret 有如下文件:

📦/secret
┣ 📜AGE - 20
┗ 📜NAME - 李三


path=$1
@caryyu
caryyu / usage.md
Last active April 10, 2020 03:54
kafka-cli in kubernetes

This usage is based on the project of https://github.com/birdayz/kaf

Description

  • A Kafka cluster in your Kubernetes Cluster
  • If you're in China, Please make sure you have the proxy setup in your Kubernetes cluster as what I did

Steps

@caryyu
caryyu / goroutine.md
Created May 22, 2020 03:41
Golang 一些示例
@caryyu
caryyu / we-org-global.sh
Created May 22, 2020 06:02
读取 Vault 密钥到环境变量文件供本地 Docker 调试使用
export VAULT_ADDR=https://xxx
export VAULT_TOKEN=xxx
export VAULT_PATH="secret/projects/xxxxxx/services/org-global/defaults"
rm -f ~/.we/org-global
OUTPUT=`vault list -format=json $VAULT_PATH | jq -c '.[]' | grep -v "env-file" | sed 's/"//g' | awk '{ print "vault kv get -format=json '$VAULT_PATH'/"$1" | jq .data.value | sed '"'"'s/\"//g'"'"' | awk '"'"'{print \""$1"=\"\$1}'"'"' >> ~/.we/org-global"}'`
eval $OUTPUT
@caryyu
caryyu / Cron 表达式 & 日期.md
Last active June 17, 2020 12:55
Shell tips and tricks - 中文

Cron 表达式转换为日期

主要使用 https://github.com/caryyu/cronexpr 命令工具

  • MacOS - cronexpr -n 1 "30 16 * * *" | {read t; date -r "$t"}
  • Linux - cronexpr -n 1 "30 16 * * *" | {read t; date --date=@"$t"}

Date 日期调整(加一天,加一小时,等)

  • MacOS - date -v+1d/date -v-1d/date -v+1H
@caryyu
caryyu / Username Credential.md
Created June 18, 2020 09:54
Vault tips & tricks
vault write auth/userpass/users/caryyu password="xxxxxxxxxxxx" 

vault auth list -detailed

vault policy list

vault write identity/entity name="caryyu" policies="policy-1,policy-2"

vault write identity/entity-alias name="caryyu" mount_accessor=auth_userpass_7cde8625
@caryyu
caryyu / .vimrc
Last active December 29, 2020 09:15
个人 Vim 配置
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } | Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'preservim/nerdcommenter'
Plug 'PhilRunninger/nerdtree-visual-selection'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'vim-airline/vim-airline'
Plug 'morhetz/gruvbox'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-fugitive'
@caryyu
caryyu / Docker 中文语言包
Created September 23, 2020 07:25
Ubuntu 相关记录
FROM scottyhardy/docker-wine:latest
RUN apt-get update && apt-get -y install \
locales \
language-pack-zh-hans \
fonts-droid-fallback \
ttf-wqy-zenhei \
ttf-wqy-microhei \
fonts-arphic-ukai \
fonts-arphic-uming
@caryyu
caryyu / outline.md
Last active November 8, 2020 04:18
Bit Torrent Learning Routes
  • Basic Network
    • TCP/IP
    • UDP vs uTP
  • P2P Network
    • STUN Server - NAT Traversal
    • Turn Server
    • UPnP Protocol
    • WebRTC
  • Bit Torrent BEP 0003 - Foundation
  • Bit Torrent BEP 0005 - DHT
@caryyu
caryyu / readme.md
Last active January 29, 2021 10:13
Docker Desktop Port-Forwarding
  • Docker

docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 0.0.0.0:1234:1234 bobrik/socat TCP-LISTEN:1234,fork UNIX-CONNECT:/var/run/docker.sock

  • Kubernetes

docker run -d -p 0.0.0.0:6444:6443 bobrik/socat TCP-LISTEN:6443,fork TCP:docker-desktop:6443

  • Nginx Stream Proxy