Skip to content

Instantly share code, notes, and snippets.

@jahands
jahands / Test-Parallel.ps1
Created April 17, 2020 19:42
Run things in parallel in PowerShell 7
Function Foo {
@(1..2) | ForEach-Object -Parallel {
switch ($_) {
1 {
Return 1
}
2 {
# This could be something that takes a while
# like a network call, etc
Start-Sleep 3
@jahands
jahands / Sync-MultiMC.ps1
Created January 8, 2020 17:01
Jsonbin.io example usage - this is how I sync minecraft between computers without overwriting newer data with older data
Class JsonBin {
[string]$BinID
[string]$SecretKey = '$xyz'
[object]$Data
JsonBin($binID){
$this.BinID = $binID
$this.Get()
}
Get(){
$res = Invoke-RestMethod -Method Get -Uri "https://api.jsonbin.io/b/$($this.BinID)/latest" -Headers @{'secret-key'=$this.SecretKey}
from PIL import Image
import multiprocessing as mp
import os, math, sys
folder = "C:/Users/jh/AppData/Roaming/Factorio/script-output/FactorioMaps/" + sys.argv[1] + '/Images/'
ext = ".jpg"
maxthreads = mp.cpu_count()
@jahands
jahands / Backup-FactorioSaves.ps1
Last active May 25, 2018 18:47
Backup Factorio saves
<#
.SYNOPSIS
Backs up Factorio save / autosaves
.PARAMETER SaveName
The name of the save file (excluding the .zip extension)
.PARAMETER Auto
Auto backup new saves as you're playing
.PARAMETER SavesPath
Path to Factorio save files.
@jahands
jahands / AddItem.ps1
Last active September 28, 2017 19:46
PowerShell database class
[JhaContentDB]::new($dbPath).Load().Add($item).Save().Close()
@jahands
jahands / Remove-Windows10JunkApps.ps1
Created September 25, 2017 15:39
Removes a few apps that come with Windows 10. To use, copy/paste into PowerShell and hit Enter.
@(
'Microsoft.Messaging'
'Minecraft'
'Netflix'
'Microsoft.MicrosoftOfficeHub'
'Microsoft.OneConnect'
'Microsoft.Office.OneNote'
'Microsoft.People'
'Microsoft.WindowsPhone'
'Microsoft.Windows.Photos'
@jahands
jahands / boxstarter.ps1
Created September 20, 2017 17:28
Boxstarter Commands for a new Windows box.
$auPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{8FA01A01-4B9C-4A5F-9E4B-5242B1CA676A}Machine\Software\Policies\Microsoft\Windows\WindowsUpdate\AU"
New-Item $auPath -Force
Set-ItemProperty -Path $auPath -Name NoAutoRebootWithLoggedOnUsers -Type DWord -Value 1 -Force
Function Send-PasswordHashesToDiscord {
<#
.SYNOPSIS
Sends password hashes from dump to Discord
#>
Param (
[string]$LastHash,
[switch]$FirstRun
)
$path = 'V:\NOBACKUP\TMP\pwned-passwords-1.0.txt'
0eNrt3U/T3baZpvHvorXVxRskQDK7Xsx2Nt2LqZpKuWTn7UTVsuxSlEwyXfruI1l/LEuHPPgdnLeSrvEqFfvlY/AABC4+eIjrv5589+IvDz+9ev7y9bff/fjjfz753X/98k/+/OR3//uz//vu3z3//seX7//xn5//8eWzF+/+2eu///Tw5HdPnr9++OHJN09ePvvh3f979ez5iydvvnny/OUfHv725Hd5882FS/76/NXrv7z9J5+uev8XT5fPrix0ZfnsyvnN77958vDy9fPXzx/et/nn//P3b1/+5YfvHl69bdQvV79+294//un105+b/c2Tn37889urfnz57r/4NtLTLN88+fu7/53ehv/D81cP37//tz837ouopT9q6Y8690ed+qMu3VG3/qC1O2jrD9q6g0JXrd1Boae2T0G//8urvz784SDk/D7i/uuA84WA+68eqqcfnoVLg/Rf6vug27/UX4dtF8K+Gyc9Dd3fx/wi4nopoj9Qy/XfM/5A9UT1B6onKj9QPUH5geoJyg9UT1B+oHqCbr1BoZ/23pj97SxTb8z+H7R0P1H9PV+6n6f+IVq6nyZ4mEr3wwTPfel+mGCKKo2n6NIzRZdfnqfvnv/x6cOLt3/86vn3T3/68cXDGaW8uRRr62tjZmviLk08beE89f6KH5s4fdnCi+SUzhtfKGrRta50BJ11qesJuuhK1xO04kLXE7PhOtcTc8VlrifmhqtcT8zdFrmOkMtka1xPyNgS1xOyCIXO1yekZbYls6eNi62YPSErLpg9MRuulz0xV1wue2LSG9LaEXDXhaP1TPF10il+6wganeJ7ghad4nuCzjjF98RccIrviVlxiu+J2XCK/yrm7795nxD73Wf5s2+evHj23cOLD8P024+Rv12+LW//3V8fXv35/ay2LKWmLds0/5LMmt61sjcVd5Qd+183Z+TKrzJy98urfQD3Ut6cZtKuPNbTJ2TNlw/2cppL66Hq/ayJS2cT108tfEfV90iaXW5P859+ejOUGWt
<html>
<head>
<script type="text/javascript">
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}