This file contains 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
// weightedRandomSelector.js | |
// | |
// This is a simple weighted random selector, works in Rhino, can use within an | |
// Apigee JavaScript step. | |
// | |
// last saved: <2021-December-02 13:11:16> | |
// | |
// -------------------------------------------------------- | |
(function (){ |
This file contains 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 org.bouncycastle.asn1.ASN1EncodableVector; | |
import org.bouncycastle.asn1.ASN1Integer; | |
import org.bouncycastle.asn1.ASN1Sequence; | |
import org.bouncycastle.asn1.DERSequence; | |
import java.math.BigInteger; | |
private static byte[] toP1363(byte[] asn1EncodedSignature) throws Exception { | |
ASN1Sequence seq = ASN1Sequence.getInstance(asn1EncodedSignature); | |
BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getValue(); | |
BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getValue(); |
This file contains 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
/* jshint esversion:6, node:false, strict:implied */ | |
/* global print, context */ | |
function createPartialCopy(obj, partialPropertyList) { | |
// create new "partial copy" with only a subset of properties | |
return partialPropertyList.reduce(function(a, prop) { | |
a[prop] = obj[prop]; | |
return a; | |
}, {}); | |
} |
This file contains 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
#!/bin/bash | |
# uncomment to debug | |
# set -x | |
usage() { | |
printf "%s: display subject and issuer of certificates in the chain that a host presents\n" $0 | |
printf "usage:\n" | |
printf " %s HOSTNAME\n" $0 | |
printf " show cert subject and issuer\n\n" |
This file contains 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
<Javascript name='JS-ShredJSON' timeLimit='200' > | |
<Properties> | |
<Property name='output-prefix'>private</Property> | |
<Property name='source'>ContextVariableContainingJSON</Property> | |
</Properties> | |
<ResourceURL>jsc://extractJsonToContextVars.js</ResourceURL> | |
</Javascript> |
This file contains 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
// getTokenWithServiceAccount.js | |
// ------------------------------------------------------------------ | |
// uses only builtin modules, no external dependencies. | |
/* jshint esversion:9, node:true, strict:implied */ | |
/* global process, console, Buffer */ | |
const crypto = require('crypto'), | |
util = require('util'), |
This file contains 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
// invokeCallsWithLimit.js | |
// ------------------------------------------------------------------ | |
// | |
/* jshint esversion:6, node:false, strict:implied */ | |
/* global properties, httpClient, context, Request */ | |
// Specify the limit of concurrent outbound requests | |
const ASYNC_LIMIT = 3; |
This file contains 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
/* tweak-expiry-display.js */ | |
/* jshint esversion:9, browser:true, strict:implied */ | |
/* global window, navigator, console, fetch, Buffer */ | |
/* | |
Instructions | |
Add this as a "custom script" in the "Settings" dialog for the portal. | |
Be sure to bracket this source with open-and-close script tags. |
This file contains 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
(First create a service account and create+download a keyfile for it) | |
KEY_FILE=~/Downloads/name-of-the-downloaded-keyfile.json | |
(download and install gcloud if you don't have it) | |
gcloud components update | |
gcloud auth list |
This file contains 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
// weightedRandomSelector.js | |
// | |
// simple weighted random selector. | |
// | |
// Copyright © 2013, 2014 Dino Chiesa and Apigee Corp | |
// All rights reserved. | |
// | |
// created: Fri, 26 Jul 2013 11:14 | |
// last saved: <2019-June-24 06:13:20> | |
// |