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
/** | |
* Given an array of size 'n' and a number 'r' (r <= n), this generator returns all | |
* nCr permutation subarrays of the array. | |
* | |
* @param arr - array | |
* @param r number | |
*/ | |
function* permutations(arr, r, prefix = []) { | |
for (let i = 0; i < arr.length - r + 1; i++) { | |
let x = [...prefix, arr[i]] |
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 toAsciiTree(tree: any, prefix = "", isTail = true): string | null { | |
if (!tree) { | |
return null | |
} | |
let children = tree.children || [] | |
return [prefix, isTail ? "└" : "├", " ", tree.name, '\n'] | |
.concat(children.map((c: any, i: number) => toAsciiTree(c, | |
prefix + (isTail ? " " : "│ "), i >= children.length - 1))) | |
.join('') |
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
₹* _(## ## ## ##0_);₹* (## ## ## ###);₹* 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
#!/bin/bash | |
SIZE=${1:-20} | |
curl -s https://apikey.now.sh/$SIZE | cut -d, -f1 | cut -d: -f2 | tr -d \" |
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
data: function () { | |
return { | |
task: { | |
sm: {}, | |
state: '', | |
error: {}, | |
result: undefined, | |
}, | |
} | |
}, |
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
props: { | |
taskTimeout: { | |
type: Number, | |
required: false, | |
}, | |
}, |
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
['stateTimeout#*_#running', 'done/timeout'] |
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
['enter#*_#done/:status', ({args, data}) => | |
keepState() | |
.emit(args.status, data)], |
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
['cast#error/:sessionId#running', ({args, data, event}) => | |
args.sessionId === data.sessionId | |
? nextState('done/error').data({errors: {$push: [event.extra]}}) | |
: keepState()], |
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
['cast#cancel#running', ({event}) => | |
nextState('done/cancel') | |
.data({errors: {$push: [event.extra]}})], |
NewerOlder