Skip to content

Instantly share code, notes, and snippets.

View Yapcheekian's full-sized avatar

Yap Yapcheekian

View GitHub Profile
@Yapcheekian
Yapcheekian / notes.md
Last active July 28, 2021 16:43
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
Yapcheekian / sorting_algorithm.go
Last active July 28, 2021 01:46
selection sort, bubble sort, insertion sort, merge sort, quick sort
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
Yapcheekian / notes.md
Last active February 5, 2024 15:04
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 192.168.15.1 dev veth-red

@Yapcheekian
Yapcheekian / guide.md
Created July 22, 2021 12:29
Integrate elastic cloud with okta

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/

elasticsearch.yml

xpack:
@Yapcheekian
Yapcheekian / template.json
Created July 16, 2021 02:44
Create elasticsearch index template
PUT /_template/fluentbit
{
"fluenbit" : {
"order" : 0,
"index_patterns" : [
"fluentbit-*"
],
"settings" : {
"index" : {
"number_of_shards" : "10"
@Yapcheekian
Yapcheekian / debug.txt
Created June 30, 2021 02:58
Cert manager debug
kubectl get certificaterequest
kubectl describe certificaterequest X
kubectl get order
kubectl describe order X
kubectl get challenge
kubectl describe challenge X
@Yapcheekian
Yapcheekian / note.md
Last active June 14, 2021 07:39
Binary search 模版

找一個準確值

循環條件: l <= r

縮減搜索空間: l = mid + 1, r = mid - 1

找一個模糊值(比4大的最小數)

循環條件: l < r

縮減搜索空間: l = mid, r = mid - 1 或者 l = mid + 1, r = mid

@Yapcheekian
Yapcheekian / aws-ssm-ec2-proxy-command.sh
Last active June 15, 2021 03:54
ssh tunneling with ssm
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
@Yapcheekian
Yapcheekian / random.c
Created May 30, 2021 00:00
Random number generator in c
#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);