Skip to content

Instantly share code, notes, and snippets.

View nexus166's full-sized avatar
🌪️
🐧

nexus166

🌪️
🐧
  • Earth
View GitHub Profile
#!/bin/sh
COUNTRY="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
if [ -z "$COUNTRY" ]; then printf "\\n\\tNO COUNTRY CODE SPECIFIED\\n\\n" && exit 1; fi
IPSET_SET="${COUNTRY}-subnets"
IPSET="$(command -v ipset || exit 1)"
printf "\\n\\tPREPARING IPSET SET\\t\\t\\t[%s]" "$IPSET_SET" && \
"$IPSET" flush "$IPSET_SET" || "$IPSET" create "$IPSET_SET" hash:net && \
printf "\\n\\tDOWNLOADING AND IMPORTING SUBNETS.." && \
curl -s -o- "http://www.ipdeny.com/ipblocks/data/countries/$COUNTRY.zone" | \
grep -Eo '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+/[0-9]+' | \
@nexus166
nexus166 / msg
Last active March 3, 2019 16:55
sexy logging for shell scripts
#!/bin/sh
msg()
{
tstamp()
{
tput setaf 7;
date "+%d.%m.%Y %T.%N %Z";
tput sgr0
};
@nexus166
nexus166 / golang-tls.md
Last active March 9, 2019 19:51 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
#!/bin/sh
# add this function to your env and then import other scripts with:
# eval "$(ghload gist nexus166/msg 581472463579c73e15aa71e6db610cb7)"
ghload() {
MOD_TYPE=${1}; TOLOAD=${2}; MODULE=${3};
GH_NAME="$(echo ${TOLOAD} | cut -d'/' -f1)"; GH_REPO="$(echo $TOLOAD | cut -d'/' -f2)";
ghGISTS="https://gist.github.com"; ghREPOS="https://raw.githubusercontent.com";
_man() { printf "Usage:\\n\\t\$> ghload gist nexus166/msg 581472463579c73e15aa71e6db610cb7\n\\t\$> ghload repo Spajderix/barc README.md\\n"; };
@nexus166
nexus166 / web-servers.md
Created March 16, 2019 15:19 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@nexus166
nexus166 / flask-auth_request-proxy.py
Created March 18, 2019 11:52
delegate BasicAuth to a Vault instance (ngx_http_auth_request_module)
import os
import hvac
import json
from flask import Flask, request, make_response
app = Flask(__name__, template_folder='templates')
app.config['SECRET_KEY'] = 'https:/your.vault.instance:8200/'
app.config['FLASK_ENV'] = 'production'
#!/bin/sh -e
printf "%s" "$(tr -cd '[:graph:]' < ${2:-/dev/urandom} | tr -d '\-#&\+,\.\/\:\`\"'\' | head -c${1:-32})";
#!/usr/bin/env bash

LUKSNAME=${1}
KEYPATH=${2:-"${HOME:-$(pwd)}/${LUKSNAME}.key"}
KEYSIZE=${3:-"1020000"}
FILESYSTEM=${4:-"ext4"}

set -uxo pipefail

tldr

docker plugin install rexray/s3fs \
  S3FS_OPTIONS="allow_other,use_path_request_style,nonempty,url=https://s3.my.xyz" \
  S3FS_ENDPOINT="https://s3.my.xyz" \
  3FS_ACCESSKEY="xxx" \
  3FS_SECRETKEY="yyy"
echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/unstable.list

printf 'Package: *\nPin: release a=unstable\nPin-Priority: 90\n' > /etc/apt/preferences.d/limit-unstable

wget -O - https://ftp-master.debian.org/keys/archive-key-8.asc | apt-key add -
wget -qO- https://ftp-master.debian.org/keys/archive-key-8-security.asc | apt-key add -

apt update