Skip to content

Instantly share code, notes, and snippets.

View caitong93's full-sized avatar
🎯
Focusing

Tong Cai caitong93

🎯
Focusing
View GitHub Profile
@caitong93
caitong93 / linux-perf.md
Created June 16, 2020 13:31
Linux Perf

SystemTap

在 linux 上用 systemtap 是一个比较好的选择。 SystemTap 的工作方式是将脚本转换成 C 语言, 再将 C 编译成内核模块。当内核模块加载时,会 将 hooks 挂载到内核中的 probe,当卸载时,会同时 卸载 hooks

安装

https://sourceware.org/systemtap/wiki

@caitong93
caitong93 / client.go
Created December 5, 2018 02:55
Custom transport for prometheus client golang
var defaultTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
@caitong93
caitong93 / encode.go
Created April 11, 2018 07:50
[golang] encode string slice as a byte slice
package main
import (
"fmt"
"bytes"
)
func encode(ss []string) string {
bs := [][]byte{}
for _, s := range ss {
@caitong93
caitong93 / basic.go
Created March 28, 2017 11:46 — forked from rgarcia/basic.go
golang basic auth transport
import (
"encoding/base64"
"fmt"
"net/http"
)
type BasicAuthTransport struct {
Username string
Password string
}