Skip to content

Instantly share code, notes, and snippets.

View zhangguanzhang's full-sized avatar
🎯
I may be slow to respond.

zhangguanzhang zhangguanzhang

🎯
I may be slow to respond.
View GitHub Profile
@zhangguanzhang
zhangguanzhang / gist:791c484f6137f8deaed473a3857219ee
Last active May 17, 2020 11:38
golang Remove the specified repeated string
package main
import (
"fmt"
)
func main() {
s := `aaabccaad`
u := "a"
fmt.Printf("%s %s ===> %s \n", s, u, uniq(s, u))
@zhangguanzhang
zhangguanzhang / rbac_casbin.go
Last active July 14, 2020 08:35
casbin group demo
package main
import (
"fmt"
"log"
"github.com/casbin/casbin/v2"
gormadapter "github.com/casbin/gorm-adapter/v2"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
scripts/build/.variables 文件去掉-w
scripts/build/binary 增加 -gcflags="all=-trimpath=$PWD -N -l"
构建 make -f docker.Makefile binary
@zhangguanzhang
zhangguanzhang / flannel-compile
Last active July 22, 2021 04:13
flannel-compile
```
wget https://github.com/multiarch/qemu-user-static/releases/download/v3.0.0/qemu-x86_64-static.tar.gz
docker run --privileged -ti --rm --name flannel --net host -e GOARCH=amd64 \
--cap-add=NET_ADMIN --cap-add=SYS_ADMIN \
-u $( id -u):$( id -g) \
-v $PWD/dist/qemu-amd64-static:/usr/bin/qemu-amd64-static \
-v $PWD:/go/src/github.com/coreos/flannel:ro \
-v $PWD/dist:/go/src/github.com/coreos/flannel/dist \
-v /run:/run \
--workdir=/go/src/github.com/coreos/flannel \
import json,base64
import requests, re
from collections import Counter
class DockerRegistryClient(object):
def __init__(self, registry="http://reg.xxx.xxx:5000", auth='xxx:xxxxx', api_timeout=None):
self.registry = registry
self.auth = auth
self.method_kwargs = {}
self.scheme = 'application/vnd.docker.distribution.manifest.v2+json'
@zhangguanzhang
zhangguanzhang / github-fork-pr.md
Created March 2, 2022 02:54
git 本地 pr 和同步

fork 后本地仓库添加,这里例如 skopeo

  1. 先添加上游
git remote add upstream https://github.com/containers/skopeo.git
  1. 拉取上游
@zhangguanzhang
zhangguanzhang / podman.txt
Last active April 25, 2022 01:54
podman compile on CentOS8
dnf install -y gcc make wget vim git libseccomp-devel systemd-libs systemd-devel jq patch tar
go get github.com/go-delve/delve/cmd/dlv
wget -O /usr/share/containers/seccomp.json https://raw.githubusercontent.com/containers/common/main/pkg/seccomp/seccomp.json
make BUILDTAGS="containers_image_openpgp systemd exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper selinux seccomp " podman
podman system service --time 0 tcp:127.0.0.1:8081
# 取无法拉取镜像名
kubectl get po `kubectl get pod -o wide | grep Image | awk '{print $1}'` -o yaml | grep -Po 'image: \K\S+' | sort -u
# docker save -o images.tar.gz \
imgList=""
while read img;do
if docker inspect $img &>/dev/null;then
imgList+="$imgList $img"
fi
#!/bin/bash
# dnsConfig
kubectl -n kafka patch deployments kafka-0 -p '{"spec":{"template":{"spec":{"dnsConfig":{"options":[{"name":"single-request-reopen"}]}}}}}'
# dnsOptions
kubectl patch deploy $name \
-p '{"spec":{"template":{"spec":{"dnsConfig":{"options":[{"name":"single-request-reopen"}]}}}}}'
function t(){
@zhangguanzhang
zhangguanzhang / golang-debouncer.go
Last active July 6, 2022 11:59
golang 定时 防抖
// You can edit this code!
// Click here and start typing.
package main
import (
"fmt"
"sync"
"time"
)