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
######################################################### | |
# Ensure PS script is running with elevated permissions # | |
######################################################### | |
# Works in Powershell >= v4.0, add to top of file | |
#Requires -RunAsAdministrator | |
# Works in all versions of powershell, add to top of file |
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
/** | |
* Gets whether running on a certain browser according to browser data. | |
* Functions to test for a certain browser (each returns bool): | |
* * isOpera | |
* * isFirefox | |
* * isSafari | |
* * isIE | |
* * isEdge | |
* * isChrome | |
* * isBlink |
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
# First run this command from an elevated powershell to install chocolatey | |
# Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
cinst Boxstarter -y | |
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -DisableOpenFileExplorerToQuickAccess | |
Enable-RemoteDesktop | |
Disable-BingSearch | |
Disable-UAC |
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
import { useCallback, useLayoutEffect, useState, useRef } from 'react' | |
/** | |
* Returns the bounding client rect of a HTML element, uses the `ResizeObserver` api if available to detect changes to the | |
* size. Falls back to listening for resize events on the window. | |
*/ | |
export function useBoundingRect<T extends HTMLElement>(): [React.Ref<T>, ClientRect | DOMRect] { | |
const ref = useRef<T>() | |
const [rect, setRect] = useState() |
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
{ | |
init: function(elevators, floors) { | |
const priorities = { | |
CAPACITY: 'CAPACITY', | |
DISTANCE: 'DISTANCE', | |
WAITING: 'WAITING' | |
} | |
const priority = priorities.DISTANCE | |
const needsPickup = floors.reduce((acc, floor) => { | |
acc[floor.floorNum()] = { |
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
import { cpus } from 'os' | |
/** | |
* A lock that is granted when calling [[Semaphore.acquire]]. | |
*/ | |
type Lock = { | |
release: () => void | |
} | |
/** |
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
/** | |
* This is a modern rewrite of this gist https://gist.github.com/timoxley/1689041 using promises | |
*/ | |
import { createServer } from 'net' | |
export async function isPortAvailable(port: number): Promise<boolean> { | |
return await new Promise((resolve, reject) => { | |
const testServer = createServer() |
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
node -e "require('readline').createInterface({input:process.stdin,output:process.stdout,historySize:0}).question('Input> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })" |