Skip to content

Instantly share code, notes, and snippets.

View jmvrbanac's full-sized avatar

John Vrbanac jmvrbanac

View GitHub Profile
@jmvrbanac
jmvrbanac / check_hsts.py
Last active April 24, 2026 18:41
Check HSTS Across a set of websites
#!/usr/bin/env python3
# Copyright (c) 2026 John Vrbanac <john.vrbanac@linux.com>
# Licensed under the MIT License. See LICENSE for details.
"""Check HSTS (HTTP Strict Transport Security) configuration for a website."""
import sys
import urllib.request
import urllib.error
from dataclasses import dataclass, field
from urllib.parse import urlparse
@jmvrbanac
jmvrbanac / generate_compliance_report.sh
Created February 23, 2026 18:09
Application Change Report Generator for Compliance
#!/usr/bin/env bash
#
# Compliance Git Change List Generator
#
# Generates an auditable git change log over a specified date range,
# with a timestamp fetched live from the US government time source (time.gov).
#
# Output file: {control_number}_{project_name}_YYYY-MM-DD-YYYY-MM-DD.txt
#
# Author : John Vrbanac <john.vrbanac@linux.com>
@jmvrbanac
jmvrbanac / gunicorn_options.yml
Last active August 26, 2023 18:13
Capture Client Certificate CN from Gunicorn
bind: 0.0.0.0:8000
workers: 1
worker_class: "example.worker:CustomWorker"
timeout: 30
ca_certs: ca.crt
certfile: server.crt
keyfile: server.key
cert_reqs: 2
do_handshake_on_connect: true
@jmvrbanac
jmvrbanac / install_pyenv.sh
Last active February 16, 2023 09:29
Install pyenv on Ubuntu
#!/bin/bash
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl
sudo pip install virtualenvwrapper
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
@jmvrbanac
jmvrbanac / app.py
Created February 18, 2016 01:05
Using Jinja2 with Falcon
import os
import falcon
import jinja2
def load_template(name):
path = os.path.join('templates', name)
with open(os.path.abspath(path), 'r') as fp:
return jinja2.Template(fp.read())
@jmvrbanac
jmvrbanac / gist:7920633
Created December 11, 2013 23:42
Using pyenv virtualenvs in a Jenkins Job
#!/bin/bash
set +x
# Setup all of the pyenvs
export PATH="$HOME/.pyenv/bin:$PATH"
export CONFIGURE_OPTS='--enable-shared'
eval "$(pyenv init -)"
pyenv shell 2.7.5
pyenv virtualenvwrapper
pyenv rehash
@jmvrbanac
jmvrbanac / unused.py
Created January 20, 2020 22:22
Get Unused Port
def get_unused_port():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 0))
_, port = sock.getsockname()
sock.close()
return port
This is the baseline
@jmvrbanac
jmvrbanac / meinheld_gunicorn.py
Created January 22, 2019 02:40
Custom Gunicorn App that supports both meinheld and sync
from gunicorn.app.base import BaseApplication
from gunicorn.workers.sync import SyncWorker
from meinheld.gmeinheld import MeinheldWorker
class CustomWorker(object):
def handle_quit(self, sig, frame):
self.app.application.stop(sig)
super().handle_quit(sig, frame)
@jmvrbanac
jmvrbanac / version.sh
Created April 12, 2018 22:23
Adding git log to bumpversion tag commits
#!/bin/bash
export MESSAGE=$(echo -e "\n\n$(git log `git describe --tags --abbrev=0`..HEAD --oneline)")
bumpversion \
--message 'Bump version: {current_version} → {new_version}{$MESSAGE}' \
${@:1}