Skip to content

Instantly share code, notes, and snippets.

.then(() => {
var i = 0;
const whileHeapList = () => {
i++;
if (i < 5) {
// artifically delayed call
log.asyncCall().then(log => {
if (log) {
// first inner loop
const firstInnerLoop = () => {
.then(() => {
var i = 0;
const whileHeapList = () => {
i++;
if (i < 5) {
// artifically delayed call
log.asyncCall().then(log => {
if (log) {
// first inner loop
const firstInnerLoop = () => {
const innerWhileLoop = () => {
if (i <= j) {
i++;
// continue
innerWhileLoop();
} else {
// stop iteration
new Promise.resolve();
}
}
// nested Loop
.then(() => {
var heaplist = 4;
const whileHeapList = () => {
if (heaplist) {
heaplist--;
var i = 0;
var j = 5;
const innerWhileLoop = () => {
@liondancer
liondancer / GreenJello.js
Created January 30, 2017 02:44
code I am trying to fix
const wait = fnc => new Promise(fnc => setTimeout(fnc, 0));
const whileHeapList = () => {
var heapNode = null;
var currTimestamp = null;
var nextMinTimestamp = null;
if (minheap.heapList.length) {
heapNode = minheap.popMin();
currTimestamp = heapNode['ts'];
printer.print(heapNode.data);
nextMinTimestamp = minheap.getPeakTimestamp();
const whileCurrTimestampLTENextMinTimestamp = () => {
Promise.all(logSources.map(logSource => {
logSource.popAsync().then(log => {
minheap.insert({
ts: log.date.getTime(),
source: i,
data: log
})
});
}).then(
while (minheap.heapList.length) {
.then(
while (minheap.heapList.length) {
let heapNode = minheap.popMin();
let currTimestamp = heapNode['ts'];
printer.print(heapNode.data);
let nextMinTimestamp = minheap.getPeakTimestamp();
while (currTimestamp <= nextMinTimestamp) {
logSources[heapNode['source']].popAsync().then(log => {
if (log) {
let logtime = log.date.getTime();
.then(
while (minheap.heapList.length) {
let heapNode = minheap.popMin();
let currTimestamp = heapNode['ts'];
printer.print(heapNode.data);
let nextMinTimestamp = minheap.getPeakTimestamp();
while (currTimestamp <= nextMinTimestamp) {
logSources[heapNode['source']].popAsync().then(log => {
if (log) {
let logtime = log.date.getTime();
def searchRange(nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
if nums:
return search(nums, 0, len(nums) - 1, target)
return [-1,-1]