Skip to content

Instantly share code, notes, and snippets.

Petr Michalec epcim

View GitHub Profile
@epcim
epcim / brew_install_coreutils.sh
Created Nov 13, 2015
OSX brew install GNU coreutils, bin utils etc...
View brew_install_coreutils.sh
# From https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
export PATH="$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH"
brew install coreutils
brew install gnu-tar --with-default-names
# alternatively
brew install binutils
brew install diffutils
@epcim
epcim / get-pods.sh
Last active Apr 11, 2019
kubectl kubernetes alias bash cli
View get-pods.sh
# you can't live without 'k' and 'p'
# kubectl alias
alias k='kubectl'
# kubectl get pods alias
## store Kubernetes pod name & namespace to env variable
## expect servername has number behind last -
[[ -z $ZSH_NAME ]] || setopt SH_WORD_SPLIT
function get-pods() {
@epcim
epcim / yg.sh
Last active Mar 29, 2019
#salt #reclass parser - works as jq for yaml files, used to traverse all paths in #Salt reclass and find/grep tree paterns
View yg.sh
#!/bin/bash
# tl;dr
# yaml-grep; to extract partial branches based on the 'jq' regex pattern.
# install:
# wget https://gist.githubusercontent.com/epcim/f1c5b748fa7c942de50677aef04f29f8/raw/yg.sh -O yg; chmod +x yg
# usage:
# ./yg '.compute?.network'
#
View osx_gnu_shell_experience.sh
# keep you $SHELL as osx bash
# modify your term/iterm2/kitty to start your preffered shell (I do zsh, you can start "up to date" bash from `brew`)
# gnu cmd links without "g" preffixed
mkdir ~/bin-osxoverride
for i in $(ls /usr/local/bin/g*) ;do N=$(basename ${i/g//}); ln -sf $i ~/bin-osxoverride/$N; done
# update your path
echo "export PATH=~/bin-osxoverride:$PATH" >> ~/.zshrc
@epcim
epcim / kubectl.sh
Created Mar 29, 2019
kubernetes k8s kubectl
View kubectl.sh
# p cmd pritns pods in cluster &&
# store Kubernetes pod name & namespace to env variable
[[ -z $ZSH_NAME ]] || setopt SH_WORD_SPLIT
function p() {
eval $(kubectl get po --all-namespaces -L app -o wide | tee /dev/stderr|awk '{gsub(/.*-/,"",$8);gsub(/-/,"",$10);printf "%s%s=\x27-n %s %s\x27\n", $10,$8, $1, $2}'|grep -v "^=");
}
p
k logs $fluentbit1
View acl_permissions.sh
#!/bin/bash
if [ $# -lt 2 -o $# -gt 3 ]; then
echo
echo 'Please provide 2 or 3 arguments.'
echo
echo 'USAGE: permissions.sh action username directory'
echo 'actions: grant, revoke-app, revoke-all'
echo 'eg: permissions.sh grant joe $HOME/webapps/django'
echo
@epcim
epcim / update-ca-certificates.md
Last active Mar 15, 2019
trusted certificates system update-ca-certificates
View update-ca-certificates.md

Adding trusted root certificates to the server

Mac OS X

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/new-root-certificate.crt
sudo security delete-certificate -c "<name of existing certificate>"

Windows

certutil -addstore -f "ROOT" new-root-certificate.crt
@epcim
epcim / github.sh
Created Mar 14, 2019
github hub pull-request cli
View github.sh
# hub tool
brew install hub
# push PR without web-browser forking the repo
GIT_USER=epcim
alias github-pull-request="hub fork;git push -u $GIT_USER HEAD;hub pull-request"
@epcim
epcim / gist:eac5083ae1ea5e8dc0e862d9dfa28fbd
Created Mar 12, 2019 — forked from mattm7n/gist:1405067
Monitor DHCP traffic with tcpdump
View gist:eac5083ae1ea5e8dc0e862d9dfa28fbd
# Monitoring on interface eth0
tcpdump -i eth0 -n port 67 and port 68
You can’t perform that action at this time.