Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Hashbrown777 / free.ps1
Created July 8, 2023 15:22
free up space on my c drive
cd $env:LOCALAPPDATA
(
'Ubisoft*',
'Grip',
'Evil*',
'ride3',
'Squad*',
'Remnant',
'Mordhau',
'Dead*',
class RC {
hidden $type = $NULL
hidden $code = $NULL
hidden $size = $NULL
hidden RC($type) {
$this.type = $type
$this.size = $type::New(1)[0]::MaxValue + 1
}
@Hashbrown777
Hashbrown777 / _NetLbfoTeam.ps1
Created June 19, 2023 15:53
After extracting the needed files, get `New-NetLbfoTeam` working in win10
try {
Switch ($args[0]) {
#entrypoint
$NULL {
if (!(Start-Process `
-FilePath 'PsExec' `
-ArgumentList (
'-s',
'-nobanner',
'-accepteula',
@Hashbrown777
Hashbrown777 / stackoverflow-unsave.js
Last active May 31, 2023 09:46
Unfollow all your questions in a Stack Exchange list
//go to one of your lists, eg https://superuser.com/users/saves/241800
$('.s-block-link.js-unsave').click()
//NO NEED TO USE THIS
(async (links) => {
const request = {
body : 'fkey=' + localStorage['se:fkey'].replace(/,.*$/, ''),
method : 'POST',
@Hashbrown777
Hashbrown777 / merge.ps1
Created May 22, 2023 12:00
take all files in $from and put them in the same place under $to, replacing any matched files
$from = $from | gi
$to = ($to | gi).FullName
$from `
| Get-ChildItem -File -Recurse `
| &{
Begin {
$from = '^' + [Regex]::Escape($from.FullName)
}
Process {
@Hashbrown777
Hashbrown777 / batt50.ps1
Created May 15, 2023 05:00
Discharge laptop to 55% before shutting it down & not using it for a good while
while ((Get-CimInstance Win32_Battery).EstimatedChargeRemaining -gt 55) { sleep 60 } shutdown -s -t 0
//leaves only the unique elements in two sorted arrays
function diff(bob, steve) {
for (let b = 0, s = 0; b < bob.length && s < steve.length; ++b, ++s) {
if (bob[b] < steve[s])
--s;
else if (bob[b] > steve[s])
--b;
else {
bob.splice(b--, 1);
steve.splice(s--, 1);
@Hashbrown777
Hashbrown777 / _punchHoles.ps1
Last active June 22, 2023 17:01
In files identified as containing corrupted blocks punch holes in the valid blocks so they don't take up as much space
$blockSize = 4KB
$buffer=[byte[]]::new($blockSize)
Get-ChildItem -File `
| Sort-Object -Property Length
| %{
"$($_.Name)`t$($_.Length / 1MB -bor 0)MB"
$path = $_.FullName
#useful if your files are patchable eg torrent-sourced
sudo cp --reflink=always $path "${path}_rescued"
@Hashbrown777
Hashbrown777 / datesort.ps1
Created January 16, 2023 17:19
Sorting captures from holidays into folders named by date
$ErrorActionPreference = 'Stop'
$shell = New-Object -ComObject 'Shell.Application'
&{
gci -File `
| ?{
#leave these in the root directory
$_.Name -notmatch '^(IMG_\d{4}.JPG|sort.ps1|Untitled.png)$'
}