Skip to content

Instantly share code, notes, and snippets.

const mqtt = require('mqtt');
const _ = require('lodash');
const memwatch = require('memwatch-next');
const util = require('util');
const setTimeoutPromise = util.promisify(setTimeout);
memwatch.on('leak', (info) => {
console.error('Memory leak detected:\n', info);
});
@stephendeyoung
stephendeyoung / ioredis.js
Created February 12, 2018 09:16
ioredis discover newly added nodes
const Redis = require('ioredis');
const _ = require('lodash');
const randomstring = require('randomstring');
const util = require('util');
let redisCluster;
async function createRedisCluster() {
const cluster = new Redis.Cluster([{
port: 30001,
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" (
entity_id VARCHAR(64),
avg_power DOUBLE);
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
SELECT STREAM
entity_id,
AVG(active_power) OVER secs_window
FROM "SOURCE_SQL_STREAM_001"
WINDOW
secs_window AS (PARTITION BY entity_id RANGE INTERVAL '5' SECOND PRECEDING)
console.log('hey')
EVT.use(EVT.Hub);
app.getAvailableHubs().then(function(hubs) {
console.log('hey2');
EVT.Hub.setup({
targetHub: hubs[0],
remote: false
});
/*
(c) Copyright Reserved EVRYTHNG Limited 2016. All rights reserved.
Use of this material is subject to license.
Copying and unauthorised use of this material strictly prohibited.
*/
const evtClient = new EVT.TrustedApp(apiKey);
function onThngPropertiesChanged(event) {
console.log('Running onThngPropertiesChanged');
evtClient.thng('UDhdsNDnAYNC52aBEQM2rrWm').action('_custom').create({
/*
(c) Copyright Reserved EVRYTHNG Limited 2016. All rights reserved.
Use of this material is subject to license.
Copying and unauthorised use of this material strictly prohibited.
*/
const evtClient = new EVT.TrustedApp(apiKey);
function onThngPropertiesChanged(event) {
console.log('event: ', event);
}
exports.onThngPropertiesChanged = (event) => {
console.log('Running onThngPropertiesChanged6');
}
exports.onThngPropertiesChanged = (event) => {
console.log('Running onThngPropertiesChanged5');
}
exports.onThngPropertiesChanged = (event) => {
console.log('Running onThngPropertiesChanged4');
}
exports.onThngPropertiesChanged = (event) => {
console.log('Running onThngPropertiesChanged3');
}