事件驱动服务器, event-driven server

事件驱动服务器, event-driven server https://gist.github.com/jcouyang/9914091 OPPC模型瓶颈 传统服务器模型如Apache为每一个请求生成一个子进程。当用户连接到服务器的一个子进程就产生,并处理连

TPS、QPS、RPS

TPS、QPS、RPS PPS PPS (Packet Per Second) PCT (percentile) PCT99: 99%的响应时间 “90th pct/95th pct/99th pct”分别表示测试实例按响应时间从小到大排序后,第90/95/99个测

linux enca 编码并转换

linux enca 编码并转换 enca -list languages enca -L zh_CN file 检查文件的编码 enca -L zh_CN -x UTF-8 file 将文件编码转换为"UTF-8″编码 enca -L zh_CN -x UTF-8 < file1 > file2 如果不想覆盖原文件可以这

Mahonia

Mahonia Mahonia—a character-set conversion library for Go Mahonia is a character-set conversion library implemented in Go. All data is compiled into the executable; it doesn’t need any external data files. Mahonia is now deprecated. I recommend using the standard package at golang.org/x/text/encoding, possibly along with golang.org/x/net/charset https://code.google.com/archive/p/mahonia/

golang 各种数据类型转换

golang 各种数据类型转换 Conversions are expressions of the form T(x) where T is a type and x is an expression that can be converted to type T. string > duration 1 2 d, e := time.ParseDuration("-1h") d, e := time.ParseDuration("1000ms") array > slice 1 2 arr := [3]int{1,2,3} sli := arr[:] hex > int, big.Int 1 2 3 4 5 6 // int n,

go file

go file 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 if srcFile, err = os.Open(localPath); err != nil { logger.Errorf("failed to read src file: %v", err) return } defer srcFile.Close() fileInfo, err := srcFile.Stat() fileSize := fileInfo.Size() // file size os.PathSeparator file, _ := os.Getwd() log.Println("current path:", file) file, _ = exec.LookPath(os.Args[0]) log.Println("exec path:",

openssl basic

openssl basic 查看私钥长度 1 openssl rsa -in id_rsa.pem -text -noout get cert 1 openssl s_client -connect site.com:636 </dev/null 2>/dev/null | openssl x509 -outform PEM > site.pem import cert into ca certs 1 sudo keytool -importcert -noprompt -alias site-`date "+%Y%m%d%H%M%S"` -file ./site.pem -keystore /usr/java/latest/lib/security/cacerts -storepass changeit 查看证书信息 pem 1 2 openssl x509 -noout -text -in ca.crt openssl x509 -noout -text -in

emacs elpa

emacs elpa https://elpa.emacs-china.org/index-en.html 1 2 3 4 5 emacs ~/.emacs (setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/") ("melpa" . "http://elpa.emacs-china.org/melpa/"))) M-x list-packages Type M-x list-packages to open the package list. Press ‘i’ to mark for installation, ‘u’ to unmark, and ‘x’ to perform the installation. Press ‘RET’ to read more about installing and using each package. https://www.emacswiki.org/emacs/InstallingPackages

nginx basic, command

nginx basic, command 1 2 3 4 5 6 7 8 9 # Do not run, just test the configuration file. sudo nginx -t nginx -s signal # stop — fast shutdown # quit — graceful shutdown # reload — reloading the configuration file # reopen — reopening the log files almalinux install nginx 1 2 3 sudo dnf update -y sudo dnf install nginx -y sudo systemctl enable --now

linux cut

linux cut 1 2 3 4 cut -d ',' -f 3 # 截取前24个字符 cut -c-24 http://www.cnblogs.com/dong008259/archive/2011/12/09/2282679.html cut是一个选取命令,就是将一段数据经过分析,取出我们想要的。一般来说,选取信息通常是针对&q

Guava Multimap

Guava Multimap 在日常的开发工作中,我们有的时候需要构造像Map<K, List>或者Map<K, Set>这样比较复杂的集合类型的

dnscrypt

dnscrypt Server 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

swap

swap archlinux 禁用 swap 禁用 zram swap 1 2 3 systemctl list-units --type=swap sudo systemctl mask dev-zram0.swap reboot 查看 swap 使用情况 1 2 3 4 5 6 # 没有输出的话就是没有启用 swap swapon --show swapon free -m cat /proc/swaps vmstat 1 5 1 2 3 4 NAME TYPE SIZE USED PRIO /dev/vda2 partition 1.9G 1.5G

go regex, 正则

go regex, 正则 1 2 3 4 5 6 nodes := []string{"foo.bar-000.x", "foo.t0.bar","foo.bar"} reg := regexp.MustCompile(`foo\.(.[^\.]*)\.{0,1}.*`) for _, v := range nodes { result := reg.FindSubmatch([]byte(v)) fmt.Println("output: ", string(result[1])) } [^a-zA-Z ]+, 匹配所有不是小写大写字母和空格的字符 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 . 匹配任