Skip to content

Instantly share code, notes, and snippets.

@k8scat
k8scat / ssl_smtp_example.go
Created May 19, 2021 07:54 — forked from chrisgillis/ssl_smtp_example.go
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@k8scat
k8scat / rm_mysql.md
Created May 17, 2021 14:31 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

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 July 16, 2021 00:48
📊 Weekly development breakdown
Other 67 hrs 4 mins █████████████████▍░░░ 83.2%
Go 6 hrs 4 mins █▌░░░░░░░░░░░░░░░░░░░ 7.5%
Markdown 2 hrs 14 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.8%
sh 1 hr 37 mins ▍░░░░░░░░░░░░░░░░░░░░ 2.0%
JavaScript 43 mins ▏░░░░░░░░░░░░░░░░░░░░ 0.9%
@k8scat
k8scat / postman_pre_request.js
Created May 12, 2021 10:52
Pre-request Script in Postman help me get and refresh the access_token.
// 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 03:45 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

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 02:36
Backup data from a volume.
#!/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 June 13, 2021 17:35
Install git from source code on CentOS 7.
#!/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
@k8scat
k8scat / install_python.sh
Last active May 7, 2021 04:00
Install python3 from source code on CentOS 7.
#!/bin/bash
#
# Install python3 from source code on CentOS 7
# Maintainer: K8sCat <k8scat@gmail.com>
set -e
if [[ $(id -u) -ne 0 ]]; then
echo "require root"
exit 1
fi
@k8scat
k8scat / logfilter.go
Last active May 6, 2021 10:44
Filter content by date range or read only last N lines of a file.
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"os"
"regexp"
@k8scat
k8scat / watch.sh
Last active May 4, 2021 19:11
Play `watch` in a shell script
#!/bin/sh
# while :; do clear; your_command; sleep 2; done
# usage: watch.sh "<your_command>" "<sleep_duration>"
d=${2:-2}
while :; do
clear
date
$1
sleep ${d}