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
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all | |
var p1 = Promise.resolve(3); | |
var p2 = 1337; | |
var p3 = new Promise((resolve, reject) => { | |
setTimeout(resolve, 100, "foo"); | |
}); | |
Promise.all([p1, p2, p3]).then(values => { | |
console.log(values); // [3, 1337, "foo"] | |
}); |
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
p1.then((result) => { | |
// do something return something | |
}).then((result1) => { | |
// do something return something | |
}).then((result2) => { | |
// do something return something | |
}).catch((error) => { | |
// if there's an error will catch it here | |
}); |
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
'use strict'; | |
const Waterfall = require('../index'); | |
const getSomeDataFromDB = () => { | |
return new Promise((resolve) => { | |
return setTimeout(() => { | |
resolve([ | |
{ id: 1 }, | |
{ id: 2 } | |
]); |
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
function isUserAuthenticate(session, callback) { | |
openDatabase(function(db) { | |
getCollection(db, 'sessions', function(col) { | |
find(col, {'session': session},function(result) { | |
result.filter(function(error, user) { | |
callback(error, user); | |
}) | |
}) | |
}) | |
}) |
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
function passMeCallback(options, callback) { | |
//do something | |
const err = null; | |
const result = options;//some data goes here | |
return callback(err, result); | |
} | |
passMeCallback({ age: 30 }, function(err, result) { | |
console.log(result); //this will be the options we just passed to the 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
version: "2" | |
services: | |
postgres: | |
image: postgres:9.6.1 | |
container_name: postgres | |
environment: | |
- POSTGRES_PASSWORD=TCrGaanoC2s7gT | |
ports: | |
- "15432:5432" |
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
FROM progrium/busybox | |
MAINTAINER Doron Segal <[email protected]> | |
# Java config | |
ENV DRUID_VERSION 0.9.1.1 | |
ENV JAVA_HOME /opt/jre1.8.0_40 | |
ENV PATH $PATH:/opt/jre1.8.0_40/bin | |
# Druid env variable | |
ENV DRUID_XMX '-' |
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
# | |
# Table partitioning with postgreSQL | |
# the master_table should be empty, data will only be inside the childs table | |
# | |
# CREATE MASTER TABLE | |
CREATE TABLE master_table ( | |
id BIGINT, | |
username VARCHAR (50) UNIQUE NOT NULL, | |
description TEXT); |
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
'use strict'; | |
const Memwatch = require('memwatch-next'); | |
const Util = require('util'); | |
if (Config.env === 'production') { | |
/** | |
* Check for memory leaks | |
*/ | |
let hd = null; | |
Memwatch.on('leak', (info) => { |
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
'use strict'; | |
const Memwatch = require('memwatch-next'); | |
const Util = require('util'); | |
if (Config.env === 'production') { | |
/** | |
* Check for memory leaks | |
*/ | |
let hd = null; | |
Memwatch.on('leak', (info) => { |