Skip to content

Instantly share code, notes, and snippets.

@naingyeminn
naingyeminn / vboxssh.sh
Created December 29, 2017 22:01
SSH Login to VBox Headless
#!/bin/bash
aname=$1
vm=$2
vmauth=$3
if [ -n "$4" ]; then
port=$4
else
port=22
fi
@naingyeminn
naingyeminn / delegation-test.yml
Last active December 12, 2018 12:18
Ansible Lab
---
- name: play - one
hosts: vm01.example.com
tasks:
- name: write content
copy:
content: "{{ ansible_nodename }}"
dest: /tmp/managed_host.txt
- name: get content
@naingyeminn
naingyeminn / suid_test.c
Created December 25, 2018 11:28
some codes
#include <stdio.h>
#include <stdlib.h>
int main()
{
char sometext[256];
FILE *fptr;
fptr = fopen("/tmp/suid_test.txt","w");
if(fptr == NULL)
{
@naingyeminn
naingyeminn / con_check.yml
Last active March 31, 2021 13:15
Ansible - Listen module
---
- hosts: servera.example.com
tasks:
- name: serverB listen on port 8888
listen:
port: "8888"
async: 5
poll: 0
delegate_to: serverb.example.com
[tower-cli]
baseurl = https://releases.ansible.com/ansible-tower-cli/rpm/epel-7-x86_64/
sslverify = 0
name = Ansible Tower-cli
enabled = 1
gpgcheck = 0
@naingyeminn
naingyeminn / ntfsmount
Last active October 6, 2022 16:02
NTFS-3G Mount Script for MacOS
#!/bin/bash
#---- ---- ---- ----
# Copyright (C) Naing Ye Minn <naingyeminn@gmail.com>
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#---- ---- ---- ----
# Install osxfuse and ntfs-3g via brew
# $ brew cask install osxfuse
# $ brew install ntfs-3g
@naingyeminn
naingyeminn / mm-kb-install.sh
Last active March 9, 2020 16:18
MM-KB Quick Install
#!/bin/bash
FONTCFG=~/.config/fontconfig/
mm_kb=https://github.com/naingyeminn/mm-kb/archive/master.zip
wget -N $mm_kb 2> /dev/null || curl -OL $mm_kb
unzip -o master.zip
cd mm-kb-master
sudo apt install make ibus-table -y
sudo make install
ibus-daemon -rdx
@naingyeminn
naingyeminn / kubeswitch
Last active August 2, 2022 02:46
Switch K8S cluster context easily
#!/bin/bash
# run `kubeswitch` to list the contexts from .kube/config and set current context
# run `source <(kubeswitch)` to use the selected context in active shell environment only
# or add `alias kswitch='source <(kubeswitch)'` in ~/.bashrc
unset KUBECONFIG
select context in $(kubectl config get-contexts -o name); do
kubectl config use-context $context &> /dev/null
kubectl config view --minify --context $context --flatten > ${HOME}/.kube/$context.conf
chmod 600 ${HOME}/.kube/$context.conf
@naingyeminn
naingyeminn / setkube
Created June 11, 2022 17:13
Manage and maintain multiple kubectl versions
#!/bin/bash
BIN_PATH="$HOME/.local/bin"
help_msg () {
echo "Usage: setkube -v [kubectl_version_number | stable]"
echo " setkube -d [kubectl_version_number]"
echo ""
echo " kubectl_version_number = 1.23.5, 1.22.2, etc."
#!/bin/bash
# usage: kubeadd new_kubeconfig_file
cp ~/.kube/config ~/.kube/config.$(date +%F)
KUBECONFIG=~/.kube/config:$1 kubectl config view --flatten > /tmp/config
mv /tmp/config ~/.kube/config
chmod 600 ~/.kube/config