Skip to content

Instantly share code, notes, and snippets.

View bender-the-greatest's full-sized avatar

bender-the-greatest

  • CSG International
  • Omaha, NE
View GitHub Profile
@bender-the-greatest
bender-the-greatest / Set-XInputMouseProfile.ps1
Created January 18, 2021 20:14
Script to adjust Xinput mouse settings. Designed for using around event-based triggers, such as xbindkeys. Currently only supports adjusting the mouse speed.
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Script to adjust Xinput mouse settings. Designed for using around event-based triggers, such as xbindkeys.
.DESCRIPTION
Changes certain Xinput mouse settings. Currently only supports adjusting the mouse speed. Leans on the `xinput`
command to read and apply Xinput configurations. A high-level explanation of which settings are changed for
each operation can be found further on in the description.
@bender-the-greatest
bender-the-greatest / Invoke-Executable.ps1
Last active October 8, 2020 07:17
Invoke an external command and check the result
function Invoke-Executable {
[CmdletBinding()]
Param(
[Parameter(Mandatory, Position=0)]
[string]$Command,
[Parameter(Position=1, ValueFromRemainingArguments)]
[string[]]$Arguments,
[int[]]$ExitCode = 0
)
@bender-the-greatest
bender-the-greatest / Set-WineEnv.ps1
Last active October 8, 2020 07:13
Configure a new wine prefix. A bit convoluted since I wanted this to set up a shared Wine directory, but Wine doesn't support multiuser scenarios. Run Set-WineEnv, the other two functions are helpers used in that function.
function Get-CanWriteDirectory {
[CmdletBinding()]
Param(
[Parameter(Mandatory, Position=0)]
[ValidateScript(
{ Test-Path -PathType Container $_ },
ErrorMessage = "Could not find the path or it is not a directory: {0}"
)]
[string]$Path
)
@bender-the-greatest
bender-the-greatest / Get-CanWriteDirectory.ps1
Last active October 8, 2020 04:05
Function to check whether the current user has write permissions to a directory or not
#Requires -Version 6.2
function Get-CanWriteDirectory {
[CmdletBinding()]
Param(
[Parameter(Mandatory, Position=0)]
[ValidateScript(
{ Test-Path -PathType Container $_ },
# Remove this property to make compatible with 5.1, 6.0, and 6.1
ErrorMessage = "Could not find the path or it is not a directory: {0}"
@bender-the-greatest
bender-the-greatest / Get-ChocolateyOutdatedPackages.ps1
Created February 7, 2020 03:15
Get outdated Chocolatey packages on the local system as a usable PowerShell object
Function Get-ChocolateyOutdatedPackages {
<#
.SYNOPSIS
Gets outdated Chocolatey packages on the local system
.DESCRIPTION
Returns an array of objects with the following properties:
- PackageName: [string] Name of the Chocolatey package.
- CurrentVersion: [string] Current version of the Chocolatey package.
@bender-the-greatest
bender-the-greatest / cloudSettings
Last active August 21, 2020 16:12
My preferred VSCode settings and extensions
{"lastUpload":"2020-08-21T16:12:30.636Z","extensionVersion":"v3.4.3"}
@bender-the-greatest
bender-the-greatest / Random-CatFact.ps1
Created April 5, 2019 16:31
Random-CatFact.ps1 - Reads a random cat fact out loud. Fun to run this with Invoke-Command on your co-workers' or boss' workstations when they aren't busy.
Add-Type -AssemblyName System.Speech
$SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$SpeechSynth.SelectVoice( 'Microsoft Zira Desktop' )
$CatFact = Invoke-RestMethod -UseBasicParsing https://catfact.ninja/fact
$SpeechSynth.speak( "Did you know? $($CatFact.fact)" )
@bender-the-greatest
bender-the-greatest / Trust-AllCerts.ps1
Last active September 17, 2020 13:34
Code snippet to ignore SSL errors when making HTTPS requests in Powershell. Originally sourced from https://www.reddit.com/r/PowerShell/comments/6emjly/ignoring_ssltls_errors_using_invokewebrequest/
# DISCLAIMER - This is provided as a method to interface with HTTPS endpoints configured
# with an invalid certificate as is common during the development process. This is not
# intended or recommended to be used in a production scenario for obvious security reasons.
#
# Also, I did not write the C# code. Props to kd0shk and the Powershell subreddit for the C# snippet.
# Both of these approaches won't work in PowerShell core and is not required as built-in
# request cmdlets now have the -SkipCertificateCheck parameter
# (e.g. Invoke-WebRequest -SkipCertificateCheck https://server.withbadcert.domain.tld)
@bender-the-greatest
bender-the-greatest / atom-friendly-phils-zsh-prompt.zsh
Created July 24, 2017 02:53
Phil!'s ZSH Prompt - Atom-Friendly. Original version breaks when Atom is installed due to dependency on Atom Package Manager, which overrides the `apm` command.
function precmd {
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
###
# Truncate the path if it's too long.
PR_FILLBAR=""
@bender-the-greatest
bender-the-greatest / Configure-SecureWinRM.ps1
Created July 20, 2017 15:55
Configure WinRM to listen over SSL (port 5986) and use the web certificate generated by a certificate templated called 'WinRM'. Highly recommend reading Synopsis, Description, and Examples.
<#
.SYNOPSIS
Configures a secure WinRM listener over HTTPS to enable
SSL-based WinRM communications. This script has not been
tested on Windows Server 2003R2 or earier, and may not
work on these OSes for a variety of reasons.
If Windows Remote Management is disabled (e.g. service
stopped, GPO Policy, etc.), this script will likely fail.
.DESCRIPTION