Skip to content

Instantly share code, notes, and snippets.

View JPRuskin's full-sized avatar

James Ruskin JPRuskin

View GitHub Profile
@JPRuskin
JPRuskin / Update-ChocolateyNexusSource.ps1
Created August 16, 2024 13:18
Updates Chocolatey sources that look like Nexus v2 NuGet feeds to Nexus v3 NuGet endpoints.
#requires -RunAsAdministrator
function Update-ChocolateyNexusSource {
<#
.Synopsis
Updates Chocolatey sources that seem to be Sonatype Nexus Repository NuGet repositories to use the v3 'Index.json'
.Example
Update-ChocolateyNexusSource -WhatIf
# Preview changes that will be made.
@JPRuskin
JPRuskin / Detrack.js
Created August 1, 2024 07:32
Bookmarklets
// Gets the last URL in the chain and decodes it, generally good for when an e-mail clickthrough
// is blocked by uBlock and then goes to a blocked tracker-site anyway...
javascript:(function() {window.location=decodeURIComponent(decodeURIComponent(location.href.replace(/.+(https.+?)$/,'$1')))})
@JPRuskin
JPRuskin / Get-InternalizedPackage.ps1
Created June 20, 2024 10:33
A function that downloads and internalizes Chocolatey packages, with functionality to remove dependencies you are absolutely sure you don't need.
# This assumes you have Chocolatey and Chocolatey.Extension installed and licensed correctly.
if (-not ('Nuget.Versioning.VersionRange' -as [type])) {
try {
Add-Type -AssemblyName $env:ChocolateyInstall\choco.exe
} catch {
$null = [System.Reflection.Assembly]::Loadfrom("$env:ChocolateyInstall\choco.exe")
}
}
function Get-InternalizedPackage {
@JPRuskin
JPRuskin / ccr-failures.ps1
Created April 30, 2024 09:44
PowerShell Universal App to display the last X Chocolatey Community Package build results, highlighting failures and showing failures that have an existing PR in place.
#requires -Version 6.1
[CmdletBinding()]
param(
[uint16]$Last = 20
)
if (-not $cache:CachedCalls) {
$cache:CachedCalls = @{}
}
@JPRuskin
JPRuskin / BootstrapQSG.ps1
Last active April 30, 2024 08:51
Bootstrap the Chocolatey For Business Quickstart Guide files.
[CmdletBinding()]
param(
# The directory to output all files to. If not provided, defaults to 'C:\choco-setup\files'.
[Parameter()]
[string]$OutputDirectory = $(Join-Path $env:SystemDrive 'choco-setup\files'),
# The branch or PR to download. If not provided, defaults to 'main'.
[Parameter()]
[Alias('PR')]
[string]$Branch = $env:CHOCO_QSG_BRANCH,
@JPRuskin
JPRuskin / SettleUp.psm1
Last active January 4, 2024 10:50
A quick and dirty set of functions to work with SettleUp.app, along with
# See: https://docs.google.com/document/d/18mxnyYSm39cbceA2FxFLiOfyyanaBY6ogG7oscgghxU/ for some documentation
# and, for some context: https://github.com/cad0p/settleup-stripe/blob/master/functions/index.js
param(
[ValidateSet("settle-up-live", "settle-up-sandbox")]
$script:FirebaseEnvironment = "settle-up-sandbox"
)
enum currency {
GBP
USD
@JPRuskin
JPRuskin / battlenet-manifest.json
Created October 1, 2022 15:21
Steam ROM Manager manifests for non Steam games
[
{
"title": "Diablo III",
"target": "/home/deck/.local/share/Steam/steamapps/compatdata/2880652453/pfx/drive_c/Program Files (x86)/Diablo III/Diablo III.exe",
"startIn": "/home/deck/.local/share/Steam/steamapps/compatdata/2880652453/pfx/drive_c/Program Files (x86)/Diablo III/",
"launchOptions": "-launch"
}
]
@JPRuskin
JPRuskin / FileInArchive.psm1
Last active May 13, 2022 09:21
Some unfinished functions to handle CRUD in zip (/nupkg) archives.
function Find-FileInArchive {
<#
.Synopsis
Finds files matching a pattern in an archive.
.Example
Find-FileInArchive -Path "C:\Archive.zip" -like "tools/files/*-x86.exe"
.Example
Find-FileInArchive -Path $Nupkg -match "tools/files/dotnetcore-sdk-(?<Version>\d+\.\d+\.\d+)-win-x86\.exe(\.ignore)?"
@JPRuskin
JPRuskin / Update-AWSSessionToken.ps1
Last active November 7, 2022 12:02
Refreshes AWS session tokens with your MFA authentication.
function Update-AWSSessionToken {
[CmdletBinding()]
param(
# MFA Token IAM, e.g. arn:aws:iam::123456789012:mfa/james
[string]$SerialNumber = "arn:aws:iam::...",
# 6-digit output from your MFA token
[ValidateLength(6,6)]
[Parameter(Mandatory)]
[string]$Token,
@JPRuskin
JPRuskin / ConvertTo-Guid.ps1
Created January 17, 2022 11:39
Converts a string to an RFC 4122 compatible UUID.
function SwapBytes {
<#
.SYNOPSIS
Simply switches two bytes in an array of bytes
#>
param(
[Parameter(Mandatory)]
[byte[]]$Guid,
[Parameter(Mandatory)]
[int]$Left,