Skip to content

Instantly share code, notes, and snippets.

View gadiener's full-sized avatar

Gabriele gadiener

View GitHub Profile
@gadiener
gadiener / create-deployer-iam.sh
Last active December 5, 2019 16:42
Create GKE deployer IAM
#!/bin/sh
set -e
if [ -n "${DEBUG}" ]; then
set -x
fi
for var in "NAME" "PROJECT"; do
if [ -z "${!var}" ]; then
@gadiener
gadiener / create-docker-credentials.sh
Created December 5, 2019 16:33
Create docker-registry secret file
#!/bin/sh
set -e
if [ -n "${DEBUG}" ]; then
set -x
fi
for var in "DOCKER_USERNAME" "DOCKER_PASSWORD" "DOCKER_EMAIL"; do
if [ -z "${!var}" ]; then
@gadiener
gadiener / viscosity-to-ovpn.py
Created October 20, 2019 17:17 — forked from ishahid/viscosity-to-ovpn.py
Convert all of your Viscosity connections into OVPN configuration files for OpenVPN
#!/usr/bin/python
"""Convert all of your Viscosity connections into OVPN configuration files for OpenVPN
https://gist.github.com/ishahid/693c2c97b3236a3c2416fc09ab170244
"""
import re
import glob
from os.path import expanduser, dirname
@gadiener
gadiener / delete_custom_metrics.py
Created July 19, 2019 09:20 — forked from jeffadams/delete_custom_metrics.py
script to delete all custom metrics from a stackdriver account
#!/usr/bin/env python
from google.cloud import monitoring
'''
# Using a service account with credentials in a json file:
JSON_CREDS = '/path/to/json'
from oauth2client.service_account import ServiceAccountCredentials
scopes = ["https://www.googleapis.com/auth/monitoring",]
credentials = ServiceAccountCredentials.from_json_keyfile_name(
@gadiener
gadiener / glogstalgia.sh
Last active July 1, 2019 09:51
Logstalgia for Google Cloud Engine Load Balancer, to install: `curl -o /usr/local/bin/glogstalgia https://gist.githubusercontent.com/gadiener/c6fa7726b9d74e0fc67ffb15c4b04f26/raw/d1574f52bf5b4f319e1ac5e46192d56401ff6349/glogstalgia.sh && chmod +x /usr/local/bin/glogstalgia`
#!/bin/sh
set -eo pipefail
PID_FILE_PATH=${PID_FILE_PATH:-'/usr/local/var/run/'}
PID_FILE_NAME=${PID_FILE_NAME:-'glogstalgia.pid'}
LOG_FILE_PATH=${LOG_FILE_PATH:-'/usr/local/var/log/'}
LOG_FILE_NAME=${LOG_FILE_NAME:-'glogstalgia.log'}
GCLOUD_LOG_QUERY=${GCLOUD_LOG_QUERY:-'resource.type="http_load_balancer"'}
LOGSTALGIA_COMMAND=${LOGSTALGIA_COMMAND:-'logstalgia --sync --frameless'}
@gadiener
gadiener / delete-evicted-pod.sh
Created June 21, 2019 12:06
Delete evicted pods
#!/bin/sh
kubectl get po --all-namespaces | awk '{if ($4 ~ /Evicted/) system ("kubectl -n " $1 " delete pods " $2)}'
@gadiener
gadiener / docker-helpers.sh
Created October 31, 2018 11:31
Docker helpers for local env
dkill() {
# Kill all running containers
docker ps -q | xargs docker kill
}
dprune() {
# Prune unused objects
docker system prune --all --force
}
@gadiener
gadiener / backup-repos
Created October 15, 2018 10:16 — forked from kopiro/backup-repos.sh
Backup all Repositories in current directory
#!/bin/bash
for i in $(find . -type d -maxdepth 1 -mindepth 1); do
echo "Backup $i..."
zip_name="$i-$(date +'%y%m%d').zip"
pushd "$i" && \
git archive --format=zip --output="/opt/backups/$zip_name" master && \
popd
done
@gadiener
gadiener / vboxhostonlyssh.md
Created May 16, 2018 10:07 — forked from cfebs/vboxhostonlyssh.md
setup a vbox ubuntu server with host only adapter

Virtualbox dev environment w/ static IP

I can never find a great guide on this stuff, so these are more like notes to myself.

The goal here is to have a virtualbox running more or less headless. An ssh client is used separately to actually use the machine. I've found it to be fantastic for a quick dev setup.

lets go

Assumes you have a vbox setup with Ubuntu server (this will work for 16.04) ready to go.

@gadiener
gadiener / Virtual Box Host Only Static IP.md
Created May 16, 2018 09:12 — forked from pjdietz/Virtual Box Host Only Static IP.md
VirtualBox Host-Only Adapter with Static IP

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

Temporary