This file contains hidden or 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
Add-Type -TypeDefinition @" | |
using System; | |
using System.Runtime.InteropServices; | |
public static class NumLock { | |
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] | |
public static extern short GetKeyState(int keyCode); | |
[DllImport("user32.dll", EntryPoint = "keybd_event", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] | |
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); |
This file contains hidden or 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 Write-ThisDownHere { | |
[CmdletBinding()] | |
param ( | |
[Parameter(ValueFromPipeline = $true)] | |
$InputObject, | |
[ValidateSet("Host", "Info", "Log")] | |
$Medium = "Host", | |
[ValidateSet("List", "Table", "Wide", "String", "JSON", "Raw")] |
This file contains hidden or 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
// | |
const NOOP = true; // must be === false to make *ANY* actual modification work happen, not just !== true. | |
// | |
const GROUP_CREATION_OKAY = false; // must be === true for this to happen | |
const ACLRULE_ADD_OKAY = false; // must be === true for this to happen | |
const ACLRULE_REMOVE_OKAY = false; // must be === true for this to happen | |
const ACLRULE_FIXROLE_OKAY = false; // must be === true for this to happen | |
// | |
const GROUP_TEMPLATE = { | |
name: ({buildingName}) => buildingName + " Resource Custodian Role", |
This file contains hidden or 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 resolveRelationships(relationships, included, parentIds) { | |
if (typeof relationships !== "object" || !Object.keys(relationships).length) return []; | |
if (typeof included !== "object" || !Array.isArray(included)) return []; | |
if (typeof parentIds === "string") parentIds = [parentIds]; | |
if (typeof parentIds !== "object" || !Array.isArray(parentIds)) parentIds = []; | |
/** | |
* @param {string} type | |
* @returns {string} | |
*/ |
This file contains hidden or 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
// An example of how something like this could be used: | |
// | |
// Set some ranges as NamedRanges named "ColumnFormat_PhoneNumber" and "ColumnFormat_DateTime" | |
// and those will end up processed by the functions named "Format_PhoneNumber" and "Format_DateTime" | |
// which should enforce a value format or number format or possibly even a visual format upon edit | |
// and then set occasionalSheetFormatPatrol as a scheduled trigger to catch the items that were | |
// updated by API/scripts or other things that couldn't have been caught by the onEdit function. | |
// ** | |
function occasionalSheetFormatPatrol() { |
This file contains hidden or 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
/** | |
* Source: https://gist.github.com/emmaly/2522d2e12157c4c3ebefe32d409ca996 | |
* | |
* @param {SpreadsheetApp.Range} ranges | |
* @returns {boolean} | |
* - `true` indicates all ranges share the same overlapping area with all others. | |
* - `false` indicates no shared overlap area, even if they all overlap individually. | |
*/ | |
function doRangesIntersect(...ranges) { | |
return getRangeIntersection(...ranges) !== null; |
This file contains hidden or 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 {string} url | |
* @param {Object<string,string|string[]>} qs - query string | |
*/ | |
function urlWithQueryStringObject(url, qs) { | |
if (!qs) return url; | |
return [ | |
url, | |
Object.entries(qs) | |
.map(([k,v]) => { |
This file contains hidden or 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 Get-FilesFromGithubLatestRelease { | |
# original function from https://github.com/microsoft/winget-cli/issues/1861#issuecomment-1193136622 | |
param ( | |
[parameter(Mandatory)][string]$Project, # e.g. paintdotnet/release | |
[parameter(Mandatory)][string[]]$Patterns, # regex | |
[switch]$Prerelease | |
) | |
$releases = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$Project/releases" | |
$release = $releases | Where-Object { $_.prerelease -eq $Prerelease } | Select-Object -First 1 |
This file contains hidden or 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
= | |
ARRAY_CONSTRAIN( | |
SORT( | |
FILTER( | |
range, | |
MAP( | |
range, | |
LAMBDA( | |
cell, | |
ISDATE(cell) |
This file contains hidden or 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 Search-FileAccess { | |
param ( | |
[Parameter(Mandatory=$true)] | |
[string]$IdentityReferenceRegex, | |
[Parameter(Mandatory=$true)] | |
[string]$Path, | |
[Boolean]$Recurse=$true, | |
[switch]$Visualization | |
) |