View datesort.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
$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)$' | |
} | |
View dirdiff.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
#folders you want checked that are found in each root | |
$paths = 'Pics of cats', 'Pics of dogs' | |
#roots to compare, must include terminating slash | |
$roots = '//?/D:/PicsBackup/', '//?/C:/Users/Hashbrown/Desktop/' | |
#any files that are permitted to differ and wont be checked | |
$skip = ` | |
'Pics of cats/test.ps1', | |
'Pics of cats/tabby/download.log' | |
#periodically the script outputs the last sucessfully checked path. | |
#upon failure you can start from exactly where you were, skipping all previously checked files |
View clonepage.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
(function (element, asBody) { | |
let copy = open().document; | |
copy.open(); | |
copy.write('<!doctype html>\n<html><head></head><body></body></html>'); | |
copy.close(); | |
if (asBody) { | |
for (const name of element.getAttributeNames()) | |
copy.body.setAttribute(name, element.getAttribute(name)); | |
for (const node of element.children) |
View ChunkSum.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
<# Similar to a CheckSum, but you receive one for every chunk of a given size in the file as if hashing several files each of that size. | |
You could use this to assess where in a file it differs from another (say, over a network, where comparing digests is infinitely better than comparing the real byte streams) | |
-File | |
Can be a string or file reference (it's passed to Get-Item internally anyway) | |
-ChunkSize | |
The size to 'break' the file into to report each hash on. | |
A chunksize greater or equal to the filesize is equivalent to a normal Get-FileHash call. | |
This figure does not have to be a multiple of BufferSize (nor vice versa); the streaming is robust. | |
-BufferSize | |
The amount, in bytes, to read at a time before passing it on to the hashing algorithm. |
View wslMount.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
<# calling the wslMount function will attach one or more physical disks to a wsl instance | |
-drives | |
This parameter specifies which disks, and is an array of what Windows calls the Friendly Name. | |
You can see these by calling `Get-PhysicalDisk`. | |
-count | |
The list of friendly names are not necessarily unique (eg if you have multiple of the same model of drive). | |
Count is required so that you know how many disks have been matched, and will be passed to WSL. | |
-wsl | |
The name of the wsl install you want to interact with, defaults to the default wsl instance. | |
-mount |
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 |
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 grep.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
#https://gist.github.com/Hashbrown777/a5a02e2fd3eeed4485d4ba073ef3b143 | |
. "$PSScriptRoot/async.ps1" | |
. "$PSScriptRoot/files.ps1" | |
. "$PSScriptRoot/style.ps1" | |
#default switches of $True emulate grep/ag behaviour, use `-flag:$False` to disable | |
Function Grep { [CmdletBinding(PositionalBinding=$False)]Param([Parameter(ValueFromPipeline)]$Input, | |
#display params | |
[switch]$OnlyMatching, [switch]$Files, $Max=-1, | |
#async params |
View randomalphanumeric.sh
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
cat /dev/urandom \ | |
| tr -dc '[:upper:][:digit:]' \ | |
| fold -w ${1:-8} \ | |
| head -1 |
View _hashes
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
# |
NewerOlder