Skip to content

Instantly share code, notes, and snippets.

View aduzsardi's full-sized avatar
🛠️
d(0_0)b

Alexandru Duzsardi aduzsardi

🛠️
d(0_0)b
View GitHub Profile
@aduzsardi
aduzsardi / kubectl-decode_secret
Created April 26, 2023 15:05
kubectl plugin to base64 decode secrets data
#!/bin/bash
# Install: put this in an executable file named `kubectl-decode_secret` , which is in your PATH
# Usage: kubectl decode-secret <secret-name>
#
# Note: the script is using fzf (https://github.com/junegunn/fzf) , for example if you just type `kubectl decode-secret`
# it will list the screts and you can select whichever you want
kubectl get secret $(kubectl get secret | sed 1d | fzf | awk '{ print $1 }') --template='{{ range $key, $value := .data }}{{ printf "%s: %s\n" $key ($value | base64decode) }}{{ end }}'
@aduzsardi
aduzsardi / ansible_filter_plugin.py
Created August 8, 2022 05:06
Ansible filter plugin example
#!/usr/bin/env python3
from passlib.totp import TOTP
from ansible.module_utils._text import to_text
class FilterModule(object):
def filters(self):
return {
'totpcode': self.totpcode
}
@aduzsardi
aduzsardi / docker-volumes-clean.sh
Last active January 19, 2021 10:32
Remove docker volumes that have not been used for a time
#!/bin/bash -e
### Author: Alex Duzsardi
### Twitter: @aduzsardi
### GitHub: @aduzsardi
### Keybase: @aduzsardi
### Requirements: bash, date, docker, jq
# Remove docker volumes last used more than a month ago
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@aduzsardi
aduzsardi / gist:ce194be2c7798850303ff780938a3604
Created August 21, 2020 07:21 — forked from hgross/gist:26042d052f58feeb6d1b329e8dd2dfcc
Change docker_gwbridge subnet address
## Do this on each swarm-node
# store containers attached to the bridge
$ gwbridge_users=$(docker network inspect --format '{{range $key, $val := .Containers}} {{$key}}{{end}}' docker_gwbridge | \
$ xargs -d' ' -I {} -n1 docker ps --format {{.Names}} -f id={})
# stop all containers
# if you have stacks that restart automatically, remove them via docker stack <stackName> rm
$ echo "$gwbridge_users" | xargs docker stop
$ docker network rm docker_gwbridge
$ docker network disconnect -f docker_gwbridge gateway_ingress-sbox
@aduzsardi
aduzsardi / swarm-output.json
Created August 15, 2020 18:55
docker swarm inspect infromation - json output
docker node inspect self --format '{{json .}}' | jq .
{
"ID": "misdcojgeuz8ps4v1w93apoiz",
"Version": {
"Index": 443
},
"CreatedAt": "2020-08-08T21:58:17.93412711Z",
"UpdatedAt": "2020-08-15T12:15:50.442472266Z",
"Spec": {
"Labels": {},
@aduzsardi
aduzsardi / httproxy.sh
Last active July 29, 2020 13:41
inlets bash helper function
# add this to your .bashrc
# call it with httproxy http://proxied-url.tld
httproxy() {
local bold='\e[1m' reset='\e[0m' bright='\e[37m'
local info='\e[96m' warn='\e[93m' error='\e[91m'
local helpmsg=$(cat <<HELP
${info}Usage:${reset}
${bright}${FUNCNAME[0]} <proxied-url>${reset}
@aduzsardi
aduzsardi / mask2cdr
Created April 23, 2020 14:23 — forked from RichardBronosky/mask2cdr
Convert netmask to CIDR
#!/bin/bash
# Based on https://stackoverflow.com/questions/20762575/explanation-of-convertor-of-cidr-to-netmask-in-linux-shell-netmask2cdir-and-cdir
mask2cdr ()
{
local mask=$1
# In RFC 4632 netmasks there's no "255." after a non-255 byte in the mask
local left_stripped_mask=${mask##*255.}
local len_mask=${#mask}
@aduzsardi
aduzsardi / .jdk1.8.jinfo
Created April 21, 2020 15:40 — forked from olagache/.jdk1.8.jinfo
Generate ".jdk1.8.jinfo" and "alternatives.sh" files to install java 8 using ubuntu alternatives.
alias=jdk1.8
section=non-free
jre servertool /usr/lib/jvm/jdk1.8/jre/bin/servertool
jre keytool /usr/lib/jvm/jdk1.8/jre/bin/keytool
jre java /usr/lib/jvm/jdk1.8/jre/bin/java
jre jcontrol /usr/lib/jvm/jdk1.8/jre/bin/jcontrol
jre rmid /usr/lib/jvm/jdk1.8/jre/bin/rmid
jre ControlPanel /usr/lib/jvm/jdk1.8/jre/bin/ControlPanel
jre rmiregistry /usr/lib/jvm/jdk1.8/jre/bin/rmiregistry
jre orbd /usr/lib/jvm/jdk1.8/jre/bin/orbd
#!/bin/bash
nginxver=`apt show nginx-full |grep Version | awk '{print $2}' |awk -F '-' '{print $1}'`
nginxname=nginx-$nginxver.tar.gz
nginxdir=nginx-$nginxver
#apt -y install libmaxminddb0 libmaxminddb-dev mmdb-bin
if [ -f "$nginxname" ]