Skip to content

Instantly share code, notes, and snippets.

@zawyelwin
zawyelwin / test.yml
Last active September 3, 2020 18:41
A Simple YAML flatten script with dot notation.
en:
questions:
new: 'New Question'
other:
recent: 'Recent'
old: 'Old'
@zawyelwin
zawyelwin / certificate-renewal.sh
Last active December 1, 2020 07:58
Some handy kubectl commands to make your life easier.Collected from some great resources I found out and some tweaks from their implementations. All credits goes to the original authors.
$ cd /etc/kubernetes/pki/
$ mv {apiserver.crt,apiserver-etcd-client.key,apiserver-kubelet-client.crt,front-proxy-ca.crt,front-proxy-client.crt,front-proxy-client.key,front-proxy-ca.key,apiserver-kubelet-client.key,apiserver.key,apiserver-etcd-client.crt} ~/certs-bak
$ kubeadm init phase certs all
$ cd /etc/kubernetes/
$ mv {admin.conf,controller-manager.conf,kubelet.conf,scheduler.conf} ~/certs-bak
$ kubeadm init phase kubeconfig all
$ reboot
######################################################################### SERVER
resource "azuread_application" "server" {
name = "k8s_server"
reply_urls = ["http://k8s_server"]
type = "webapp/api"
# this is important, as stated by the documentation
group_membership_claims = "All"
required_resource_access {
@zawyelwin
zawyelwin / example.md
Last active December 15, 2020 20:20
Rename all files in a directory based on the line number from a txt file.

Original File name

1.mp4 2.mp4 3.mp4 4.mp4

title.txt

1-abc
2-def
3-ghi
stages:
- docker build
docker:image:
stage: docker build
image: docker
when: manual
variables:
DOCKER_HOST: tcp://docker-service.gitlab-managed-apps:2375
DOCKER_DRIVER: overlay2
@zawyelwin
zawyelwin / db_dump.sh
Created February 24, 2021 05:00
Dump all databases without except system databases.
#!/bin/bash
host=<DB_HOST>
password=<DB_PASSWORD>
user=<DB_USER>
database=( $(mysql -h $host -u $user -p$password -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|mysql|performance_schema|tmp|sys)") )
for db in "${database[@]}"
do
mysqldump -h $host -u $user -p$password $db > $db.sql
@zawyelwin
zawyelwin / az_acr_import.sh
Created February 24, 2021 05:10
Script to import azure container registry images with tags to another azure container registry.
#!/bin/bash
registryName='<REGISTRY_NAME>'
repository=("apm/pinpoint-agent", "apm/pinpoint-collector")
sourceAcrName="<SOURCE_ACR_NAME>"
destAcrName="<DESTINATION_ACR_NAME>"
for repo in "${repository[@]}"
do
tags=$(az acr repository show-tags --name $sourceAcrName --repository $repo | xargs | tr -d '[]\n\r,' )
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
@zawyelwin
zawyelwin / laravel-deploy.md
Last active February 3, 2025 21:10
Deploy a Laravel app properly.

Add a user to the server and append the user to the sudo group. You can verify the user is in the sudo group using id <username> command.

adduser <username>
usrmod -aG sudo <username>

Install Ngxin MySql PHP and necessary extensions for Laravel.

sudo apt update
@zawyelwin
zawyelwin / .dockerignore
Created September 18, 2021 20:27
Simple Laravel Docker Deployment
bootstrap/cache/services.php
storage/app/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/views/*
storage/logs/*
vendor/