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
const crypto = require('crypto'); | |
const signSecret = process.env.SLACK_SIGN_SECRET; | |
const validateRequest = (requestSignature, requestTime, rawBody, validFor = 300) => { | |
const requestValidFrom = Math.floor(Date.now() / 1000) - validFor; | |
if (requestTime < requestValidFrom) { | |
throw new Error(`Request outdated: !(${requestTime} < ${requestValidFrom})`); | |
} |
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 { EventEmitter } from 'events'; | |
const debug = require('debug')('wsmonitor'); | |
/* | |
Give it a websocket to monitor and it'll assert connectivity, handling ping/pong events, and emit actionable state events. | |
Emits events: | |
- connected : connection successfully opened | |
- disconnected : connection dropped or was terminated, reconnect required if desired | |
- wserror : connection saw error |
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
const mstr = require('microstrategy'); | |
/* | |
This uses the unofficial `microstrategy` nodejs module, found on npm, to: | |
- load a group from the metadata | |
- read the current group object properties (specifically interested in ACLs) | |
- make a request to add my user to the ACL list, with full control access | |
*/ | |
(async ()=> { | |
const mstrApi = new mstr.REST({ | |
baseUrl: 'http://10.27.72.72:8080/2020u1Library/api' |
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
// Loop through each visualization found in the current page (via `mstrmojo.all`) and execute a callback | |
function forEachVisualization(mojoAllObject, perVizCallback, completionCallback) { | |
var visualizations = Object.values(mojoAllObject).filter(function(e){ return e.scriptClass == 'mstrmojo.vi.ui.rw.VizBox' }); | |
for (var i=0;i < visualizations.length;i++){ | |
perVizCallback && perVizCallback(visualizations[i], visualizations, i); | |
} | |
completionCallback && completionCallback(visualizations); | |
} | |
// Example perVizCallback - adds a button to the top-right of each visualization in a dossier |
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
// automatically monitors websockets for unexpected disconnects, then terminates and sockets that stopped responding. | |
// This allows the onClose event to handle reconnects. | |
const monitorWebsocket = ws => { | |
ws.on('error', () => { | |
ws.isAlive = true; | |
}); | |
ws.on('close', () => { | |
ws.isAlive = true; | |
}); |
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
const request = require('request-promise'); | |
const apiRoot = 'http://aps-tsiebler-vm:8080/11.1GALibrary/api'; | |
const isSessionCookie = cookie => { | |
return cookie.startsWith('JSESSIONID'); | |
}; | |
const getSession = async (username = '', password = '', otherVars = {}) => { | |
const requestOptions = { |
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
{"ohlcv":[[1548543599999,0.3121,0.31317,0.3121,0.31292,984647.7],[1548547199999,0.31276,0.31299,0.31231,0.31258,491215.1],[1548550799999,0.3126,0.31372,0.31003,0.31339,3585305],[1548554399999,0.31339,0.3137,0.31251,0.31319,1238543.7],[1548557999999,0.31312,0.31409,0.31284,0.31305,958885.5],[1548561599999,0.3131,0.31312,0.3121,0.31233,816783.6],[1548565199999,0.31237,0.31258,0.31122,0.31149,2771745.9],[1548568799999,0.31141,0.3117,0.31123,0.31153,1607515.7],[1548572399999,0.31153,0.31197,0.31129,0.31141,549997],[1548575999999,0.31141,0.31157,0.31031,0.31101,1410985.5],[1548579599999,0.31101,0.31155,0.3102,0.3107,1223119],[1548583199999,0.3107,0.31085,0.307,0.30862,3442654.6],[1548586799999,0.30862,0.30889,0.30687,0.30719,2418293.2],[1548590399999,0.30713,0.30799,0.30501,0.30655,2658867],[1548593999999,0.3065,0.30658,0.30576,0.30588,1757229.1],[1548597599999,0.30587,0.30797,0.30512,0.3067,1811089.7],[1548601199999,0.30683,0.3075,0.30272,0.30677,4200062],[1548604799999,0.30677,0.3085,0.30633,0.3074,1773647.3],[1 |
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
{"ohlcv":[[1547661600000,0.3261,0.3285,0.32287,0.32347,4437838.3],[1547668800000,0.32348,0.32583,0.322,0.3241,3687461.7],[1547676000000,0.32406,0.3273,0.32284,0.3257,2037472.6],[1547683200000,0.3258,0.32664,0.32437,0.32599,2374213.6],[1547690400000,0.32599,0.32641,0.32011,0.32329,6132092.8],[1547697600000,0.32326,0.32376,0.32222,0.32227,2303730.2],[1547704800000,0.32227,0.32425,0.322,0.32405,2231340.3],[1547712000000,0.32423,0.32451,0.32242,0.32262,2669430.4],[1547719200000,0.32247,0.3245,0.31926,0.32389,5440536.5],[1547726400000,0.32374,0.32398,0.3218,0.32189,2440560.9],[1547733600000,0.3219,0.32534,0.32121,0.32432,4930068.7],[1547740800000,0.3243,0.32722,0.3223,0.32433,6339789.4],[1547748000000,0.3245,0.326,0.32382,0.3247,2946770.7],[1547755200000,0.32471,0.3284,0.32327,0.32389,4046485.2],[1547762400000,0.32389,0.3265,0.32219,0.32489,4627556.9],[1547769600000,0.32468,0.32548,0.32275,0.32318,3005643.9],[1547776800000,0.3232,0.32499,0.32318,0.32381,1305064.5],[1547784000000,0.32371,0.32427,0.32237,0.32305,167 |
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
{"ohlcv":[[1539016200000,0.49395,0.49497,0.49125,0.49319,2483674.4],[1539018000000,0.49319,0.49385,0.49177,0.4932,1802643],[1539019800000,0.49311,0.494,0.4925,0.49337,1591872],[1539021600000,0.49337,0.4939,0.49056,0.49097,1900166],[1539023400000,0.49097,0.49199,0.49011,0.4905,1954349.9],[1539025200000,0.49054,0.49498,0.49052,0.4942,2210880.3],[1539027000000,0.49419,0.49739,0.49397,0.49572,3461677.1],[1539028800000,0.49572,0.4962,0.4935,0.49435,1545820.6],[1539030600000,0.49417,0.4964,0.49417,0.49566,1466366.6],[1539032400000,0.4955,0.49588,0.4939,0.49451,1267737.9],[1539034200000,0.49409,0.49499,0.49351,0.49372,1412942.5],[1539036000000,0.49373,0.49403,0.49205,0.49263,1707114.6],[1539037800000,0.49282,0.49344,0.49185,0.49185,1526666.7],[1539039600000,0.492,0.494,0.4916,0.49293,1298221.8],[1539041400000,0.49294,0.49338,0.492,0.49335,1314119.2],[1539043200000,0.49302,0.49387,0.491,0.49278,1815117.8],[1539045000000,0.49256,0.49278,0.4885,0.4896,2182405],[1539046800000,0.48906,0.4899,0.48224,0.48699,3381114.3],[1 |
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
// tradesList = [{},...] | |
// saveObjectToFile(tradesList, `./data/${symbol}_f${fromMS}_t${toMS}.json`) | |
const fs = require('fs'); | |
module.exports = (object, filepath) => { | |
return new Promise((resolve, reject) => { | |
const objStr = JSON.stringify(object); | |
fs.writeFile(filepath, objStr, function(err) { | |
if (!err) return resolve(); |