Skip to content

Instantly share code, notes, and snippets.

View pebo's full-sized avatar

Per Böckman pebo

View GitHub Profile
@pebo
pebo / # docker compose example
Last active June 10, 2023 06:02
docker compose with base image
# usage
docker compose up
#!/bin/sh
set -e
script=$(basename $0)
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
find $scriptDir -maxdepth 1 -mindepth 1 -type d -exec sh -c '(test -d {}/.git && echo {} && cd {} && git status -s && echo)' \;
@pebo
pebo / .bashrc
Created October 28, 2019 09:15
Set GCP active config
gcp () {
if [ -z "$1" ]; then
echo "CLOUDSDK_ACTIVE_CONFIG_NAME=$CLOUDSDK_ACTIVE_CONFIG_NAME"
gcloud config configurations list
return 0
fi
export CLOUDSDK_ACTIVE_CONFIG_NAME=$1
if [[ $CLOUDSDK_ACTIVE_CONFIG_NAME =~ stage ]]
then
COLOR_PROFILE='\[\033[38;5;70m\]${CLOUDSDK_ACTIVE_CONFIG_NAME}\[$(tput sgr0)\]'
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROGRAM=`basename $0`
usage() {
cat <<EOT
Usage: $PROGRAM <ENV_NAME> [up|down|status]
@pebo
pebo / StmtCloudformationInstanceRolePolicy.json
Created April 21, 2016 07:13
Policy for typical cloudformation instance role usages
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "StmtCloudformationInstanceRolePolicy",
"Effect": "Allow",
"Action": [
"iam:AddRoleToInstanceProfile",
"iam:AttachRolePolicy",
"iam:CreateInstanceProfile",
@pebo
pebo / env-susbst.sh
Last active August 3, 2016 20:28
envsubst like substitution; only replacing $VAR or ${VAR} if they have a value in in env
#!/bin/bash
# envsubst like substitution; only replacing $VAR or ${VAR} if they exists
# based on http://mywiki.wooledge.org/TemplateFiles
while read -r; do
while [[ $REPLY =~ \$(([a-zA-Z_][a-zA-Z_0-9]*)|\{([a-zA-Z_][a-zA-Z_0-9]*)\})(.*) ]]; do
if [[ -n ${!BASH_REMATCH[2]} ]]; then
printf %s "${REPLY%"$BASH_REMATCH"}${!BASH_REMATCH[2]}"
else
printf %s "${REPLY%"$BASH_REMATCH"}\$${BASH_REMATCH[2]}"
fi
@pebo
pebo / .bashrc
Last active March 22, 2016 07:40
Show AWS_PROFILE in prompt
# with colors
awsp () {
export AWS_PROFILE=$1
if [[ $AWS_PROFILE =~ dev ]]
then
COLOR_PROFILE='\[\033[38;5;70m\]${AWS_PROFILE}\[$(tput sgr0)\]'
elif [[ $AWS_PROFILE =~ prod ]]
then
COLOR_PROFILE='\[$(tput setaf 1)\]${AWS_PROFILE}\[$(tput sgr0)\]'
else
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
import logging
PORT = 80
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
#!/bin/sh
set -e
wget -c --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm" --output-document="jdk-8u45-linux-x64.rpm"
sudo rpm -i jdk-8u45-linux-x64.rpm
@pebo
pebo / etcd-notes.md
Created April 27, 2015 11:04
etcd notes