Skip to content

Instantly share code, notes, and snippets.

@mbentley
mbentley / pystone.py
Created January 27, 2023 11:13
Pystone 1.3 - Update to address removal of clock
#! /usr/bin/env python3
"""
"PYSTONE" Benchmark Program
Version: Python/1.3 (corresponds to C/1.1 plus 3 Pystone fixes)
Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013.
Translated from ADA to C by Rick Richardson.
@mbentley
mbentley / omada_api.ps1
Last active February 23, 2024 18:40
Example API Calls Using Powershell and Bash/curl for Omada Controller (last validated on 5.12.7)
### PowerShell Example
# set variables
$OMADA_URL = "https://omada.example.com:8043"
$USERNAME = "admin"
$PASSWORD = "test12345"
# get controller id from the API
$CONTROLLER_ID = (Invoke-RestMethod -Uri "${OMADA_URL}/api/info" -Method Get -UseBasicParsing).result.omadacId
# set the login request body as json
@mbentley
mbentley / haproxy.conf
Last active April 22, 2024 06:22
HAProxy SNI Example
global
log /dev/log local0
log /dev/log local1 notice
defaults
log global
mode tcp
option tcplog
option dontlognull
timeout connect 5s
@mbentley
mbentley / check_cert_chain.sh
Created August 29, 2019 18:09
Verify certificate chain is complete
#!/bin/bash
set -e
# set the paths for certificates
ROOT_CERT="${HOME}/Downloads/certs/DigiCertGlobalRootCA.cer"
INTERMEDIATE_CERT="${HOME}/Downloads/certs/DigiCertSHA2SecureServerIntermediateCA.cer"
SERVER_CERT="${HOME}/Downloads/certs/dfwdtrlabawsw.ds.dtveng.net.cer"
# function to get the issuer
#!/bin/sh
IMAGE="${1:-}"
TAG="${2:-}"
if [ -z "${IMAGE}" ]
then
echo "Missing IMAGE"
echo "Usage: ${0} namespace/repo tag"
exit 1
@mbentley
mbentley / validate_cert_chain.sh
Created September 12, 2018 20:13
Validate the proper certificates are present
#!/bin/bash
set -e
# set the paths for certificates
ROOT_CERT="${HOME}/Downloads/certs/DigiCertGlobalRootCA.cer"
INTERMEDIATE_CERT="${HOME}/Downloads/certs/DigiCertSHA2SecureServerIntermediateCA.cer"
SERVER_CERT="${HOME}/Downloads/certs/myservercert.cer"
# function to get the issuer
@mbentley
mbentley / haproxy.cfg
Created May 4, 2018 14:17
Example HAProxy Config
global
log /dev/log local0
log /dev/log local1 notice
defaults
log global
mode tcp
option tcplog
option dontlognull
timeout connect 5s
@mbentley
mbentley / ingress-nginx.yml
Created May 4, 2018 13:08
ingress-nginx example
apiVersion: v1
kind: Namespace
metadata:
name: ingress-nginx
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: default-http-backend
labels:
@mbentley
mbentley / gist:8adbb67b18f73c8a9de5a803d2f0ae6b
Last active April 24, 2018 12:55
Docker Content Trust with the `docker trust` command
The following commands assume that you already have a client bundle downloaded and extracted to the present working directory:
# take your public key and add your user as a signer for the repository
$ docker trust signer add --key cert.pem admin dtr.demo.dckr.org/admin/docker-whale
Adding signer "admin" to dtr.demo.dckr.org/admin/docker-whale...
Initializing signed repository for dtr.demo.dckr.org/admin/docker-whale...
Enter passphrase for root key with ID a380e3a:
Enter passphrase for new repository key with ID eceefed:
Repeat passphrase for new repository key with ID eceefed:
Successfully initialized "dtr.demo.dckr.org/admin/docker-whale"
@mbentley
mbentley / cluster_cpureservation.sh
Last active March 13, 2018 21:13
Swarm mode - Find NanoCPUs Reserved from a cluster or a single node
#!/bin/bash
# uses some poor techniques like awk + grep so it works on 17.03 and newer where formatting isn't available
# get a list of all of the nodes; loop through them
for NODE in $(docker node ls -q)
do
# reset the per node CPU resevation counter to 0
CPURES="0"