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
// Return a new array, a subset of `list`, which matches `filter`. Assumes an | |
// array of objects and cyclers through each object, and looks at each property, | |
// and compares all string properties to the value of the `filter` string, | |
// returning only those which contain an exact match. | |
const filteredList = (filter = '', list = []) => { | |
if (filter) { | |
return list.filter((el) => { | |
return Object.keys(el).some((prop) => { | |
return el[prop] && | |
typeof el[prop] === 'string' && |
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 express = require('express'); | |
const client = require('./tcp/client'); | |
const EventEmitter = require('events'); | |
class OnDataEmitter extends EventEmitter { } | |
const OnData = new OnDataEmitter(); | |
const app = express() | |
// TCP Client data event listener that handles data event by the client. |
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 net = require('net'); | |
const server = net.createServer(); | |
const config = { | |
host: '0.0.0.0', | |
port: 9670, | |
exclusive: true, | |
} | |
server.on('connection', (socket) => { | |
console.log('New client connected') |
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 net = require('net'); | |
const client = new net.Socket(); | |
const config = { | |
host: '0.0.0.0', | |
port: 9670, | |
exclusive: true, | |
} | |
const timeout = 3000; | |
let retrying = false; | |
// Functions to handle client events |
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
# Ensure to execute chmod 777 path/to/this/file | |
# Configure your env variables here | |
export PG_USER=username | |
export PG_PASSWORD=password | |
export PG_HOST=prod_db_host | |
export DATABASE=prod_db | |
# Create database, Run migrations Compile app and Start Server | |
MIX_ENV=prod mix compile.protocols |
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 i_am_last_but_i_take_1_sec() { | |
return setTimeout(() => { | |
console.log('i was no: 5 and i take 1 second') | |
}, 1000); | |
} | |
function i_am_fourth_but_i_take_4_sec() { | |
return setTimeout(() => { | |
console.log('i was no: 4 and i take 4 seconds') | |
}, 4000); |
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 i_am_last_but_i_take_1_sec(callback) { | |
return setTimeout(() => { | |
console.log('i was no: 5 and i take 1 second') | |
callback() | |
}, 1000); | |
} | |
function i_am_fourth_but_i_take_4_sec(callback) { | |
return setTimeout(() => { | |
console.log('i was no: 4 and i take 4 seconds') |
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 run (){ | |
i_am_first_but_i_take_10_sec(()=>{ | |
let error_0 | |
if(error_0) throw Error(error_0) | |
else { | |
i_am_second_but_i_take_8_sec(()=>{ | |
let error_1 | |
if(error_1) throw Error(error_1) | |
else{ | |
i_am_second_but_i_take_8_sec(()=>{ |
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 i_am_last_but_i_take_1_sec() { | |
return new Promise((resolve, reject)=>{ | |
setTimeout(() => { | |
console.log('i was no: 5 and i take 1 second') | |
resolve('done') | |
}, 1000); | |
}) | |
} | |
function i_am_fourth_but_i_take_4_sec() { |
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 run (){ | |
i_am_first_but_i_take_10_sec() | |
.then(() => { | |
return i_am_second_but_i_take_8_sec() | |
}) | |
.then(() => { | |
return i_am_third_but_i_take_6_sec() | |
}) | |
.then(() => { |
OlderNewer