Skip to content

Instantly share code, notes, and snippets.

View suncle1993's full-sized avatar
🎯
Focusing

Suncle Chen suncle1993

🎯
Focusing
View GitHub Profile
@suncle1993
suncle1993 / docker-compose.yml
Created January 5, 2023 05:55
docker-compose for local env
services:
db:
image: 'mysql:5.7'
container_name: mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
ports:
- '3306:3306'
volumes:
- './mysql/data:/var/lib/mysql'
@suncle1993
suncle1993 / test_string.go
Created March 2, 2022 08:03
测试string的并发写panic
package main
import (
"fmt"
"time"
)
var (
testString string
)
package main
import (
"fmt"
"strings"
"github.com/spf13/cobra"
)
func main() {
@suncle1993
suncle1993 / golangci-lint-fix.py
Last active March 2, 2022 08:07
批量修复golang ci
import re
import subprocess
# 不自动处理的规则
ex = ("SA4006", "structcheck") # 不自动处理的规则
# 忽略error返回白名单,白名单才处理
errwl = {
"ymetrics": "_ = ",
"yalert": "_ = ",
@suncle1993
suncle1993 / int64set.go
Created March 2, 2022 07:15
golang int64类型的集合
package main
import (
"fmt"
"sync"
)
// Int64Set int64类型的集合
type Int64Set struct {
sync.RWMutex
[alias]
aa = add .
ag = reset HEAD^ # again
b = branch
bd = branch -D
br = branch
ca = commit --all
cb = checkout -b
changed = update-index --no-assume-unchanged # revert op of `git unchanged`
ci = commit
@suncle1993
suncle1993 / .golangci.yml
Created October 15, 2021 03:38
golang ci config example
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
@suncle1993
suncle1993 / forbid-master.sh
Created October 23, 2020 08:10
一键配置在master上禁止commit和push操作
#!/usr/bin/env bash
set -e
MIN_GIT_VERSION="2.9"
HOOKS_DIR="$HOME/.git-hooks"
function checkGitVersion() {
# check if git is installed
if ! command -v git &>/dev/null; then
echo "git could not be found"
@suncle1993
suncle1993 / pre-push
Created October 23, 2020 08:09
git 禁止在master上push
#!/bin/bash
protected_branch='master'
remote_branch_prefix="refs/heads/"
protected_remote_branch=$remote_branch_prefix$protected_branch
while read local_ref local_sha remote_ref remote_sha
do
if [ "$protected_remote_branch" == "$remote_ref" ]; then
echo " git hooks: Do not commit to $protected_branch branch"
@suncle1993
suncle1993 / pre-commit
Created October 23, 2020 08:08
git禁止在master上commit
#!/bin/bash
protected_branch='master'
current_branch=$(git rev-parse --symbolic --abbrev-ref HEAD)
if [ "$protected_branch" == "$current_branch" ]; then
echo "git hooks: Do not commit to $current_branch branch"
exit 1
fi