Skip to content

Instantly share code, notes, and snippets.

Avatar
🇨🇳
Focusing

K8sCat k8scat

🇨🇳
Focusing
View GitHub Profile
@k8scat
k8scat / openresty.service
Created Jun 9, 2021 — forked from HauptJ/openresty.service
OpenResty Systemd service file
View openresty.service
# Stop dance for OpenResty
# A modification of the Nginx systemd script
# Source: https://www.digitalocean.com/community/tutorials/how-to-use-the-openresty-web-framework-for-nginx-on-ubuntu-16-04
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the Nginx process.
# If, after 5s (--retry QUIT/5) OpenResty is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if OpenResty is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
@k8scat
k8scat / gh-dl-release
Created Jun 6, 2021 — forked from maxim/gh-dl-release
Download assets from private Github releases
View gh-dl-release
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
View bash.generate.random.alphanumeric.string.sh
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@k8scat
k8scat / ssl_smtp_example.go
Created May 19, 2021 — forked from chrisgillis/ssl_smtp_example.go
Golang SSL SMTP Example
View ssl_smtp_example.go
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@k8scat
k8scat / rm_mysql.md
Created May 17, 2021 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX
View rm_mysql.md

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    
@k8scat
k8scat / 📊 Weekly development breakdown
Last active Jun 23, 2021
📊 Weekly development breakdown
View 📊 Weekly development breakdown
Other 29 hrs 33 mins ██████████▎░░░░░░░░░░ 49.1%
Go 14 hrs 23 mins █████░░░░░░░░░░░░░░░░ 23.9%
Markdown 11 hrs 56 mins ████▏░░░░░░░░░░░░░░░░ 19.8%
Bash 1 hr 41 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.8%
sh 1 hr 6 mins ▍░░░░░░░░░░░░░░░░░░░░ 1.8%
@k8scat
k8scat / postman_pre_request.js
Created May 12, 2021
Pre-request Script in Postman help me get and refresh the access_token.
View postman_pre_request.js
// https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#sending-requests-from-scripts
const url = pm.environment.replaceIn("{{base_url}}/some/api")
const req = {
url: url,
method: 'POST',
header: {
'Content-Type': 'application/json',
'X-Foo': 'bar'
},
body: {
@k8scat
k8scat / delete_git_submodule.md
Created May 11, 2021 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.
View delete_git_submodule.md

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@k8scat
k8scat / backup_volume.sh
Last active May 8, 2021
Backup data from a volume.
View backup_volume.sh
#!/bin/sh
#
# Backup data from a volume.
# Maintainer: k8scat@gmail.com
data_volume=$1
data_dir=$2
if [[ "${data_volume}" = "" || "${data_dir}" = "" ]]; then
echo "usage: $0 <data_volume> <data_dir>"
exit 1
@k8scat
k8scat / install_git.sh
Last active Jun 13, 2021
Install git from source code on CentOS 7.
View install_git.sh
#!/bin/bash
#
# Install git from source code on CentOS 7, refer to https://github.com/git/git/blob/master/INSTALL
set -e
# Get version from https://github.com/git/git/releases, for example: 2.29.2
version=$1
if [[ -z "${version}" ]]; then
echo "usage: $0 <version, 2.29.2> [profile]"
exit 1