Skip to content

Instantly share code, notes, and snippets.

View LinkTsang's full-sized avatar
🎯
action speaks louder than words

LinkTsang LinkTsang

🎯
action speaks louder than words
  • Tencent
  • Shenzhen
View GitHub Profile
@LinkTsang
LinkTsang / nginx-tuning.md
Created July 14, 2024 13:26 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@LinkTsang
LinkTsang / proc_net_tcp_decode
Created August 14, 2023 15:53 — forked from jkstill/proc_net_tcp_decode
decode entries in /proc/net/tcp
Decoding the data in /proc/net/tcp:
Linux 5.x /proc/net/tcp
Linux 6.x /proc/PID/net/tcp
Given a socket:
$ ls -l /proc/24784/fd/11
lrwx------ 1 jkstill dba 64 Dec 4 16:22 /proc/24784/fd/11 -> socket:[15907701]
@LinkTsang
LinkTsang / sigterm_context.go
Created February 24, 2023 08:02 — forked from matejb/sigterm_context.go
Golang context with cancellation on signal receive
func contextWithSigterm(ctx context.Context) context.Context {
ctxWithCancel, cancel := context.WithCancel(ctx)
go func() {
defer cancel()
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)
select {
case <-signalCh:
@LinkTsang
LinkTsang / my gists - autohotkey.md
Created February 20, 2021 07:31 — forked from db93n2/my gists - autohotkey.md
my autohotkey gists
@LinkTsang
LinkTsang / gist:dabad49910c2494a39860c393df3b03f
Created August 12, 2016 16:08 — forked from getify/gist:3667624
escape all double-quote chars in a string
// NOTE: only escapes a " if it's not already escaped
function escapeDoubleQuotes(str) {
return str.replace(/\\([\s\S])|(")/g,"\\$1$2"); // thanks @slevithan!
}
escapeDoubleQuotes("ab"); // ab => ab
escapeDoubleQuotes("a\"b"); // a"b => a\"b
escapeDoubleQuotes("a\\\"b"); // a\"b => a\"b
escapeDoubleQuotes("a\\\\\"b"); // a\\"b => a\\\"b
escapeDoubleQuotes("a\\\\\\\"b"); // a\\\"b => a\\\"b
@LinkTsang
LinkTsang / git_toturial
Last active December 30, 2015 15:56 — forked from guweigang/git_toturial
git命令大全&FAQ
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "[email protected]" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://[email protected]/VT.git # clone远程仓库
@LinkTsang
LinkTsang / 936Code4NumPad.cpp
Last active August 29, 2015 14:04
Get 936 code for NumPad (windows only)
unsigned short GetMagicNumber(wchar_t WideChar)
{
wchar_t wc[2];
wc[0] = WideChar;
wc[1] = NULL;
union {
char c[2];
short s;
} buffer , output;