Skip to content

Instantly share code, notes, and snippets.

Avatar
🍺
🥓

Trevor Sullivan pcgeek86

🍺
🥓
View GitHub Profile
@pcgeek86
pcgeek86 / install-mysqlsh.sh
Last active Nov 22, 2021
Install MySQL Shell utility into MySQL official Docker container image
View install-mysqlsh.sh
# Use these commands to install MySQL Shell utility into a container running
# the official MySQL distribution via Docker Hub.
#
# docker pull mysql:8.0.26
# export CONTAINER_ID=$(docker run --detach --env MYSQL_ROOT_PASSWORD=12345 mysql:8.0.26)
# docker exec --interactive --tty $CONTAINER_ID bash
apt update && apt-get install httpie --yes
# Use the Debian or Ubuntu package
@pcgeek86
pcgeek86 / build-aws-vpc.ps1
Last active Jul 20, 2021
2021-07-15 Use PowerShell Imperative Commands to Create EC2 VPC with Two Public Subnets and Two Private Subnets with Internet Access
View build-aws-vpc.ps1
<#
- Creates an Amazon Web Services (AWS) Virtual Private Cloud (VPC) in the us-west-2 (Oregon) region.
- VPC contains two public subnets and two private subnets.
- NAT Gateway is created to handle outbount Internet traffic from private subnets.
- Internet Gateway is created to handle in/outbound Internet traffic for public subnets.
- iex (iwr https://gist.githubusercontent.com/pcgeek86/523b3b7c80eb25bd7f993354509268d0/raw).Content
#>
function Add-EC2NameTag {
<#
.Synopsis
@pcgeek86
pcgeek86 / script.ps1
Created Jun 16, 2020
Use PowerShell PSTypeNames and custom FormatData to limit default properties emitted from objects
View script.ps1
$Object = [PSCustomObject]@{
FirstName = 'Trevor'
LastName = 'Sullivan'
}
$Object
$Object.PSObject.TypeNames.Add('Person')
$FormatData = @'
<?xml version="1.0" encoding="utf-8" ?>
@pcgeek86
pcgeek86 / email-domain-blacklist.txt
Created May 26, 2020
My personal list of blacklisted e-mail domains who have sent me spam.
View email-domain-blacklist.txt
advidsdesign.cc
chinadesels.com
crazycybertech.info
fleek.co
joviasevilla.com
veganliftz.com
webpronews.com
@pcgeek86
pcgeek86 / Get-YouTubeVideoRuntime.ps1
Created Feb 7, 2020
Retrieves your YouTube video run-time, in hours, using dependency-free PowerShell code
View Get-YouTubeVideoRuntime.ps1
$ErrorActionPreference = 'stop'
function Get-YouTubeChannel {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $Username,
[Parameter(Mandatory = $true)]
[string] $AccessToken
)
@pcgeek86
pcgeek86 / Get-WavBitDepth.ps1
Created Feb 6, 2020
Get WAV file bit depth using PowerShell
View Get-WavBitDepth.ps1
# 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 Sep 13, 2021
Convert an animated .webp file to GIF with Python
View webp_animation_to_gif.py
#!/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 Jan 19, 2020
Create VPC, AWS Directory Service, and Amazon WorkSpace, using AWS PowerShell module
View workspaces.ps1
$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 Sep 14, 2019
Apply 24-bit colors to your text using PowerShell and ANSI escape sequences
View powershell-ansi-color.ps1
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 Oct 22, 2021
Install & test Selenium with Firefox / Gecko driver on headless Ubuntu 18.04 LTS server
View gist:a1fd9d26f8ad46b51adf9513f67b95f2
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