Skip to content

Instantly share code, notes, and snippets.

View mrhockeymonkey's full-sized avatar
😀
Making my own x-plat app with Flutter

Scott Matthews mrhockeymonkey

😀
Making my own x-plat app with Flutter
View GitHub Profile
@mrhockeymonkey
mrhockeymonkey / openssl-example.ps1
Last active March 16, 2024 02:11
OpenSSL Example Usages
# example creating certs for use with docker swarm
$openssl = 'C:\Program Files (x86)\OpenSSL\1.0.1L\bin\openssl.exe'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
$CN = "some-cert-name"
$Fqdn = "computer1.com"
# create a CA
& $openssl genrsa -aes256 -out ca-key.pem 4096
& $openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem -subj "/CN=$CN"
@mrhockeymonkey
mrhockeymonkey / verify_certificate.py
Last active March 16, 2024 02:11
Verify certificates with Python
from base64 import b64decode
from OpenSSL import crypto
def verify_chain_of_trust(certificate, trusted_cert_pems):
# Create and fill a X509Sore with trusted certs
store = crypto.X509Store()
for trusted_cert_pem in trusted_cert_pems:
trusted_cert = crypto.load_certificate(crypto.FILETYPE_PEM, trusted_cert_pem)
store.add_cert(trusted_cert)
@mrhockeymonkey
mrhockeymonkey / dynamic-dynamic-params.ps1
Created February 12, 2020 09:38
Dynamically define dynamic parameters for Powershell functions
function Verb-Noun {
[CmdletBinding()]
param (
# a normal parameter
[Parameter(ValueFromPipeline = $true)]
[System.String]$Name,
)
dynamicparam {
# a simple dynamic parameter, $PossibleCategories is discovered on module import
$DynamicParams = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
PS D:\fluffy-basson> docker network ls
NETWORK ID NAME DRIVER SCOPE
tsrtjyvcnda9 dsc_net overlay swarm
kecsl0ygqz7v ingress overlay swarm
250269d47835 nat nat local
262286df0819 none null local
PS D:\fluffy-basson> docker inspect dsc_net
[
#!groovy
pipeline {
agent any
stages {
stage ("check") {
when {
branch 'master'
}
steps {
@mrhockeymonkey
mrhockeymonkey / github-release.py
Created July 10, 2018 10:57
Automating GitHub Releases
from __future__ import print_function
import json
import os
from optparse import OptionParser
import requests
import sys
import pprint
import logging as log
__author__ = 'ravi, scottm' #http://javawithravi.com/automating-github-releases-via-jenkins/
@mrhockeymonkey
mrhockeymonkey / TerraformTrace.log
Created July 4, 2018 13:07
Trace log for Terraform issue
2018/07/04 13:50:53 [INFO] Terraform version: 0.11.7 41e50bd32a8825a84535e353c3674af8ce799161
2018/07/04 13:50:53 [INFO] Go runtime version: go1.10.1
2018/07/04 13:50:53 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2018/07/04 13:50:53 [DEBUG] Attempting to open CLI config file: /home/scott/.terraformrc
2018/07/04 13:50:53 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/07/04 13:50:53 [INFO] CLI command args: []string{"apply"}
2018/07/04 13:50:53 [INFO] command: empty terraform config, returning nil
2018/07/04 13:50:53 [DEBUG] command: no data state file found for backend config
2018/07/04 13:50:53 [DEBUG] New state was assigned lineage "73e74daa-be08-bfcc-39ed-cb987529f8fc"
2018/07/04 13:50:53 [INFO] command: backend initialized: <nil>
@mrhockeymonkey
mrhockeymonkey / InvokeSqlQuery-Legacy.ps1
Last active June 30, 2018 15:37
Invoke SQL queries the old way
# This is the old way I used to invoke sql queries.
# A better way now would be to use the SqlServer module and Invoke-SqlCommand
$tsqlQuery = @"
Select AccountName
From SUSDB.dbo.tbDownstreamServerTarget
"@
Try {
$conn.Open()
}
Catch {
@mrhockeymonkey
mrhockeymonkey / Jenkins-GitDiff.groovy
Last active March 16, 2024 02:11
Jenkins: git diff in pipeline to discover modified files
#!groovy
// https://medium.com/rocket-travel-engineering/running-advanced-git-commands-in-a-declarative-multibranch-jenkinsfile-e82b075dbc53
// Jenkins only checks out the branch for performance reasons so to be able to do more advanced git commands we need to
// also fetch master (or anything else you need)
pipeline {
agent any
stages {
stage ("info") {
when {
@mrhockeymonkey
mrhockeymonkey / Write-PSBoundParams.ps1
Created May 22, 2018 15:19
Show PSBoundParameter Values
$PSBoundParameters.GetEnumerator() |
ForEach-Object -Begin {
$Width = $PSBoundParameters.Keys.Length | Sort-Object | Select-Object -Last 1
} -Process {
"{0,-$($Width)} : '{1}'" -f $_.Key, ($_.Value -join ', ') |
Write-Verbose
}