useful stuff for working in js for codingame.com
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
| #!/usr/bin/env node | |
| /** | |
| * Extracts all documentation pages from Archbee __NEXT_DATA__ | |
| */ | |
| const https = require("https") | |
| function fetch(url) { | |
| return new Promise((resolve, reject) => { |
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
| { | |
| "id": "https://gist.githubusercontent.com/ErikBrendel/aa2ae80174608cd32823d15fd12131b0/raw/462a67a9252a79dd074a6e7c57587bbc79e176f1/json-schema-04-wp.json", | |
| "$schema": "https://gist.githubusercontent.com/ErikBrendel/aa2ae80174608cd32823d15fd12131b0/raw/462a67a9252a79dd074a6e7c57587bbc79e176f1/json-schema-04-wp.json", | |
| "description": "Core schema meta-schema", | |
| "definitions": { | |
| "schemaArray": { | |
| "type": "array", | |
| "minItems": 1, | |
| "items": { "$ref": "#" } | |
| }, |
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
| from typing import List | |
| WEIGHT_RANGE = 3 | |
| class Graph4: | |
| edge_weights = ... # type: List[int] | |
| def __init__(self): | |
| self.edge_weights = [-WEIGHT_RANGE, -WEIGHT_RANGE, -WEIGHT_RANGE, -WEIGHT_RANGE, -WEIGHT_RANGE, -WEIGHT_RANGE] |
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
| //this little js snippet tells you the total amount of additions & deletions of a bitbucket PR or a branch comparison. | |
| //Just open up the site, open up your browser console (Ctrl+Shift+K on Firefox) and paste and execute this code. | |
| //It uses XPath to query all span-elements with the right class | |
| function xpathSum(path) { | |
| var iter = document.evaluate(path, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null); | |
| var sum = 0; | |
| var thisNode = iter.iterateNext(); | |
| while (thisNode) { | |
| var value = parseInt(thisNode.textContent); |