Skip to content

Instantly share code, notes, and snippets.

View exodus4d's full-sized avatar

Mark Friedrich exodus4d

View GitHub Profile
@exodus4d
exodus4d / winnmp.log
Last active November 5, 2018 19:42
winnmp.log
Terminating 80
Terminating ALL processes..
Terminating 6379
Terminating 9002
Terminating 9003
@exodus4d
exodus4d / processJSON.php
Created February 17, 2019 13:20
reactphp NDJSON client decoder
<?php
// NDJSON Ping/Pong communication:
// 1. Client send ONE JSON object
// 2. Server respond with ONE JSON obect
// 3. Client MIGHT send another JSON object
// 4. Server WOULD respond with OND JSON object
// 5. ....
// Questions:
// [1] I use first() in combination with once(), because a data chunk MIGHT contain multiple NDJSON objects
// 2nd, 3rd object should be ignored... Is this a good practice?

Add more features [advanced]

At some point you might get limited by the Queue class as a data-structure. You have to add methods for new features, that break the definition of a Queue.

  • Multi threaded dequeue(): Maybe you want to break the limit of "one request after the other". E.g. run up to max 5 tasks parallel. You can replace this._pendingPromise (true|false) flag with a counter and check insinside dequeue().

async dequeue() {

@exodus4d
exodus4d / morris.esm.js
Last active February 6, 2021 15:27
Morris.js - ES6 Module - Example
import Raphael from 'raphael';
var Morris, compStyle, minutesSpecHelper, secondsSpecHelper,
__slice = [].slice,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
Morris /* = window.Morris*/ = {};