Skip to content

Instantly share code, notes, and snippets.

View pcgeek86's full-sized avatar
🍺
🥓

Trevor Sullivan pcgeek86

🍺
🥓
View GitHub Profile
@pcgeek86
pcgeek86 / AWS Cleanup.ps1
Last active March 7, 2022 20:34
AWS Cleanup script using PowerShell
<#
Call this script:
foreach ($Region in (Get-AWSRegion).Region) {
Set-DefaultAWSRegion -Region $Region
iex (iwr https://gist.githubusercontent.com/pcgeek86/42764099021c0b1baa7f32d48afef4c2/raw).Content
}
#>
Get-LMFunctionList | Remove-LMFunction -Force
@pcgeek86
pcgeek86 / Get-YouTubeVideoRuntime.ps1
Created February 7, 2020 19:51
Retrieves your YouTube video run-time, in hours, using dependency-free PowerShell code
$ErrorActionPreference = 'stop'
function Get-YouTubeChannel {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $Username,
[Parameter(Mandatory = $true)]
[string] $AccessToken
)
@pcgeek86
pcgeek86 / Get-WavBitDepth.ps1
Created February 6, 2020 15:41
Get WAV file bit depth using PowerShell
# Create an empty Byte array, with a length of 1 byte
$Data = [System.Byte[]]::new(1)
# Open a FileStream to the specified file path
$Stream = [System.IO.File]::Open("$HOME/wav1.wav", [System.IO.FileMode]::Open)
# Seek to Byte 35
$null = $Stream.Seek(34, [System.IO.SeekOrigin]::Begin)
# Read a single byte, from the current position, into the specified Byte array
@pcgeek86
pcgeek86 / webp_animation_to_gif.py
Last active February 11, 2024 22:18
Convert an animated .webp file to GIF with Python
#!/usr/bin/env python3
# Trevor Sullivan <trevor@trevorsullivan.net>
# https://trevorsullivan.net
# https://twitter.com/pcgeek86
# IMPORTANT: Install the webp Python package, using the following command:
# pip3 install --user webp
# Import the webp package
@pcgeek86
pcgeek86 / workspaces.ps1
Created January 19, 2020 21:48
Create VPC, AWS Directory Service, and Amazon WorkSpace, using AWS PowerShell module
$ErrorActionPreference = 'Stop'
Install-Module -Name AWS.Tools.DirectoryService, AWS.Tools.EC2, AWS.Tools.WorkSpaces -Scope CurrentUser -Force
Update-AWSToolsModule
$VPC = New-EC2Vpc -CidrBlock 10.5.0.0/16
$VPC
@pcgeek86
pcgeek86 / powershell-ansi-color.ps1
Created September 14, 2019 22:06
Apply 24-bit colors to your text using PowerShell and ANSI escape sequences
while ($true) {
$Red = Get-Random -SetSeed (Get-Date).Ticks.ToString().Substring(10,8) -Maximum 255
$Green = Get-Random -SetSeed (Get-Date).Ticks.ToString().Substring(10,8) -Maximum 255
$Blue = Get-Random -SetSeed (Get-Date).Ticks.ToString().Substring(10,8) -Maximum 255
Write-Host -Object ("$([char]27)[38;2;{0};{1};{2}mtrevor" -f $Red, $Green, $Blue)
}
@pcgeek86
pcgeek86 / gist:a1fd9d26f8ad46b51adf9513f67b95f2
Last active March 9, 2024 18:11
Install & test Selenium with Firefox / Gecko driver on headless Ubuntu 18.04 LTS server
sudo apt update
sudo apt install firefox python3-pip xvfb x11-utils --yes
sudo -H pip3 install bpython selenium
export DISPLAY=:2
Xvfb $DISPLAY -ac &
export GECKO_DRIVER_VERSION='v0.24.0'
wget https://github.com/mozilla/geckodriver/releases/download/$GECKO_DRIVER_VERSION/geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
tar -xvzf geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
body {
color: blue;
}
@pcgeek86
pcgeek86 / cheatsheet.ps1
Last active April 16, 2024 14:56
PowerShell Cheat Sheet / Quick Reference
Get-Command # Retrieves a list of all the commands available to PowerShell
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
Get-Help # Get all help topics
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
Get-Help -Name Get-Command # Get help for a specific PowerShell function
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
@pcgeek86
pcgeek86 / install-balena-cli.sh
Last active October 17, 2021 22:16
Install Balena CLI on Debian / Ubuntu
# Trevor Sullivan <trevor@trevorsullivan.net>
export VERSION='v9.12.0'
export FILENAME="balena-cli-$VERSION-linux-x64"
export URL="https://github.com/balena-io/balena-cli/releases/download/$VERSION/$FILENAME.zip"
sudo apt update
sudo apt install httpie unzip --yes
cd $HOME