Skip to content

Instantly share code, notes, and snippets.

Avatar

John J. Hanley jhanley-com

View GitHub Profile
@jhanley-com
jhanley-com / composer.json
Created Oct 1, 2021
This program prints the Microsoft JSON Web Key Set (JWKS) certificate and public keys. Also demonstrated is two methods to create a public key from the information provided by the JWKS data. For details see my article on Azure Open ID Connect JSON Web Key Set - http://www.jhanley.com/azure-openid-connect-json-web-key-set
View composer.json
{
"require": {
"phpseclib/phpseclib": "^2.0",
}
}
@jhanley-com
jhanley-com / print_jwks_public_keys.php
Created Oct 1, 2021
This program prints the Microsoft JSON Web Key Set (JWKS) certificate and public keys. Also demonstrated is two methods to create a public key from the information provided by the JWKS data. For details see my article on Azure Open ID Connect JSON Web Key Set - http://www.jhanley.com/azure-openid-connect-json-web-key-set
View print_jwks_public_keys.php
<?php
/*****************************************************************************
* Date Created: 2021-09-30
* Last Update: 2021-09-30
* https://www.jhanley.com - Google Cloud
* Copyright (c) 2021, John J. Hanley
* Author: John J. Hanley
* License: MIT
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@jhanley-com
jhanley-com / .gitignore
Last active Sep 22, 2021
Laravel .gitignore file
View .gitignore
/node_modules
/public/blog
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
@jhanley-com
jhanley-com / main.tf
Last active Sep 20, 2021
Terraform files for my article, Azure - Lock a VM to Prevent Deletion: https://www.jhanley.com/azure-lock-a-vm-to-prevent-deletion/
View main.tf
##############################################################################
# Date Created: 2021-09-17
# Last Update: 2021-09-17
# https://www.jhanley.com - Google Cloud
# Copyright (c) 2021, John J. Hanley
# Author: John J. Hanley
# License: MIT
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@jhanley-com
jhanley-com / is_object_public.py
Created Aug 10, 2021
The following example first processes a bucket. If uniform access is not enabled then the object is processed. If public access enabled on the bucket or the object, the object is Public. Refer to https://stackoverflow.com/questions/68722565/how-to-check-if-a-file-in-gcp-storage-is-public-or-not
View is_object_public.py
import sys
from google.cloud import storage
# Replace with valid bucket and object names
bucket_name = 'example_bucket_name'
object_name = 'example_object_name'
# Instantiates a client
storage_client = storage.Client()
View simple_gist.txt
This is a simple GitHub Gist.
This is line 2.
@jhanley-com
jhanley-com / recommender_example.py
Created Jun 14, 2021
Python example demonstrating the Google Cloud Compute Recommender list recommendations api
View recommender_example.py
# pip install google-cloud-recommender
from google.cloud import recommender
import os
# Enter values for your Project ID and Zone
PROJECT=
LOCATION=
RECOMMENDER = 'google.compute.instance.MachineTypeRecommender'
View main.tf
# This script is used in my article about Terraform, Google Cloud DNS and Cloud IAM.
# https://www.jhanley.com/terraform-experiments-with-google-cloud-dns-and-iam/
######################################################################
# Terraform
######################################################################
terraform {
required_version = ">= 0.14.7"
}
@jhanley-com
jhanley-com / tclean.bat
Created Mar 7, 2021
Windows batch script to cleanup a Terraform project
View tclean.bat
IF exist .terraform (rd /s /q .terraform)
IF exist terraform.tfstate.d (rd /s /q terraform.tfstate.d)
IF exist .terraform.lock.hcl (del .terraform.lock.hcl)
IF exist terraform.tfstate (del terraform.tfstate)
IF exist terraform.tfstate.backup (del terraform.tfstate.backup)
@jhanley-com
jhanley-com / main.tf
Last active Jan 6, 2021
Terraform Azure Service Principal - Part 2
View main.tf
# Test code for the question: https://stackoverflow.com/q/65525116/8016720
# Provides configuration details for Terraform
terraform {
required_version = ">= 0.14.3, < 0.15.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>2.41"