Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / bash-if-statements.md
Created December 5, 2017 22:10
Bash IF Statements

Exists

Check if a Directory exists:

if [ -d "./data" ]
  then echo "true"
  else echo "false"
fi
@ruanbekker
ruanbekker / docker-nfs-volumes.md
Created December 10, 2017 10:43
NFS Volumes with Docker Swarm

Create NFS Volumes:

Creating the NFS Volume:

$ docker volume create --driver local \
  --opt type=nfs \
  --opt o=addr=192.168.1.115,uid=1000,gid=1000,rw \
  --opt device=:/mnt/volumes/mysql-test \
  mysql-test-1
@ruanbekker
ruanbekker / auth_pass_input.py
Created January 22, 2018 10:43
Using Getpass to prompt for sensitive info without prompting for it
import getpass
text = getpass.getpass(prompt='Enter your passphrase to encrypt ')
print("You have entered: {}".format(text))
@ruanbekker
ruanbekker / crypto-coindata-cardano-watcher.py
Created January 22, 2018 18:32
Checks the Last 1H and last 24H Data of Cardano on Coindata
#!/usr/bin/python
import requests
import json
baseurl = 'https://coindata.co.za/api.php'
r = requests.get(baseurl).content
j = json.loads(r)
for crypto in j:
@ruanbekker
ruanbekker / mysql-iam-rds.sh
Last active December 3, 2022 02:09
MySQL Client Wrapper for RDS IAM Based Authentication
#!/usr/bin/env bash
# Wrapper MySQL Client for IAM Based Authentication for MySQL and Amazon Aurora on RDS
# Read: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
# Usage: [app] [aws_profile] [rds_endpoint] [rds_mysql_username]
command_exists() {
type "$1" &> /dev/null ;
}
@ruanbekker
ruanbekker / aws_ssm_get_parameters.md
Created January 31, 2018 14:38
Getting Secrets from SSM using GetParameters Example

Example with SSM to get Parameter Values using GetParameters:

Setting Environment Variables:

$ export MYSQL_HOSTNAME="/test/ruan/mysql/db01/mysql_hostname"
$ export MYSQL_USERNAME="/test/ruan/mysql/db01/mysql_user"
@ruanbekker
ruanbekker / aws_ssm_get_parameter.md
Created January 31, 2018 14:41
Getting Secrets from SSM using GetParameter Example with Python and Boto3

Bash Environment Example with SSM to get Parameter Values using GetParameter:

IAM Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1517398919242",
@ruanbekker
ruanbekker / report_status.sh
Created February 15, 2018 09:42
Report Status Codes in Bash
#!/bin/bash
#set -e
python -c "import $1" > /dev/null 2>&1
code=$?
if [ $code == 0 ]
then
echo "good"
echo "Status Code: $code"
else
@ruanbekker
ruanbekker / setup-golang.sh
Created February 20, 2018 12:20
Setup Golang on Linux
#!/usr/bin/env bash
mkdir -p ~/workspace/go
cd /tmp
wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
tar -xf go1.8.1.linux-amd64.tar.gz
sudo chown -R root:root ./go
sudo mv go /usr/local
rm -rf go1.8.1.linux-amd64.tar.gz
echo 'export GOPATH=$HOME/workspace/go' >> ~/.profile
echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' >> ~/.profile
@ruanbekker
ruanbekker / read_and_write-args.go
Last active March 2, 2018 11:18
Golang: Read File and Write to Disk with Arguments
package main
import (
"io/ioutil"
"os"
"fmt"
)
var (
input_filename string