Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️
d(0_0)b

Alexandru Duzsardi aduzsardi

🛠️
d(0_0)b
  • @prodigy-it-solutions
  • Cluj-Napoca, Romania
  • @aduzsardi
View GitHub Profile
@aduzsardi
aduzsardi / docker-volumes-clean.sh
Last active Jan 19, 2021
Remove docker volumes that have not been used for a time
View docker-volumes-clean.sh
#!/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
View samizdat-shell-help.bash
#!/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.
View gist:ce194be2c7798850303ff780938a3604
## 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 Aug 15, 2020
docker swarm inspect infromation - json output
View swarm-output.json
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 Jul 29, 2020
inlets bash helper function
View httproxy.sh
# 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 Apr 23, 2020 — forked from RichardBronosky/mask2cdr
Convert netmask to CIDR
View mask2cdr
#!/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 Apr 21, 2020 — forked from olagache/.jdk1.8.jinfo
Generate ".jdk1.8.jinfo" and "alternatives.sh" files to install java 8 using ubuntu alternatives.
View .jdk1.8.jinfo
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
View build-nginx-geoip2-deb.sh
#!/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" ]
@aduzsardi
aduzsardi / nginx.conf
Created Apr 1, 2020 — forked from amitsaha/nginx.conf
nginx conf + geoip2
View nginx.conf
# blog post: https://echorand.me/nginx-and-geoip2.html
worker_processes auto;
daemon off;
error_log /dev/stdout warn;
include /etc/nginx/modules/*.conf;
load_module modules/ngx_http_geoip2_module.so;
events {
}
@aduzsardi
aduzsardi / letsencrypt_2017.md
Created Mar 17, 2020 — forked from leeoniya/letsencrypt_2017.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)
View letsencrypt_2017.md

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.