Skip to content

Instantly share code, notes, and snippets.

View zdk's full-sized avatar
:octocat:

Di Warachet S. zdk

:octocat:
  • Thailand
  • 06:15 (UTC +07:00)
View GitHub Profile
@zdk
zdk / query_srv_record.tsx
Last active August 14, 2024 14:59
Test SRV record query with Bun
import * as dns from "node:dns";
import { $ } from 'bun';
const addrs = await dns.promises.resolveSrv("_web1._tcp.mydomain.local");
console.log(addrs);
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
docker pull registry.k8s.io/ingress-nginx/controller:v1.8.1
docker pull registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
kind load docker-image -n dev registry.k8s.io/ingress-nginx/controller:v1.8.1
kind load docker-image -n dev registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
@zdk
zdk / create-cluster.sh
Last active August 5, 2024 12:59
kind cluster
cat <<EOF | kind create cluster --name dev --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
@zdk
zdk / haproxy.md
Created January 11, 2024 13:16 — forked from guycalledseven/haproxy.md
haproxy conditions

Haproxy conditions

Since I keep forgetting them I've put them here.

To form a condition, you can use the following syntax after the rule that it applies to:

<HAProxy action statement> if|unless [!]acl1 <AND|OR|or|'||'> [!]acl2 ...

  • if - the condition is TRUE if the result of the ACLs is TRUE.
#!/bin/bash
openssl req -nodes -x509 -newkey rsa:2048 -keyout /etc/ssl/private/test.key -out /etc/ssl/private/test.crt -days 30
cat /etc/ssl/private/test.key /etc/ssl/private/test.crt > /etc/ssl/private/test.pem
cat <<EOL >> /etc/haproxy/haproxy.cfg
defaults
mode http
timeout client 10s
timeout connect 5s
timeout server 10s
#!/bin/bash
# update, add docker gpg key, and docker apt repo
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
apt-cache policy docker-ce
if [[ $(grep -i microsoft /proc/version) ]]; then
@zdk
zdk / th-address.json
Created November 20, 2023 10:50 — forked from mennwebs/th-address.json
Thai Address from Postal Code - JSON
This file has been truncated, but you can view the full file.
[
{
"zipCode": "10100",
"subDistrictList": [
{
"subDistrictId": "100801",
"districtId": "1008",
"provinceId": "10",
"subDistrictName": "ป้อมปราบ"
@zdk
zdk / .zshrc
Last active November 20, 2023 02:11
Kill multi ports
killport() {
while test $# -gt 0
do
port_number=$1
pid=$(lsof -P | grep ':'$port_number'[[:space:]](LISTEN)' | awk '{print $2}')
if ! kill -QUIT $pid > /dev/null 2>&1; then
echo -e "\e[0;31mNo process running on \e[0m $port_number port" >&2
else
echo -e "Kill $port_number \e[0;32msuccessfully\e[0m"
fi