View arraydiff.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
View stackoverflow-unsave.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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', |
View opendirectory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const ignore = /^http:\/\/waltercosand.com\/CosandScores\/Composers%20[^/]+\//; | |
const urls = [ | |
'http://waltercosand.com/CosandScores/Composers%20A-D/', | |
'http://waltercosand.com/CosandScores/Composers%20E-K/', | |
'http://waltercosand.com/CosandScores/Composers%20L-P/', | |
'http://waltercosand.com/CosandScores/Composers%20Q-Z/' | |
].reverse(); | |
const skip = [ | |
'http://waltercosand.com/CosandScores/Composers%20L-P/Mozart,%20W.%20A/Mozart%20-%20Complete%20Works%20for%20Piano/' |
View merge.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$from = $from | gi | |
$to = ($to | gi).FullName | |
$from ` | |
| Get-ChildItem -File -Recurse ` | |
| &{ | |
Begin { | |
$from = '^' + [Regex]::Escape($from.FullName) | |
} | |
Process { |
View batt50.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while ((Get-CimInstance Win32_Battery).EstimatedChargeRemaining -gt 55) { sleep 60 } shutdown -s -t 0 |
View #WSL stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#todo explanation |
View ssh.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#accepts all arguments for ssh except command, -N and -f | |
#command can be piped in | |
Filter ssh-f { | |
$N = $False | |
if (!$_) { | |
#the same as -N | |
$_ = 'read' | |
$N = $True | |
} | |
$_ = 'echo SUCCESS;' + $_ |
View punchHoles.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$blockSize = 4KB | |
$buffer=[byte[]]::new($blockSize) | |
Get-ChildItem -File ` | |
| Sort-Object -Property Length | |
| %{ | |
"$($_.Name)`t$($_.Length / 1MB -bor 0)MB" | |
#useful if your files are patchable eg torrent-sourced | |
sudo cp --reflink=always $_.FullName "$($_.FullName)_rescued" | |
chmod u+r $_.FullName |
View 1_client.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
&{ Param($hostname, $port) | |
$socket = $NULL | |
$stream = $NULL | |
try { | |
$socket = [System.Net.Sockets.TCPClient]::new( | |
[System.Net.IPAddress]::Parse( | |
[System.Net.Dns]::GetHostAddresses($hostname) | |
), | |
$port | |
) |
View attachsmb.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
#Required: | |
Install-Module -Name LoopbackAdapter -MinimumVersion 1.2.0.0 | |
#run in admin terminal | |
#you do NOT need to disable/remove SMB 1.0/CIFS | |
#Troubleshooting: | |
#You can check [attempted] forwardings and [successful] listeners here, respectively | |
netsh interface portproxy show v4tov4 |
NewerOlder