Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Hashbrown777 / alignbytes.ps1
Last active September 28, 2023 02:32
Resizes files anchoring to EOF
View alignbytes.ps1
'3705688449 ,setup_cyberpunk_2077_build_4902785change_6408866_with_ep1_rl_(64bit)_(67718)-25.bin
2124976 ,setup_cyberpunk_2077_build_4902785change_6408866_with_ep1_rl_(64bit)_(67718).exe
30669496 ,setup_cyberpunk_2077_redmod_build_4902785change_6408866_with_ep1_rl_(64bit)_(67718).exe' -split '\n' `
| %{
$expected,$name = $_ -split ','
$expected = [UInt32]$expected
$diff = (gci $name).Length - $expected
if (!$diff) {
return
@Hashbrown777
Hashbrown777 / _wireguard.ps1
Last active September 7, 2023 14:45
Multiple wireguard connexions with an open port on each (azirevpn)
View _wireguard.ps1
./single.ps1 bob paris
./private.ps1 steve newyork
./private.ps1 greg seattle
./private.ps1 emma newyork
<#
Will create
a wireguard tunnel to paris using bob's credentials in the init [non-]namespace,
a tunnel to seattle with the interface name "seattle" using greg's config under the namespace "greg",
and two tunnels to newyork (interfaces both called 'newyork') using options from steve and emma (under namespaces of the same name respectively)
@Hashbrown777
Hashbrown777 / monitoring.sh
Last active September 8, 2023 14:46
Assorted commands
View monitoring.sh
#top for networking
sudo iftop -P -B
#shows connexions going through listened port
sudo tcptrack -i eno1 port 8080
#get process listening on port
sudo netstat -tulpn | ag 8080
#top for disks
@Hashbrown777
Hashbrown777 / free.ps1
Created July 8, 2023 15:22
free up space on my c drive
View free.ps1
cd $env:LOCALAPPDATA
(
'Ubisoft*',
'Grip',
'Evil*',
'ride3',
'Squad*',
'Remnant',
'Mordhau',
'Dead*',
View rc4.ps1
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
View _NetLbfoTeam.ps1
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
View stackoverflow-unsave.js
//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
View merge.ps1
$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
View batt50.ps1
while ((Get-CimInstance Win32_Battery).EstimatedChargeRemaining -gt 55) { sleep 60 } shutdown -s -t 0