Skip to content

Instantly share code, notes, and snippets.

View smoonlee's full-sized avatar
🏠
Working from home

Simon Lee smoonlee

🏠
Working from home
View GitHub Profile
@smoonlee
smoonlee / share-buttons.html
Created December 4, 2024 18:22
Hugo Social Media Share Buttons
{{/* Made using https://sharingbuttons.io/ */}}
{{ if not .Params.disableShare }}
{{ if (not (isset .Site.Params.ShareButtons "size")) }}
{{ errorf "'size' should be specified inside shareButtons in hugo config file" }}
{{ end }}
{{ $possibleSizes := (slice "small" "medium" "large") }}
{{ if not (in $possibleSizes .Site.Params.ShareButtons.Size) }}
{{ errorf "'size' is %q but should be set to one of possible sizes: %q " .Site.Params.ShareButtons.Size (delimit $possibleSizes ", ") }}
@smoonlee
smoonlee / azure-shortcode-location.ps1
Created October 21, 2024 08:15
Pwsh locationShortCode switch
# Azure Location ShortCode Switch
switch ($location) {
'eastus' { $locationShortCode = 'eus' }
'eastus2' { $locationShortCode = 'eus2' }
'westus' { $locationShortCode = 'wus' }
'westus2' { $locationShortCode = 'wus2' }
'northcentralus' { $locationShortCode = 'ncus' }
'southcentralus' { $locationShortCode = 'scus' }
'centralus' { $locationShortCode = 'cus' }
'canadacentral' { $locationShortCode = 'cc' }
@smoonlee
smoonlee / action-install-hugo-windows.yaml
Created October 6, 2024 10:55
Download and install Hugo.Extended (Windows)
name: Hugo Check and Install (Windows)
on:
push:
branches:
- main
workflow_dispatch:
# Uncomment the following lines if you want to add pull request triggers
# pull_request:
# types: [opened, synchronize, reopened, closed]
@smoonlee
smoonlee / action-install-hugo-linux.yaml
Created October 6, 2024 10:55
Download and install Hugo.Extended (Linux)
name: Hugo Check and Install (Linux)
on:
push:
branches:
- main
workflow_dispatch:
# Uncomment the following lines if you want to add pull request triggers
# pull_request:
# types: [opened, synchronize, reopened, closed]
$wc = New-Object net.webclient
$wc.Downloadfile($video_url, $local_video_url)
function Get-UsableAddressSpace {
param (
[Parameter(Mandatory = $true)]
[string]$CIDR
)
# Function to convert IP address to integer
function ConvertTo-Int {
param ($ip)
$i = 0
@smoonlee
smoonlee / Get-AzSystemUptime
Last active May 6, 2024 20:09
Get Uptime for Linux and Windows machines in Azure
# Function - Get Azure Virtual Machine System Uptime
function Get-AzSystemUptime {
param (
[string] $subscriptionId,
[string] $resourceGroup,
[string] $vmName
)
if ($subscriptionId) {
Set-AzContext -SubscriptionId $subscriptionId | Out-Null
@smoonlee
smoonlee / ubuntu-linux-virtual-installer.sh
Created March 29, 2024 16:58
Hyper-V Ubuntu Virtual Kernel Setup script
#!/bin/bash
# Microsoft Hyper-V Intergration Services (Ubuntu/Debian Install Script)
# Author: Simon Lee
# Script Revision: 1.0
# Description: Install linux-virtual kernal for Ubuntu/Debian Server
# Clear Current Screen
clear
# Check Session Status
@smoonlee
smoonlee / gist:802b38d57f04f9d316ea9f5cc7c83fa3
Created March 26, 2024 18:18
Convert REG_BINARY to Human
# Get the value of a REG_BINARY from the registry
$value = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Path\To\Your\Key" -Name "ValueName"
# Convert the REG_BINARY value to a readable format
$readableValue = [System.BitConverter]::ToString($value.ValueName)
# Display the readable format
Write-Output $readableValue
# AutoBuild Operating System Installation
if ($autoBuild) {
Write-Output `r "ABC :: AutoBuild is enabled, Applying Operating System Image..." `r
Write-Output "ABC :: Checking AutoBuild Configuration..." `r
Write-Output "ABC :: VM Generation: [$hvGeneration]"
Write-Output "ABC :: Iso Path: [$isoPath]"
# Mount OS Disk
Write-Output `r "ABC :: Mounting OS Disk"
$osDiskContext = Mount-VHD -Path $osDiskPath | Out-Null