Skip to content

Instantly share code, notes, and snippets.

View mukulmishra18's full-sized avatar

Mukul Mishra mukulmishra18

View GitHub Profile
@mukulmishra18
mukulmishra18 / pizza.js
Created April 1, 2018 20:58
Pizza ordering service.
/** Pizza Service.
*
* When a new order will come handleOrder class can handle the task
* by checking if order can be fulfilled in the given time interval.
* For priority customer it is 15 minutes and for rest it is 30 minutes.
*
* -- When order can be flufilled handleOrder.ready = Unresolved promise.
* -- When order cannot be flufilled handleOrder.ready = Resolved promise.
* By doing this, incoming orders can wait for promise queue to fulfill.
* Orders are arranged in time series and handled as a first come first serve.
.declareMethod('calculateDuration', function (data) {
// Create a temporary audio element and assign the data to
// calculate the time duration.
var gadget = this,
audioElement = document.createElement('audio');
audioElement.src = URL.createObjectURL(data);
return RSVP.Queue()
.push(function () {
return promiseEventListener(
audioElement,
var rr = [{"top":11,"time":1937},{"top":14,"time":1954},{"top":21,"time":1970},{"top":34,"time":1986},{"top":52,"time":2003},{"top":76,"time":2019},{"top":106,"time":2036},{"top":141,"time":2052},{"top":177,"time":2069},{"top":211,"time":2086},{"top":239,"time":2103},{"top":259,"time":2119},{"top":271,"time":2136},{"top":274,"time":2152},{"top":275,"time":2170},{"top":278,"time":2303},{"top":295,"time":2319},{"top":329,"time":2336},{"top":378,"time":2353},{"top":439,"time":2370},{"top":508,"time":2386},{"top":582,"time":2403},{"top":651,"time":2420},{"top":704,"time":2436},{"top":737,"time":2453},{"top":750,"time":2470},{"top":752,"time":2486},{"top":753,"time":2704},{"top":790,"time":2720},{"top":879,"time":2736},{"top":1005,"time":2754},{"top":1127,"time":2770},{"top":1205,"time":2786},{"top":1229,"time":2803},{"top":1232,"time":2986},{"top":1239,"time":3003},{"top":1251,"time":3019},{"top":1272,"time":3037},{"top":1302,"time":3053},{"top":1344,"time":3071},{"top":1396,"time":3086},{"top":1458,"time":3103},
var rr = [{"top":8165,"time":2042},{"top":8169,"time":2075},{"top":8181,"time":2124},{"top":8211,"time":2169},{"top":8222,"time":2210},{"top":8258,"time":2253},{"top":8331,"time":2294},{"top":8366,"time":2327},{"top":8446,"time":2365},{"top":8545,"time":2411},{"top":8584,"time":2459},{"top":8586,"time":2503},{"top":8588,"time":2825},{"top":8608,"time":2872},{"top":8686,"time":2921},{"top":8746,"time":2971},{"top":8796,"time":3015},{"top":8833,"time":3057},{"top":8918,"time":3102},{"top":8971,"time":3146},{"top":9008,"time":3195},{"top":9010,"time":3241},{"top":9012,"time":3492},{"top":9017,"time":3536},{"top":9069,"time":3582},{"top":9108,"time":3628},{"top":9170,"time":3677},{"top":9233,"time":3724},{"top":9382,"time":3806},{"top":9432,"time":4067},{"top":9434,"time":4354},{"top":9437,"time":4487},{"top":9709,"time":4548},{"top":9911,"time":4607},{"top":9914,"time":5210},{"top":9925,"time":5268},{"top":9990,"time":5331},{"top":10030,"time":5389},{"top":10081,"time":5451},{"top":10187,"time":5511},{"top":1026
var rr = [{"top":11,"time":1937},{"top":14,"time":1954},{"top":21,"time":1970},{"top":34,"time":1986},{"top":52,"time":2003},{"top":76,"time":2019},{"top":106,"time":2036},{"top":141,"time":2052},{"top":177,"time":2069},{"top":211,"time":2086},{"top":239,"time":2103},{"top":259,"time":2119},{"top":271,"time":2136},{"top":274,"time":2152},{"top":275,"time":2170},{"top":278,"time":2303},{"top":295,"time":2319},{"top":329,"time":2336},{"top":378,"time":2353},{"top":439,"time":2370},{"top":508,"time":2386},{"top":582,"time":2403},{"top":651,"time":2420},{"top":704,"time":2436},{"top":737,"time":2453},{"top":750,"time":2470},{"top":752,"time":2486},{"top":753,"time":2704},{"top":790,"time":2720},{"top":879,"time":2736},{"top":1005,"time":2754},{"top":1127,"time":2770},{"top":1205,"time":2786},{"top":1229,"time":2803},{"top":1232,"time":2986},{"top":1239,"time":3003},{"top":1251,"time":3019},{"top":1272,"time":3037},{"top":1302,"time":3053},{"top":1344,"time":3071},{"top":1396,"time":3086},{"top":1458,"time":3103},
var rr = [{"top":11,"time":1937},{"top":14,"time":1954},{"top":21,"time":1970},{"top":34,"time":1986},{"top":52,"time":2003},{"top":76,"time":2019},{"top":106,"time":2036},{"top":141,"time":2052},{"top":177,"time":2069},{"top":211,"time":2086},{"top":239,"time":2103},{"top":259,"time":2119},{"top":271,"time":2136},{"top":274,"time":2152},{"top":275,"time":2170},{"top":278,"time":2303},{"top":295,"time":2319},{"top":329,"time":2336},{"top":378,"time":2353},{"top":439,"time":2370},{"top":508,"time":2386},{"top":582,"time":2403},{"top":651,"time":2420},{"top":704,"time":2436},{"top":737,"time":2453},{"top":750,"time":2470},{"top":752,"time":2486},{"top":753,"time":2704},{"top":790,"time":2720},{"top":879,"time":2736},{"top":1005,"time":2754},{"top":1127,"time":2770},{"top":1205,"time":2786},{"top":1229,"time":2803},{"top":1232,"time":2986},{"top":1239,"time":3003},{"top":1251,"time":3019},{"top":1272,"time":3037},{"top":1302,"time":3053},{"top":1344,"time":3071},{"top":1396,"time":3086},{"top":1458,"time":3103},
#! /usr/bin/python
from __future__ import print_function
import subprocess
import sys
import time
if (len(sys.argv)) != 2:
print("usage:", sys.argv[0], "<pid>")
sys.exit(1)
(function p(d) {
var t = rr.shift();
setTimeout(function () {
document.getElementById("viewerContainer").scrollTop = t.top;
p(t.time)
}, t.time - d);
})(0)
var rr = [], tt = Date.now();
document.getElementById("viewerContainer").addEventListener("scroll", () => rr.push({
top: document.getElementById("viewerContainer").scrollTop,
time: Date.now() - tt
}));
@mukulmishra18
mukulmishra18 / getTextContentStream.js
Created April 17, 2017 15:40
getTextContent function of PDF.js with sendWithStream
getTextContent: function PDFPageProxy_getTextContent(params) {
var readableStream = this.transport.messageHandler.sendWithStream('GetTextContent', {
pageIndex: this.pageNumber - 1,
normalizeWhitespace: (params && params.normalizeWhitespace === true ?
true : /* Default */ false),
combineTextItems: (params && params.disableCombineTextItems === true ?
false : /* Default */ true),
});
return new Promise(function (resolve, reject) {
readAllChunks(readableStream);