Skip to content

Instantly share code, notes, and snippets.

View bodsch's full-sized avatar

Bodo Schulz bodsch

View GitHub Profile
@bodsch
bodsch / gist:e02534f6417b44d80a05c41dd225023a
Created May 10, 2017 13:40 — forked from brandonrich/gist:67c0ae24b5abfef65134
Ruby AWS SDK v2 IAM user MFA example
# shows how to use the Ruby AWS SDK to list EC2 instance IDs
# when your API credentials have been placed under MFA requirements
# Prerequisites:
# you are running on a host that already has the AWS CLI set up with an IAM key pair
# that can describe EC2 instances (OTHERWISE, just pass a
# secret_access_id / secret_access_key pair to the STS client initializer)
# You have installed the Ruby AWS SDK Gem
# http://aws.amazon.com/sdk-for-ruby/
@bodsch
bodsch / cirqle_queue_and_fifo.rb
Created December 11, 2017 13:16 — forked from prepor/cirqle_queue_and_fifo.rb
Simple ruby implementation of Cirqle Queue and FIFO
class CircleQueue
include Enumerable
class Head
attr_accessor :first, :last
def initialize
self.first = self
self.last = self
end
@bodsch
bodsch / dns_check.rb
Created January 21, 2018 09:33 — forked from colszowka/dns_check.rb
Ruby DNS Check
require 'resolv'
class DnsCheck
attr_reader :host
def initialize(host)
@host = host
end
def a
@a ||= Resolv::DNS.new.getresources(host, Resolv::DNS::Resource::IN::A)
@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 / 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 / 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