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
| item4 = {id: 4, children: []}; | |
| item3 = {id: 3, children: [], parent: 2}; | |
| item2 = {id: 2, children: [item3], parent: 1}; | |
| item1 = {id: 1, children: [item2]}; | |
| items = [item1, item4]; | |
| flatten = (items) => { | |
| return items.reduce((flatItems, item) => { | |
| const children = _.get(item, 'children', []); | |
| const flatChildren = children.length === 0 ? [] : flatten(children); | |
| return [...flatItems, item, ...flatChildren]; |
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
| pad = (num) => { | |
| return num < 10 ? `0${num}` : num.toString(); | |
| }; | |
| getIsoDate = (date) => { | |
| const year = date.getFullYear(); | |
| const month = pad(date.getMonth() + 1); | |
| const monthDay = pad(date.getDate()); | |
| return `${year}-${month}-${monthDay}`; | |
| }; | |
| getIsoTime = (date) => { |
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
| release=$(echo "${TRAVIS_TAG//v}") | |
| requires=$REQUIRED_MOODLE_VERSION | |
| today=$(date +"%Y-%m-%d") | |
| todaysReleases=$(git log --tags --simplify-by-decoration --pretty="format:%ai %d" | sort -r | grep "$today" | wc -l | tr -d '[:space:]') | |
| versionPrefix=$(date +"%Y%m%d") | |
| versionSuffix=$(printf %02d $todaysReleases) | |
| version="$versionPrefix$versionSuffix" |
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
| <?php | |
| function getIn($obj, $keys, $default = null) { | |
| $key = $keys[0]; | |
| $rest = array_slice($keys, 1); | |
| if ($obj instanceof StdClass) { | |
| if (isset($obj->{$key})) { | |
| if (count($rest) > 0) { | |
| return getIn($obj->{$key}, $rest); | |
| } else { |
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
| export type Path = string[]; | |
| export type Modifier = (data: any, path: Path) => any; | |
| export type Schema = { [key: string]: Modifier }; | |
| export const defaultValue = (value: any): Modifier => | |
| (data) => | |
| data === undefined ? value : data; | |
| export const overrideValue = (value: any): Modifier => () => value; |
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 fs = require('fs'); | |
| const docTokens = require('./ts.json'); | |
| const renderToken = token => { | |
| const functionKind = 64; | |
| switch (token.kind) { | |
| case functionKind: { | |
| const source = token.sources && renderSources(token.sources); | |
| const sig = renderSignatures(token.signatures); |
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
| injectScript = (src) => { | |
| return new Promise((resolve) => { | |
| var script = document.createElement('script'); | |
| script.type = 'text/javascript'; | |
| script.async = true; | |
| script.src = src; | |
| script.onload = () => resolve(window.gapi); | |
| document.body.appendChild(script); | |
| }); | |
| }; |
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 = function (a) { | |
| return function (b) { | |
| return function () { | |
| a = a(); | |
| b = b(); | |
| return a + b; | |
| }; | |
| }; | |
| }; | |
| one = function () {return 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
| var copy = function (text) { | |
| var range = document.createRange(); | |
| var elem = document.createElement('div'); | |
| var parent = document.createElement('div'); | |
| window.getSelection().removeAllRanges(); | |
| elem.innertText = text; | |
| parent.appendChild(elem); | |
| range.selectNode(elem); | |
| window.getSelection().addRange(range); | |
| document.execCommand('copy'); |
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 () { | |
| var parseNum = function (elem) { | |
| return parseInt(elem.innerText.replace('$', '').replace(',', '')) | |
| }; | |
| var attrs = $('#squad > thead > tr > th').length; | |
| var player_elems = $('#squad > tbody > tr.highlighted').toArray(); | |
| if (player_elems.length == 0) { | |
| player_elems = $('#squad > tbody > tr').toArray(); | |
| } |