Skip to content

Instantly share code, notes, and snippets.

View rms1000watt's full-sized avatar

Ryan M Smith rms1000watt

View GitHub Profile
@rms1000watt
rms1000watt / slack.go
Created March 13, 2019 20:13
Send Slack Incoming Webhook in Golang
func Slack(url, msg string) (err error) {
buf := bytes.NewBufferString(fmt.Sprintf(`{"text":"%s"}`, msg))
if _, err := http.Post(url, "application/json", buf); err != nil {
fmt.Println("Failed posting to slack:", err)
}
return
}
@rms1000watt
rms1000watt / main.sh
Last active March 17, 2019 07:28
Main parent bash script to run multiple commands
#!/usr/bin/env bash
NC='\033[0m'
red() { echo -e "\033[0;31m$@${NC}";}
blue() { echo -e "\033[0;96m$@${NC}";}
green() { echo -e "\033[1;32m$@${NC}";}
yellow(){ echo -e "\033[0;33m$@${NC}";}
help() {
red "Usage:
@rms1000watt
rms1000watt / update-all.sh
Last active October 16, 2019 06:11
Update All (Update all github repos in a directory once every 5 minutes)
#!/usr/bin/env bash
# Usage: ./update-all.sh $GOPATH/src/github.com/rms1000watt
B='\033[0;34m'
NC='\033[0m'
MAIN_DIR=$1
if [ -z $MAIN_DIR ]; then
echo "No directory to walk and update"
@rms1000watt
rms1000watt / build-go-versions.sh
Last active June 20, 2019 19:38
Build go versions of your golang app
#!/usr/bin/env bash
set -e
rm -rf bin ||:
mkdir bin ||:
PROJECT=$(basename $(git rev-parse --show-toplevel))
VERSION=$(cat version.txt)
export CGO_ENABLED=0
@rms1000watt
rms1000watt / k8s-shell-in-cluster.sh
Created March 4, 2019 21:42
Kubernetes shell in cluster
#!/usr/bin/env bash
kubectl create -f https://k8s.io/examples/application/shell-demo.yaml
kubectl get pod shell-demo
kubectl exec -it shell-demo -- /bin/bash
@rms1000watt
rms1000watt / aws-ubuntu-no-dns-resolution-fix.sh
Created February 14, 2019 21:06
AWS Ubuntu No DNS resolution fix
echo "supersede domain-name-servers 8.8.8.8, 9.9.9.9;" | sudo tee -a /etc/dhcp/dhclient.conf &> /dev/null
sudo ifdown eth0 && sudo ifup eth0
@rms1000watt
rms1000watt / fix-sed.sh
Created February 12, 2019 08:36
sed RE error illegal byte sequence
# https://stackoverflow.com/a/19770395/2330648
# sed: RE error: illegal byte sequence
export LC_CTYPE=C
export LANG=C
sed 's|`testing`|`pizza`|g' < in.txt > out.txt
@rms1000watt
rms1000watt / test.py
Created January 21, 2019 01:40
Python Unit Tests Output junit
import unittest
class RyanTest(unittest.TestCase):
def test_hello_world(self):
print("hello world")
def test_failure(self):
self.assertEqual(1, 2)
@rms1000watt
rms1000watt / install-consul-linux.sh
Created January 14, 2019 03:58
Install Consul on Linux
#!/usr/bin/env bash
if [[ ! -f /bin/consul ]]; then
CONSUL_VERSION=1.4.0
apt update -y
apt install -y curl unzip
curl -L -o consul_${CONSUL_VERSION}_linux_amd64.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
unzip -d /bin consul_${CONSUL_VERSION}_linux_amd64.zip
@rms1000watt
rms1000watt / ansible.yml
Created January 11, 2019 00:00
Test Ansible YAML for local testing
- hosts: 127.0.0.1
tasks:
- shell: cat hello.txt
register: hello_world
changed_when: false
- debug:
var: hello_world.stdout
- debug: