Skip to content

Instantly share code, notes, and snippets.

View bodsch's full-sized avatar

Bodo Schulz bodsch

View GitHub Profile
@bodsch
bodsch / mass-aggregation-change.sh
Created January 26, 2018 15:07 — forked from kirbysayshi/mass-aggregation-change.sh
quick examples of how to change many many wsp (graphite/whisper) files settings
for f in $(find $1 -iname "*.wsp"); do
if [ -a $f ];
then /opt/graphite/bin/whisper-set-aggregation-method.py $f max;
fi;
done
@bodsch
bodsch / git-tag-delete-local-and-remote.sh
Created March 23, 2018 14:16 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@bodsch
bodsch / whisper-calculator.py
Created April 17, 2018 14:59 — forked from jjmaestro/whisper-calculator.py
whisper-calculator.py: Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
@bodsch
bodsch / bash_sockets.sh
Created April 19, 2018 07:52 — forked from CMCDragonkai/bash_sockets.sh
Bash: Socket Programming (Alternative to using Netcat)
#!/usr/bin/env bash
# consider if the server is passing a file like
while true; do nc -l 10000 <<<"hi"; done
# on our client side, we can consume this using nc
nc 10.0.0.1 10000
@bodsch
bodsch / find-duplicate-files.bash
Last active February 8, 2019 20:39 — forked from OndraZizka/find-duplicate-files.bash
Finds duplicate files. An alternative to `fdupes -r -S .`
find -type f -size +3M -print0 | while IFS= read -r -d '' i; do
#echo $i
echo -n '.'
if grep -q "$i" md5-partial.txt; then
echo -n ':'; #-e "\n$i ---- Already counted, skipping.";
continue;
fi
#md5sum "$i" >> md5.txt
MD5=`dd bs=1M count=1 if="$i" status=none | md5sum`
MD5=`echo $MD5 | cut -d' ' -f1`
@bodsch
bodsch / vercomp
Last active May 29, 2018 13:45
compare two strings in dot separated version format in Bash
#!/bin/bash
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
vercomp() {
[[ $1 == $2 ]] && return 0
v1=$(echo "$1" | sed -e 's|-|.|g')
v2=$(echo "$2" | sed -e 's|-|.|g')
local IFS=.
@bodsch
bodsch / get_latest_release.sh
Created June 1, 2018 20:56 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@bodsch
bodsch / replacement for netcat
Created August 10, 2018 15:59
replacement for netcat
# now wait for ssh port
RETRY=20
until [[ ${RETRY} -le 0 ]]
do
timeout 1 bash -c "cat < /dev/null > /dev/tcp/${VM_NAME}.${VM_DOMAIN}/22" 2> /dev/null
if [ $? -eq 0 ]
then
break
else
sleep 20s
@bodsch
bodsch / gist:4ea55240d7c4b0706d8504eba6b975fc
Last active November 10, 2018 10:26
install icingaweb2-module-vspheredb in alpine
apk add php7-phar php7-sockets php7-pcntl
cd /usr/bin/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
ln -s composer.phar composer
cd /usr/share/webapps/icingaweb2-2.6.1/modules/vspheredb/
@bodsch
bodsch / ansible-vault.md
Created January 30, 2019 16:55 — forked from hvanderlaan/ansible-vault.md
Ansible-vault example

Ansible vault example

New in Ansible 1.5, “Vault” is a feature of ansible that allows keeping sensitive data such as passwords or keys in encrypted files, rather than as plaintext in your playbooks or roles. These vault files can then be distributed or placed in source control. To enable this feature, a command line tool, ansible-vault is used to edit files, and a command line flag –ask-vault-pass or –vault-password-file is used. Alternately, you may specify the location of a password file or command Ansible to always prompt for the password in your ansible.cfg file. These options require no command line flag usage.

Requirements