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
{ | |
question: | |
'Is the subject site located within the catchment of the Hauraki Gulf Islands as defined by the Hauraki Gulf Marine Park Act 2000?', | |
path: ['siteInfo', 'districtArea', 'hauraki', 'gulfCatchment'] | |
}, | |
{ | |
question: | |
'Is the subject site located within the Waitakere Ranges Heritage Area (WRHA)?', | |
path: ['siteInfo', 'districtArea', 'waitakere', 'heritageArea'], | |
relevantIf: anyPass([ |
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
{wizardSteps.map( | |
({ path, component: StepComponent, additionalProps }) => ( | |
<Route | |
key={path} | |
path={path} | |
exact | |
render={routeProps => ( | |
<StepComponent | |
{...routeProps} | |
{...additionalProps} |
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
def import_jwk(jwk): | |
""" | |
Used to import a JWK key from the JSON client. | |
""" | |
if (jwk.get('kty') != 'RSA'): | |
raise ValueError('Expected kty to be RSA') | |
def decode_base64(data): | |
# Python is very particular about padding of base64 strings. We'll | |
# just pad the end with zero length data |
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
{ | |
"sections": [ | |
{ | |
"title": "Flooding", | |
"questions": [ | |
{ | |
"text": "Is the site within a flood plain?", | |
"path": ["siteInfo", "flooding", "floodPlain"] | |
}, | |
{ |
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 do_work(data) { | |
const duration = Math.random() * 100; | |
return fetch(data); | |
} | |
async function main() { | |
const results = await Promise.all(['a', 'b', 'c'].map(do_work)); | |
console.log(results); | |
} |
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
def canonical_jsonify(json_node): | |
# Escape character | quote | backslash | high surrogate not followed by low, or low surrogate not following | |
# a high surrogate | |
replace_regex = r'[\u0000-\u001F]|\"|\\|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]' | |
to_slash_escape = { | |
'\b': '\\b', | |
'\t': '\\t', | |
'\n': '\\n', | |
'\f': '\\f', | |
'\r': '\\r', |
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
// As described here: http://gibson042.github.io/canonicaljson-spec/ | |
// Probably fairly inefficient, but I really doubt it matters | |
export function encodeCanonicalJSON(jsonNode) { | |
// Escape character | quote | backslash | high surrogate not followed by low, or low surrogate not following | |
// a high surrogate | |
const replaceRegex = /[\u0000-\u001F]|"|\\|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g; | |
const toSlashEscape = { | |
"\b": "\\b", | |
"\t": "\\t", | |
"\n": "\\n", |
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
// As described here: http://gibson042.github.io/canonicaljson-spec/ | |
// Probably fairly inefficient, but I really doubt it matters | |
export function encodeCanonicalJSON(jsonNode) { | |
// Escape character | quote | backslash | high surrogate not followed by low, or low surrogate not following | |
// a high surrogate | |
const replaceRegex = /[\u0000-\u001F]|"|\\|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g; | |
const toSlashEscape = { | |
"\b": "\\b", | |
"\t": "\\t", | |
"\n": "\\n", |
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 tokeniseInput = function(inputString) { | |
const tokenise = function(tokens, currentToken, remaining) { | |
if (remaining.length === 0) { | |
return tokens; | |
} | |
const [currentChar, ...newRemaining] = remaining; | |
// Only include the current token if it is not empty | |
const tokensMaybeWithCurrent = function() { |
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
def head(x): | |
return x[0] | |
def tail(x): | |
return x[1:] | |
def powerset(x): | |
if x == []: | |
return [[]] | |
else: |