Skip to content

Instantly share code, notes, and snippets.

View pldmgg's full-sized avatar

Paul DiMaggio pldmgg

View GitHub Profile
@pldmgg
pldmgg / README.md
Created September 26, 2022 16:43 — forked from jamesramsay/README.md
Gmail: delete old emails automatically

Gmail: delete old emails automatically

Automatically deletes old emails that match the specified label.

Get started

  • Create a new Google Apps Script at https://script.google.com
  • Overwrite the placeholder with the javascript below
  • Update the following constants:
  • LABEL_TO_DELETE: the label that should be have old messages deleted
@pldmgg
pldmgg / hassio_installer.sh
Last active May 13, 2020 22:26
hassio_installer.sh
#!/usr/bin/env bash
set -e
ARCH=$(uname -m)
DOCKER_BINARY=/usr/bin/docker
DOCKER_REPO=homeassistant
DOCKER_SERVICE=docker.service
URL_VERSION="https://version.home-assistant.io/stable.json"
URL_HA="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/ha"
URL_BIN_HASSIO="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-supervisor"
@pldmgg
pldmgg / USB_Passthru_on_UnRaid_to_HassOS_VM.txt
Last active May 11, 2020 02:29
USB_Passthru_on_UnRaid_to_HassOS_VM
- A lot of credit to: https://www.labsrc.com/unraid-automatic-usb-hotplugging-libvirt/
- And also the follwing script which I modified slightly to fix some syntax errors:
https://raw.githubusercontent.com/labsrc/Libvirt-USB-Hotplugging/master/usbhotplug.sh
##### Launch the UnRaid Terminal #####
- From the UnRaid Web GUI, click the "Terminal" icon towards the upper-right of the page (it should be right below Uptime)
- All of the below commands will be run from this terminal
@pldmgg
pldmgg / UnRaid_HassOS_VM_Setup
Last active May 21, 2020 13:57
UnRaid_HassOS_VM_Setup
##### What You'll Need (assuming your workstation is Windows) #####
- Qemu For Windows: https://qemu.weilnetz.de/w64/
- WinSCP: https://winscp.net/eng/download.php
- 7zip: https://www.7-zip.org/download.html
- The VMDK virtual disk from the Home Assistant website: https://www.home-assistant.io/hassio/installation/
- Access to your UnRaid WebGUI from your Windows workstation
#### Installing Qemu On Your Windows Workstation ####
- Why? Because the virtual disk images provided by the Home Assistant website are not in a format that UnRaid can understand.
@pldmgg
pldmgg / Home_Assistant_Migration_to_HassOS_VM.txt
Last active May 19, 2020 23:43
Home_Assistant_Migration_to_HassOS_VM
##### Make a Snapshot of your existing HA implementation #####
- In the Home Assistant dashboard, navigate Supervisor -> Snapshots. Give the resulting .tar file a name, make sure "Full Snapshot" is checked, and then click "Create".
- Download the resulting snapshot .tar by clicking on it and selecting "Download"
##### Download your preferred virtual appliance containing HassOS #####
- From here (under the "As a virtual appliance" section): https://www.home-assistant.io/hassio/installation/
##### Deploy the VM #####
- How you deploy the VM depends on what hypervisor you're using, so I'm not going to cover that here.
- Whatever hypervisor you use, make sure the VM automatically starts when your host OS starts
@pldmgg
pldmgg / restore_docker_containers.sh
Created February 17, 2020 00:02
restore_docker_containers.sh
#!/bin/bash
# Reference: https://github.com/tlaanemaa/backup-docker
# Reference for starting addons via comd line: https://www.reddit.com/r/homeassistant/comments/an8lsl/how_do_you_issue_hassio_cli_commands_in_a/
# Installation of Prerequisites -
#
# sudo apt-get install npm
# sudo npm install -g backup-docker
# sudo apt-get install powershell
# cd ~
@pldmgg
pldmgg / backup_docker_containers.sh
Created February 16, 2020 23:58
backup_docker_containers.sh
#!/bin/bash
# Reference: https://github.com/tlaanemaa/backup-docker
# Reference for starting addons via comd line: https://www.reddit.com/r/homeassistant/comments/an8lsl/how_do_you_issue_hassio_cli_commands_in_a/
#
# Installation of Prerequisites
# sudo apt-get install npm
# sudo npm install -g backup-docker
# sudo apt-get install powershell
# cd ~
@pldmgg
pldmgg / Set-PSModulePath.ps1
Created January 6, 2020 17:54
Sets $env:PSModulePath Regardless of PS Version or Operating System
function Set-PSModulePath {
[CmdletBinding()]
Param ()
[System.Collections.ArrayList]$ExpectedPaths = @()
# Handles Windows PowerShell
if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq 'Desktop') {
$ExpectedModulePathA = [Environment]::GetFolderPath('MyDocuments') + "\WindowsPowerShell\Modules"
$ExpectedModulePathB = "C:\Windows\system32\WindowsPowerShell\v1.0\Modules"
@pldmgg
pldmgg / Upgrade-PowerShellCore.ps1
Last active January 25, 2021 07:23
Upgrade PowerShell Core On Windows 10 x64
function Upgrade-PowerShellCore {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[switch]$PreRelease,
[Parameter(Mandatory=$False)]
[switch]$Silent
)
@pldmgg
pldmgg / Rename-PSCustomObjectNoteProperty.ps1
Created December 1, 2019 13:17
RenamePSCustomObjectNoteProperty
function Rename-NoteProperty {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[pscustomobject]$MyObject,
[Parameter(Mandatory=$True)]
[String]$ExistingPropertyName,
[Parameter(Mandatory=$True)]