Skip to content

Instantly share code, notes, and snippets.

@nevill
nevill / bench-metal.log
Created February 27, 2020 08:02
Benchmark results of RangeQuery on VM vs Dedicated
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6634700849 ns/op 1875759 B/op 9705 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6637383642 ns/op 1875784 B/op 9705 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6637649343 ns/op 1875805 B/op 9706 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6637758314 ns/op 1875820 B/op 9706 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6637945397 ns/op 1870044 B/op 9705 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6638105296 ns/op 1870020 B/op 9705 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_0.3),steps=1000-48 10 6638157506 ns/op 1875834 B/op 9706 allocs/op
BenchmarkRangeQuery/expr=holt_winters(a_hundred[1d],_0.3,_
@nevill
nevill / memory.md
Last active February 15, 2020 16:36
Go Memory Allocation

Allocator

Data structures

  • fixalloc
    • a free-list allocator for fixed-size off-heap objects, used to manage storage used by the allocator.
  • mheap
    • the malloc heap, managed at page (8192-byte) granularity.
  • mspan
    • a run of pages managed by the mheap.
  • mcentral
@nevill
nevill / tips.sh
Last active November 6, 2021 11:31
Useful shell commands
# 在执行程序10秒后终止
ping 192.168.1.1 & read -t 10 || kill $!
ping 192.168.1.1 & sleep 10s; kill $!
# 计算 pi 2000 位
perl -Mbignum=bpi -wle "print bpi(2000)"
package main
import (
"log"
"math/rand"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
@nevill
nevill / ingress-svc.yml
Last active October 25, 2018 08:14
k8s monitoring
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: NodePort
@nevill
nevill / install.sh
Last active January 5, 2023 00:49
Script to install Kubernetes for mainland China
# This script is for Ubuntu 16.04 (xenial)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/docker.list
deb https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ xenial stable
EOF
# from https://yq.aliyun.com/articles/66474
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
@nevill
nevill / pre-commit.py
Last active December 6, 2017 09:39
hooks to test if a file contains BOM, compatible with python 2 and 3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import os.path
import sys
import subprocess
UTF8_BOM = b'\xef\xbb\xbf'
PS1='\[\e[1;34m\]\u@\h \W \[\e[0;32m\]\$\[\e[0;39m\] '
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
PS1='\[\e[1;34m\]\u@\h \W\[\e[0;36m\]$(__git_ps1 "(%s)") \[\e[0;32m\]\$\[\e[0;39m\] '
# PS1='\u@\h \W$(__git_ps1 " (%s)")\$ '
GIT_PS1_SHOWDIRTYSTATE=true
fi
# bash setting
@nevill
nevill / Hijacked packets
Last active August 29, 2015 14:06
Baidu Hijack
11:29:35.387693 IP (tos 0x0, ttl 63, id 50801, offset 0, flags [DF], proto TCP (6), length 64)
116.2xx.x.x.53587 > 115.239.211.110.80: Flags [S], cksum 0x5f8f (correct), seq 895062881, win 65535, options [mss 1452,nop,wscale 4,nop,nop,TS val 783494939 ecr 0,sackOK,eol], length 0
0x0000: 4500 0040 c671 4000 3f06 95fc 74ea 2302 [email protected]@.?...t.#.
0x0010: 73ef d36e d153 0050 3559 9361 0000 0000 s..n.S.P5Y.a....
0x0020: b002 ffff 5f8f 0000 0204 05ac 0103 0304 ...._...........
0x0030: 0101 080a 2eb3 2f1b 0000 0000 0402 0000 ....../.........
11:29:35.394412 IP (tos 0x0, ttl 55, id 50801, offset 0, flags [DF], proto TCP (6), length 64)
115.239.211.110.80 > 116.2xx.x.x.53587: Flags [S.], cksum 0x2bbb (correct), seq 117149092, ack 895062882, win 65535, options [mss 1440,nop,wscale 7,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,sackOK,eol], length 0
0x0000: 4500 0040 c671 4000 3706 9dfc 73ef d36e [email protected]@.7...s..n