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
// restaurants are loaded... | |
var restaurants = [ | |
{ | |
"id": 324, | |
"name": "Tien Hiang", | |
}, | |
{ | |
"id": 329, | |
"name": "Hank Burger", | |
}, |
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
import React, { Component } from 'react' | |
const withHoverWatcher = WrappedComponent => { | |
return class extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
isMouseHover: false | |
} | |
this.elRef = null |
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 domainUsesGoogleMail = domain => { | |
return fetch('https://dns.google.com/resolve?name=' + encodeURIComponent(domain) +'&type=MX').then(res => res.json()).then(d => { | |
return d.Answer.reduce((acc, val) => { | |
return acc || (val.data.indexOf('google.com.') >= 0 || val.data.indexOf('googlemail.com.') >= 0) | |
}, false) | |
}) | |
} | |
const showMailServer = domain => { | |
domainUsesGoogleMail(domain).then(r => { | |
console.log(r ? `${domain} uses Google Mail` : `${domain} does not use Google Mail`) |
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 evaluate(context){ | |
var d = new Date(); | |
return d.getTime() + (d.getMilliseconds() / 1000); | |
}; |
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 getHashedId($id) { | |
$random = base64_encode(random_bytes(32)); | |
$stringToSign = $id . "\0" . $random; | |
$hash = hash('sha256', $stringToSign); | |
return base64_encode($hash . "\0" . $random); | |
} | |
function verifyHashedId($id, $hashedId) { |
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 futurePromise() { | |
var _resolve = null; | |
var _reject = null; | |
this.promise = new Promise(function(resolve, reject) { | |
_resolve = resolve; | |
_reject = reject; | |
}); | |
this.then = function() { | |
return this.promise.then(...arguments); |
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 evaluate(context){ | |
var stringToSign = ''; | |
var request = context.getCurrentRequest(); | |
var bodyKeys = request.getUrlEncodedBodyKeys().sort(); | |
for (var i = 0; i < bodyKeys.length; i++) { | |
var key = bodyKeys[i]; | |
if ('signature' !== key) { | |
stringToSign += key + "=" + request.getUrlEncodedBodyKey(key); | |
} |
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 evaluate(context){ | |
var request = context.getCurrentRequest(); | |
var bodyParams = request.getUrlEncodedBody(); | |
for (var property in bodyParams) { | |
if (bodyParams.hasOwnProperty(property)) { | |
console.log("" + property + " > " + bodyParams[property]); | |
} | |
} | |
return bodyParams; | |
}; |
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 evaluate(context){ | |
var g = context.getRequestGroupByName("New Group"); | |
return g.getChildren().map(function(c){return c.name;}).join(", "); | |
}; |
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
// context docs: https://paw.cloud/docs/reference/ExtensionContext | |
// request docs: https://paw.cloud/docs/reference/Request | |
// DynamicString docs: https://paw.cloud/docs/reference/DynamicString | |
// DynamicValue docs: https://paw.cloud/docs/reference/DynamicValue | |
function logRequestVariableInfo(requestVariable) { | |
console.log('Request Variable: ' + requestVariable.name + '\n' + | |
' Request: ' + requestVariable.request.name + '\n' + | |
' Value: ' + requestVariable.value + '\n' + | |
' Description: ' + requestVariable.description + '\n' + |