Skip to content

Instantly share code, notes, and snippets.

View nevermosby's full-sized avatar
🎯
Focusing

Wen-Quan Li nevermosby

🎯
Focusing
View GitHub Profile
@nevermosby
nevermosby / goroutine-download-file.go
Created August 22, 2016 09:14
Use goroutine to download multiple files
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"strings"
"sync"
@nevermosby
nevermosby / goroutine-channel-communicate.go
Created August 22, 2016 09:16
Use goroutine and channel to share data
package main
import (
"fmt"
"math/rand"
"sync"
)
func main() {

zuul 配置

zuul:
  ignoredServices: '*'
  host:
    connect-timeout-millis: 20000
    socket-timeout-millis: 20000

  routes:
 auth-service:
@nevermosby
nevermosby / ss-man.sh
Last active May 25, 2018 05:28
ss command help dos
ss -ltn # list out all the listening sockets
ss -ltp # list out all the listening socketes and the related process name with pid
ss -t4 state time-wait # list all Ipv4 tcp sockets that are in "time-wait" state
# state list
1. established
2. syn-sent
3. syn-recv
4. fin-wait-1
5. fin-wait-2
@nevermosby
nevermosby / go-help-modules.txt
Created October 4, 2018 04:52
the output of `go help modules` command
# go help modules
A module is a collection of related Go packages.
Modules are the unit of source code interchange and versioning.
The go command has direct support for working with modules,
including recording and resolving dependencies on other modules.
Modules replace the old GOPATH-based approach to specifying
which source files are used in a given build.
Preliminary module support
@nevermosby
nevermosby / deepequal.go
Last active February 12, 2019 03:12
source code of relect.DeepEqual in golang
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Deep equality test via reflection
package reflect
import "unsafe"
@nevermosby
nevermosby / etcdctl-mannual.md
Last active August 28, 2019 09:11
etcdctl-mannual

use etcdctl for etcd v3 API

if you have access to the etcd server, you can use the following steps to try etcd v3 API to fetch Kubernetes cluster data

  1. set environment to use v3 API
# set ETCDCTL_API
export ETCDCTL_API=3
  1. use etcdctl tool to fetch all the namespaces
# fetch all the namespaces
@nevermosby
nevermosby / update-k8s-pv.sh
Created December 8, 2019 02:32
manually update kubernetes PV path
#!/bin/sh
# 1. delete pv, pv会变成terminating状态
kubectl delete pv [pv-name]
# 2. delete pvc, pvc会变成terminating状态
kubectl delete pvc [pvc-name-related-to-pv]
# 3. patch pvc to remove protection, 具体可以看这里:https://stackoverflow.com/questions/51358856/kubernetes-cant-delete-persistentvolumeclaim-pvc,然后pv和pvc就被干净删除了
kubectl patch pvc [pvc-name] -p '{"metadata":{"finalizers": []}}' --type=merge
@nevermosby
nevermosby / build-curl-with-c-ares.sh
Last active April 4, 2024 00:40
build curl with c ares for custom dns server
## for some distributions of Linix, like ubuntu 18.04
## `curl` does not include `c-ares` module so that you cannot do `curl --dns-servers 8.8.8.0 www.example.com`
## you will get error message as below:
## curl: (4) A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision.
# build curl from source code
# You can do that with building `curl` from souce code. below is tested against ubuntu 18.04
# download the code from git repo
git clone https://github.com/curl/curl.git && cd curl
@nevermosby
nevermosby / bpf-tc-drop-tcp-not-inline.o
Created May 24, 2020 06:28
bpf program cannot loaded into kernel if the program contains not-inlined functions
Disassembly of section tc:
tc_drop_tcp:
0: bf 16 00 00 00 00 00 00 r6 = r1
1: b7 01 00 00 69 6f 6e 0a r1 = 175009641
2: 63 1a f8 ff 00 00 00 00 *(u32 *)(r10 - 8) = r1
3: 18 01 00 00 20 74 63 20 00 00 00 00 73 65 63 74 r1 = 8386658476233028640 ll
5: 7b 1a f0 ff 00 00 00 00 *(u64 *)(r10 - 16) = r1
6: 18 01 00 00 45 6e 74 65 00 00 00 00 72 69 6e 67 r1 = 7453010373394067013 ll
8: 7b 1a e8 ff 00 00 00 00 *(u64 *)(r10 - 24) = r1
9: b7 01 00 00 00 00 00 00 r1 = 0