Skip to content

Instantly share code, notes, and snippets.

View jhanley-com's full-sized avatar

John J. Hanley jhanley-com

View GitHub Profile
@jhanley-com
jhanley-com / main.tf
Created November 29, 2023 21:33
Civo Terraform: Create Firewall and Rules to Allow Traffic From Home
terraform {
required_providers {
civo = {
source = "civo/civo"
version = "~>1.0.39"
}
}
}
provider "civo" {
@jhanley-com
jhanley-com / create_firewall_allow_from_home.bat
Last active November 29, 2023 20:49
Civo CLI (Windows): Create Firewall and Rules to Allow Traffic From Home
:: This script is for Windows
:: Firewall rule name
set NAME=allow_from_home
:: update the IP address with yours
set CIDR=1.2.3.4/32
:: Create a new firewall
call civo firewall create %NAME% --create-rules=false --network=default
@jhanley-com
jhanley-com / recommender_example.py
Created June 14, 2021 23:59
Python example demonstrating the Google Cloud Compute Recommender list recommendations api
# 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'
@jhanley-com
jhanley-com / modules.php
Created April 16, 2022 02:59
Display the PHP version and loaded extensions
<?php
echo 'PHP Version: ' . phpversion() . '<br />' . PHP_EOL;
echo '<br />' . PHP_EOL;
$extensions = get_loaded_extensions();
// Case insensitive sort by value
array_multisort(array_map('strtolower', $extensions), $extensions);
foreach ($extensions as $i => $ext)
@jhanley-com
jhanley-com / ssh-copy-id.bat
Created December 15, 2021 21:30
PowerShell script to copy SSH public key to a Linux system. This is for my article on OpenSSH - https://www.jhanley.com/ubuntu-20-04-desktop-installing-and-configuring-ssh/
powershell ./ssh-copy-id.ps1 %1 %2
@jhanley-com
jhanley-com / main.tf
Last active December 15, 2021 16:45
Terraform Azure Service Principal - Part 1
# Test code for the question: https://stackoverflow.com/q/65525116/8016720
# Provides configuration details for the Azure Terraform provider
provider "azurerm" {
# !!! Must include features even if empty
features {}
}
variable "appName" { default = "testAppName" }
variable "subscriptionId" { default = "" }
@jhanley-com
jhanley-com / print_jwks_public_keys.php
Created October 1, 2021 02:39
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
<?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 / composer.json
Created October 1, 2021 02:39
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
{
"require": {
"phpseclib/phpseclib": "^2.0",
}
}
@jhanley-com
jhanley-com / .gitignore
Last active September 22, 2021 03:12
Laravel .gitignore file
/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 September 20, 2021 21:12
Terraform files for my article, Azure - Lock a VM to Prevent Deletion: https://www.jhanley.com/azure-lock-a-vm-to-prevent-deletion/
##############################################################################
# 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.