Skip to content

Instantly share code, notes, and snippets.

{
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([
{wizardSteps.map(
({ path, component: StepComponent, additionalProps }) => (
<Route
key={path}
path={path}
exact
render={routeProps => (
<StepComponent
{...routeProps}
{...additionalProps}
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
{
"sections": [
{
"title": "Flooding",
"questions": [
{
"text": "Is the site within a flood plain?",
"path": ["siteInfo", "flooding", "floodPlain"]
},
{
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);
}
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',
// 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",
// 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",
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() {
def head(x):
return x[0]
def tail(x):
return x[1:]
def powerset(x):
if x == []:
return [[]]
else: