docker run -it --rm -u yap ubuntu /bin/bash # run as non-root user
docker run -it --rm --security-opt=no-new-privileges ubuntu /bin/bash
docker run -it --rm --cap-drop all --cap-add NET_ADMIN ubuntu /bin/bash
docker run -it --rm --read-only --tmpfs /opt ubuntu /bin/bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/3324643/processes-threads-green-threads-protothreads-fibers-coroutines-whats-the | |
https://stackoverflow.com/questions/46864623/which-of-coroutines-goroutines-and-kotlin-coroutines-are-faster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arrNum [5]int // this is an array | |
var sliceNum []int // this is a slice | |
fmt.Println(arrNum) // [5]int{0,0,0,0,0} array have initial value of zero value | |
fmt.Println(sliceNum) // []int(nil) slice have initial value of nil value | |
sliceNum == nil // true | |
arrNum[0] = 1 // ok | |
sliceNum[0] = 1 // compile time error because you cannot assign values to nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# https://mp.weixin.qq.com/s?__biz=MzA4MzIwNTc4NQ==&mid=2247484821&idx=1&sn=aaa173a8b913cc759c56efe05d2c15ad&chksm=9ffb4e63a88cc7755ca720b3886946245246d8e57687cf209ad47f61a186cc290c04ef57fc91&scene=21#wechat_redirect | |
function e_net() { | |
set -eu | |
pod=`kubectl get pod ${pod_name} -n ${namespace} -o template --template='{{range .status.containerStatuses}}{{.containerID}}{{end}}' | sed 's/docker:\/\/\(.*\)$/\1/'` | |
pid=`docker inspect -f {{.State.Pid}} $pod` | |
echo -e "\033[32m Entering pod netns for ${namespace}/${pod_name} \033[0m\n" | |
cmd="nsenter -n -t ${pid}" | |
echo -e "\033[32m Execute the command: ${cmd} \033[0m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func selectionSort(items []int) { | |
for x := 0; x < len(items) - 1; x++ { | |
min := x | |
for y := x+1; y < len(items); y++ { | |
if items[y] < items[min] { | |
min = y | |
} | |
} | |
items[x], items[min] = items[min], items[x] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT /_template/fluentbit | |
{ | |
"fluenbit" : { | |
"order" : 0, | |
"index_patterns" : [ | |
"fluentbit-*" | |
], | |
"settings" : { | |
"index" : { | |
"number_of_shards" : "10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl get certificaterequest | |
kubectl describe certificaterequest X | |
kubectl get order | |
kubectl describe order X | |
kubectl get challenge | |
kubectl describe challenge X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eu | |
REGION_SEPARATOR='--' | |
ec2_instance_id="$1" | |
ssh_user="$2" | |
ssh_port="$3" | |
ssh_public_key_path="$4" | |
ssh_public_key="$(cat "${ssh_public_key_path}")" | |
ssh_public_key_timeout=60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main(int argc, const char * argv[]) { | |
srandom(getpid()); | |
for (int i = 0; i < 16; i++) { | |
long int r = random(); | |
printf("%ld\n", r); |