Skip to content

Instantly share code, notes, and snippets.

View rms1000watt's full-sized avatar

Ryan M Smith rms1000watt

View GitHub Profile
@rms1000watt
rms1000watt / openssl-create-ca-and-signed-keys.sh
Last active April 25, 2019 06:39
OpenSSL Create CA Certificate Authority and CA Signed Keys
#!/usr/bin/env bash
# Create a CA Key & Cert
openssl genrsa -out ca.key 4096
openssl req -x509 -new -key ca.key -out ca.crt -days 730 -subj /CN="MyFirstCA"
# Create a server Key & CSR
openssl genrsa -out server.key 4096
openssl req -new -out server.csr -key server.key -config openssl.cnf
@rms1000watt
rms1000watt / volume-mount-aws-nvme-docker.sh
Created April 19, 2019 17:44
Volume Mount AWS NVMe SSD and point docker to run from it
if [[ ${disk_ephemeral} -eq 1 ]]; then
echo "START: Mount the ephemeral disk"
sudo mkfs.ext4 /dev/nvme0n1
sudo mount -t ext4 /dev/nvme0n1 /opt
echo '/dev/nvme0n1 /opt auto noatime 0 0' | sudo tee -a /etc/fstab
sudo mount -a
sudo chmod -R 777 /opt
echo "DONE: Mount the ephemeral disk"
@rms1000watt
rms1000watt / main.go
Last active April 11, 2019 06:46
Golang Server In Memory SQLite3 example
// go run main.go
// curl -XPOST "localhost:9999/person?name=ryan&age=88"
// curl -XGET "localhost:9999/person?name=ryan"
// Philosophy: Write the least amount of code to get to the DB which includes
// internal/external packages
package main
import (
@rms1000watt
rms1000watt / dates.sh
Last active December 18, 2019 20:25
BitBar Plugins: Docker Stats, Netstats, Timezones, Refresh
#!/usr/bin/env bash
arr=()
arr[0]="[AU] $(TZ=Australia/Melbourne date +'%I:%M %p')"
arr[1]="[LA] $(TZ=America/Los_Angeles date +'%I:%M %p')"
arr[2]="[TX] $(TZ=US/Central date +'%I:%M %p')"
arr[3]="[NY] $(TZ=America/New_York date +'%I:%M %p')"
rand=$[$RANDOM % ${#arr[@]}]
echo "${arr[$rand]} | size=12"
@rms1000watt
rms1000watt / ryan
Created March 22, 2019 20:55
ryan script for general functionality on Darwin
#!/usr/bin/env bash
set -e
help() {
echo "Usage:
ryan container CONTAINER_NAME # Get container ID
" 1>&2
exit 1
@rms1000watt
rms1000watt / clean-git.sh
Created March 20, 2019 19:35
Clean Git Garbage Collector (gc prune aggressive reflog)
#!/usr/bin/env bash
git gc --aggressive --prune=now
git reflog expire --all --expire=now
@rms1000watt
rms1000watt / .realize.yaml
Created March 19, 2019 06:58
Realize Yaml for a project with go modules configured
schema:
- name: project-name
path: .
commands:
install:
status: true
method: go build -o ./project-name
run:
status: true
method: ./project-name
@rms1000watt
rms1000watt / main.sh
Created March 18, 2019 00:04
Add busybox (shell) into from scratch container as volume mount for temporary shell
#!/usr/bin/env bash
if [[ ! -d "busybox" ]]; then
curl -o busybox.tar.xz -L https://github.com/docker-library/busybox/blob/82bc0333a9ae148fbb4246bcbff1487b3fc0c510/uclibc/busybox.tar.xz?raw=true
mkdir busybox
tar -zxvf busybox.tar.xz -C busybox
rm busybox.tar.xz
fi
docker run -it --rm --entrypoint sh -v $(pwd)/busybox/bin:/bin hello-world
@rms1000watt
rms1000watt / aws-get-kubeconfig-from-eks.sh
Created March 14, 2019 22:12
AWS Get kubeconfig from EKS
#!/usr/bin/env bash
eval $(assume-role dev-account)
aws eks update-kubeconfig --region us-east-1 --name dev-eks
@rms1000watt
rms1000watt / log-in-to-ecr.sh
Created March 14, 2019 22:11
AWS Log in to ECR
#!/usr/bin/env bash
export AWS_PROFILE=personal
$(aws ecr get-login --region us-east-1 --no-include-email)