Skip to content

Instantly share code, notes, and snippets.

View jonchampagne's full-sized avatar

Jon Champagne jonchampagne

  • Waterloo, Ontario, Canada
View GitHub Profile
@jonchampagne
jonchampagne / Stop-VMGuestAndWait.ps1
Created April 29, 2022 14:03
PowerCLI: Shut down a virtual machine, and wait for it to be fully shut down.
function Stop-VMGuestAndWait {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)][String]$VMName
)
Stop-VMGuest $VMName -Confirm:$false
do {
Start-Sleep -Seconds 1
$VMStatus = (Get-VM $VMName).PowerState
} while ($VMStatus -ne "PoweredOff")
#!/usr/bin/env python3
# Loops through all the zfs datasets in a system, and dumps their properties into JSON
import subprocess
import json
def get_zfs_property(prop, pool):
process = subprocess.Popen(['zfs', 'get', '-H', '-o', 'value', '-p', prop, pool],
stdout=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
stdout, stderr = process.communicate()
@jonchampagne
jonchampagne / rclone-mount@.service
Created December 11, 2019 20:21
rclone-mount@.service
[Unit]
Description=Mount %i
#AssertPathIsDirectory=%h/%i
#After=network.service # Not sure if this is needed
[Service]
Type=simple
ExecStartPre=/usr/bin/mkdir -p %h/%i
ExecStart=/usr/bin/rclone mount \
--config=%h/.config/rclone/rclone.conf \
@jonchampagne
jonchampagne / Get-ADMembershipRecursive.ps1
Created October 13, 2019 13:59
Recursively get all groups an active directory user or group is a part of
function Get-ADMembershipRecursive($name){
$names = [System.Collections.ArrayList]@()
Get-ADPrincipalGroupMembership -Identity $name | ForEach-Object {
$names.Add($_.Name) | Out-Null
Get-MembershipRecursive -name $_ | ForEach-Object {
$names.Add($_) | Out-Null
}
}
return $names
}
@jonchampagne
jonchampagne / conestoga.desire2learn.com.txt
Last active September 4, 2019 16:13
Darkreader Additions
================================
conestoga.desire2learn.com
INVERT
.course-text
.carousel-item-text
.d2l-input-search-container
.d2l-input
.d2l-dropdown-menu-contextmenu
@jonchampagne
jonchampagne / wsudo.sh
Created May 19, 2018 15:30
Wayland sudo
#!/bin/bash
if [ -n $XDG_SESSION_TYPE ] && [[ $XDG_SESSION_TYPE == "wayland" ]]
then
xhost +SI:localuser:root
/sbin/sudo $@
xhost -SI:localuser:root
xhost
else
/sbin/sudo $@
fi
for i in Pop-dark Pop-dark-slim Pop-slim Pop-light-slim do
cp org.gtk.Gtk3theme.Pop-light org.gtk.Gtk3theme.$i -r
sed -i 's/Pop-light/'$i'/g' org.gtk.Gtk3theme.$i/org.gtk.Gtk3theme.Pop-light.appdata.xml
sed -i 's/Pop-light/'$i'/g' org.gtk.Gtk3theme.$i/org.gtk.Gtk3theme.Pop-light.json
mv org.gtk.Gtk3theme.$i/org.gtk.Gtk3theme.Pop-light.appdata.xml org.gtk.Gtk3theme.$i/org.gtk.Gtk3theme.$i.appdata.xml
mv org.gtk.Gtk3theme.$i/org.gtk.Gtk3theme.Pop-light.json org.gtk.Gtk3theme.$i/org.gtk.Gtk3theme.$i.json
cd org.gtk.Gtk3theme.$i
sudo flatpak-builder --repo=/var/local/flatpak/repos/local $i org.gtk.Gtk3theme.$i.json
cd ..
done