Skip to content

Instantly share code, notes, and snippets.

View zemuldo's full-sized avatar
🇰🇪
Geeks don't sleep

Danstan Onyango zemuldo

🇰🇪
Geeks don't sleep
View GitHub Profile
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
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')
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.
@zemuldo
zemuldo / Redux Advanced list manipulation.js
Last active June 20, 2019 10:59
Redux Advanced list manipulation
// 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' &&