Skip to content

Instantly share code, notes, and snippets.

Renier Morales renier

Block or report user

Report or block renier

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@renier
renier / iterm2_kubectx.py
Last active Nov 20, 2019
iterm2 script that sets internal kubectx variable
View iterm2_kubectx.py
#!/usr/bin/env python3.7
#
# This will set an iterm2 variable "user.kubectx" with the name of the
# current kubectl context and namespace configured. This variable in turn
# can be referenced from the status bar controls using an interpolated
# string. It updates the variable every 5 seconds.
#
# See:
# https://www.iterm2.com/documentation-scripting-fundamentals.html
# https://github.com/renier/kubectx
@renier
renier / enable-registry-on-namespace.sh
Last active Nov 11, 2019
Enable registry access in non-default IKS namespaces
View enable-registry-on-namespace.sh
ns=$1
for country in '' $(ibmcloud ks supported-locations --json | jq -r '.[] | select(.country != null) | .country' | sort | uniq); do
[ -n "$country" ] && country="${country}-"
kubectl get secret default-${country}icr-io -o yaml | sed -e "s/default/$ns/g" | kubectl -n $ns create -f -
done
kubectl patch -n $ns serviceaccount/default -p "{\"imagePullSecrets\":[{\"name\": \"${ns}-icr-io\"}]}"
for country in $(ibmcloud ks supported-locations --json | jq -r '.[]' | select(.country != null) | .country); do
kubectl patch -n $ns serviceaccount/default --type='json' -p="[{\"op\":\"add\",\"path\":\"/imagePullSecrets/-\",\"value\":{\"name\":\"${ns}-${country}-icr-io\"}}]"
done
@renier
renier / search_and_cmd.sh
Created Aug 16, 2019
Execute commands on all found files even if they have spaces and quotes in their names
View search_and_cmd.sh
while read f; do
$(cmd) -- "${f}"
done < <(find . -name "*.ext" -print0 | xargs -0 -n1 grep -Hsl "foobar")
@renier
renier / certmanager-to-pagerduty.js
Last active Oct 29, 2018
OpenWhisk action to take the web hook from IBM Cert Manager and send it to Pager Duty
View certmanager-to-pagerduty.js
const crypto = require('crypto');
const https = require('https');
function main(params) {
// Decode JWT data
let data = params.data, header, payload, signature,
pubKey = new Buffer(params.public_key, 'base64').toString('utf8');
[header, payload, signature] = data.split('.');
// Verify signature
@renier
renier / fast_harden_ubuntu.sh
Last active Feb 24, 2019
Fast Harden Ubuntu
View fast_harden_ubuntu.sh
#!/bin/bash
apt-get install ufw -y
apt-get install denyhosts -y
# Configure firewall
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw --force enable
@renier
renier / gowo.sh
Last active Mar 16, 2018
gowo - Go workspace switcher
View gowo.sh
# Usage: gowo my_go_workspace
# Will set GOPATH and update PATH with the bin dir. Will remove previous GOPATH bin dir from the PATH.
# Opinionated about the root dir where Go workspaces go. Change if you want.
# Put this in your ~/.bash_profile
export GOPATH=$HOME/Projects/go
export PATH=$PATH:$GOPATH/bin
function gowo() {
@renier
renier / gen_cert.sh
Created Oct 30, 2016
Generate an SSL certificate
View gen_cert.sh
#!/bin/bash
DOMAIN=$(hostname -f)
export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo)
subj="
C=$1
ST=$2
O=$3
localityName=$4
commonName=$DOMAIN
organizationalUnitName=$5
@renier
renier / super_harden_ubuntu.sh
Last active Feb 10, 2019
Super Harden Ubuntu
View super_harden_ubuntu.sh
#!/bin/bash
# https://developer.ibm.com/answers/questions/462237/error-groot-must-be-grub-root-device-on-ubuntu/
sed -i -e 's/LABEL=cloudimg-rootfs/(hd0)/' /boot/grub/menu.lst
apt-get update > /dev/null
apt-get install unattended-upgrades -y
timeout 20m unattended-upgrade
apt-get autoremove -y
apt-get autoclean -y
View harden_ubuntu.sh
#!/bin/bash
apt-get update
apt-get upgrade -y
apt-get autoremove -y
apt-get autoclean -y
apt-get install ufw -y
apt-get install denyhosts -y
# Configure firewall
@renier
renier / norequiretty.sh
Last active Aug 29, 2015
No requiretty
View norequiretty.sh
sed -i -e 's/ requiretty/ !requiretty/' /etc/sudoers
You can’t perform that action at this time.