Skip to content

Instantly share code, notes, and snippets.


Yap Yapcheekian

  • Taiwan
View GitHub Profile
Yapcheekian / concurrent.txt
Last active Dec 31, 2021
Process vs coroutines vs thread
View concurrent.txt
Yapcheekian /
Created Aug 31, 2021
Fix when gem install mysql2 in rails failed
gem install mysql2 -v 0.5.3 -- \
--with-mysql-config=/usr/local/Cellar/mysql/8.0.26/bin/mysql_config \
--with-ldflags=-L/usr/local/opt/openssl/lib \
--with-cppflags=-I/usr/local/opt/openssl/include \
Yapcheekian / slices.go
Created Aug 9, 2021
Notes on go slices
View slices.go
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
Yapcheekian /
Last active Aug 5, 2021
capture pod packet
#!/usr/bin/env bash
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"
Yapcheekian /
Last active Jul 28, 2021
Docker security hardening
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
Yapcheekian / sorting_algorithm.go
Last active Jul 28, 2021
selection sort, bubble sort, insertion sort, merge sort, quick sort
View sorting_algorithm.go
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]
Yapcheekian /
Last active Jul 24, 2021
Notes on linux, container and kubernetes networking commands and concepts

Scenario 1: only 2 container (red and blue) created

ip link add veth-red type veth peer name veth-blue

ip link set veth-red netns red

ip link set veth-blue netns blue

ip -n red addr add dev veth-red

Yapcheekian /
Created Jul 22, 2021
Integrate elastic cloud with okta


  1. Create an application in okta
  2. Choose SAML2.0
  3. Give a random app name
  4. Single sign on URL: KIBANA_ENDPOINT_URL/api/security/saml/callback
  5. Audience URI (SP Entity ID): KIBANA_ENDPOINT_URL/


Yapcheekian / template.json
Created Jul 16, 2021
Create elasticsearch index template
View template.json
PUT /_template/fluentbit
"fluenbit" : {
"order" : 0,
"index_patterns" : [
"settings" : {
"index" : {
"number_of_shards" : "10"