Skip to content

Instantly share code, notes, and snippets.

View emmaly's full-sized avatar
👾
Invading Space

Emmaly emmaly

👾
Invading Space
View GitHub Profile
@emmaly
emmaly / Search-FileAccess.ps1
Created January 15, 2023 05:14
Search-FileAccess PowerShell Script
function Search-FileAccess {
param (
[Parameter(Mandatory=$true)]
[string]$IdentityReferenceRegex,
[Parameter(Mandatory=$true)]
[string]$Path,
[Boolean]$Recurse=$true,
[switch]$Visualization
)
@emmaly
emmaly / tracking-number.regex
Created January 14, 2023 02:35
Regular Expression for Tracking Numbers
\b(?:(?<International>[A-Z]{2}[0-9]{9}[A-Z]{2})|(?<FedEx>[0-9]{4} ?[0-9]{4} ?[0-9]{4} ?(?:[0-9]{3})?)|(?<UPS>(?:(?:(?:1Z)[0-9A-Z]{16})|(?:(?:T)[0-9A-Z]{15}[0-9])|(?:[0-9]{9})|(?:[0-9]{26})))|(?<USPS>(?:(?:(?:93|92|94|95)[0-9]{2} ?[0-9]{4} ?[0-9]{4} ?[0-9]{4} ?[0-9]{4} ?[0-9]{2,4})|(?:(?:70|14|23|03)[0-9]{14})|(?:(?:M0|82) ?[0-9]{3} ?[0-9]{3} ?[0-9]{2})|(?:(?:[A-Z]{2})[0-9]{9}(?:[A-Z]{2})))))\b
@emmaly
emmaly / TestableTypes.js
Last active December 26, 2022 05:14
JavaScript type match helper
// these are just suggestions and examples...
const TestableTypes = {
"undefined" : "undefined",
"null" : "null",
"object" : "object",
"Object" : "Object",
"boolean" : "boolean",
"Boolean" : "Boolean",
"number" : "number",
@emmaly
emmaly / Read-GoReleases.ps1
Last active December 18, 2022 02:15
PowerShell: get newest Go release version from git
<# as a one-liner... because why not. #>
git ls-remote --tags https://go.googlesource.com/go | ForEach-Object { if ($_ -imatch ('^\s*(?<Commit>[0-9a-f]+)\s+refs/tags/go(?<Version>\d+\.\d+(?:\.\d+)?)\s*$')) { [PSCustomObject]@{Commit=$matches.Commit;Version=[Version]$matches.Version} } } | Sort-Object -Property Version -Descending -Top 1
@emmaly
emmaly / reconfigure.sh
Created December 9, 2022 20:30
DPMA Lookup and Reconfigure
#!/bin/bash
ID="$1"
MAC=$(grep -Ei '^[A-Z0-9]+$' <<<"$ID")
if [ -z "$MAC" ]; then
MAC=$(/etc/asterisk/scj/sipmac.sh "$ID")
if [ -z "$MAC" ]; then
echo "$ID was not found" >&2
@emmaly
emmaly / filterArray.js
Last active October 10, 2022 20:38
FilterArray
/**
* @param {any[]} input
* @param {Object} filter
* @param {(RegExp|string)} filter.match
* @param {(string|string[])} filter.property
* @param {boolean} [filter.regularExpression=false]
* @param {boolean} [filter.caseSensitive=false]
* @param {boolean} [filter.multiline=false]
*/
function filterArray(input, filter) {
@emmaly
emmaly / Find-EmptyFolders.ps1
Last active September 30, 2022 08:41
Find-EmptyFolders.ps1
function Find-EmptyFolders {
Param(
[string]$Path = $pwd,
[int]$MaxDepth = 0,
[switch]$IgnoreAccessDenied,
[switch]$IncludeHidden,
[System.Management.Automation.FlagsExpression`1[System.IO.FileAttributes]]$FileAttributes
)
$getParams = @{
@emmaly
emmaly / documents.ps1
Last active September 22, 2022 23:51
PowerShell: where's my Documents folder?
$documentsFolderPath = $([Environment]::GetFolderPath('Personal'))
# other ENUM values are here:
# https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder
@emmaly
emmaly / ProjectSharedDrive.gs
Created September 13, 2022 05:42
Google Sheet Protection Maintenance
const PROJECT_DRIVE_ID = ".......................";
/**
* @returns {string[]} Project Managers
*/
function getProjectManagers() {
return getSharedDriveManagers(PROJECT_DRIVE_ID);
}
@emmaly
emmaly / NextDNS-DNS-over-DOH.ps1
Last active August 3, 2022 20:26
DNS-over-HTTP (DoH) NextDNS automatic configuration via PowerShell for Windows 11 (and maybe Windows 10?)
<# NextDNS install as DNS-over-DOH #>
param (
[Parameter(
Mandatory = $true,
ParameterSetName = "NextDnsId",
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = "NextDNS Configuration ID, like: 12ab3c"
)]