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 typing import Optional | |
def split( | |
input_string: str, | |
sep: Optional[str] = None, | |
max_split: int = -1, | |
exclusions: Optional[list[str]] = None, | |
strip_items: bool = False | |
) -> list[str]: |
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
/** | |
* Converts a positive integer into an alphabetic representation, similar to | |
* ordered list lettering and Excel column naming. | |
* | |
* @param {number} int | |
* The positive integer to convert. Non-integers will be floored. | |
* @param {boolean} [returnLowerCase=false] | |
* If `true`, returns lowercase letters (e.g., 'a', 'b', ...). | |
* If `false`, returns uppercase letters (e.g., 'A', 'B', ...). | |
* @returns {string} |
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
/** | |
* Shows the file selector dialog and returns an array of the selected files. | |
* @param {?selectFile__Options=} options | |
* @returns {Promise<File[]>} | |
*/ | |
function selectFile(options) { | |
return new Promise(resolve => { | |
function onClose(e) { | |
resolve([...e.target.files]); | |
} |
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 {Record<"codeEditor"|"diffEditor",boolean|string>} defsToInclude | |
* @returns {Record<string,any>} | |
*/ | |
function getMonacoEditorCompDefs(defsToInclude) { | |
/** | |
* @param {(script?: HTMLScriptElement) => T} getter | |
* Function that will be called to get the result of a script running. This | |
* function will initially be called without any arguments to determine if | |
* the desired results already exist but if not the script tag will be added |
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
/** | |
* Finds the smallest multiple of `multipleOf` that is greater than or equal to | |
* `baseValue + offset`. | |
* | |
* @param {number} multipleOf | |
* The number whose multiple needs to be found. | |
* @param {number} baseValue | |
* The base value to start from. | |
* @param {number} [offset=0] | |
* The optional value to add to `baseValue` (default is 0). |
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
/** | |
* Destructures values from a `root` object based on one or more `nestedMaps` | |
* structures. | |
* @param {Object} root | |
* The root object or array containing the data to destructure. | |
* @param {...NestedMap} nestedMaps | |
* One or more nested mapping objects. Each key in the `NestedMap` is a | |
* string, and each value is either: | |
* - A string (which specifies the key in the result object), or | |
* - A `NestedMap` (which specifies further nested extraction). |
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
(()=>{ | |
const docElem = document.documentElement; | |
const FILTERS = [ | |
"", | |
"invert(1) hue-rotate(180deg) contrast(0.75)", | |
"invert(1) contrast(0.75)", | |
"invert(1) hue-rotate(180deg)" | |
]; | |
const VAR_NAME = "cwestDarkMode"; | |
const DATA_VAR_NAME = `data-${VAR_NAME.replace(/[A-Z]/g, '-$&').toLowerCase()}`; |
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
var formatIntlDate = (() => { | |
const codeToOpts = [...'Y=year M=month D=day H=hour h=hour m=minute s=second S:1 SS:2 SSS:3 MMM=month:short MMMM=month:long DDD=weekday:short DDDD=weekday:long A=hour:2D a=hour:2D Z:Offset ZZ:Offset ZZZ:Generic ZZZZ: J=year:numeric,month:2D,day:2D,hourCycle:h23,hour:2D,minute:2D,second:2D,fractionalSecondDigits:3,timeZoneName:longOffset'.replace(/(\w)=\w+(?= |$)/g, '$&:numeric $1$&:2D').replace(/hour/g, 'hourCycle:h23,$&').replace(/Z:/g, 'Z=timeZoneName:long').replace(/S:/g, 'S=fractionalSecondDigits:').replace(/2D/g, '2-digit').matchAll(/(\w+)=(\S+)/g)] | |
.reduce( | |
(codeToOpts, [_, code, strOpts]) => { | |
codeToOpts[code] = [...strOpts.matchAll(/(\w+):([^,]+)/g)].reduce( | |
(opts, [_, key, value]) => { | |
opts[key] = value; | |
return opts; | |
}, | |
{} |
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
/** | |
* Merges together the values of each of the arrays with the values at the | |
* corresponding position. Useful when you have separate data sources that are | |
* coordinated through matching array indexes. | |
*/ | |
public static Object[][] zip(Object[][] listOfArrays) { | |
Object[][] rows = new List<Object[]>(); | |
Integer itemsCount; | |
for (Object[] items : listOfArrays) { | |
Boolean isFirstPass = itemsCount == null; |
NewerOlder