This file contains hidden or 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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
// © Fr3d0C0rl30n3 | |
//@version=4 | |
study("Fr3d0's Volume Profile Visible Range", "VPVR", overlay=true, max_boxes_count=500) | |
DEFAULT_COLOR = color.new(color.gray, 0) | |
BORDER_COLOR = color.new(color.black, 80) | |
BUY_COLOR = color.new(color.green, 0) | |
SELL_COLOR = color.new(color.red, 0) |
This file contains hidden or 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
// This function is just an arbitrary delay to be used with async/await pattern | |
export function delay(ms) { | |
return new Promise(res => | |
setTimeout(() => | |
res(1) | |
, ms) | |
); | |
} | |
/* SmartInterval creates an interval that has the following features: |
This file contains hidden or 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
/* The objective of the two following snippets is to | |
* handle async events with an imperative style of | |
* coding | |
* | |
* I also want the API to be compatible with that of | |
* observables, so that I can drop-in replace them | |
* That means it should also work with "| async" | |
* in Angular | |
* | |
* By convention use $ as suffix to mark the varname |
This file contains hidden or 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
class Stack { | |
constructor() { | |
this.array = [] | |
} | |
push(value) { | |
this.array.push(value) | |
} | |
pop() { |
This file contains hidden or 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
class RandomizedQueue { | |
constructor(array = []) { | |
this.array = array | |
this.size = 0 | |
} | |
isEmpty() { | |
return this.size < 1 | |
} |
This file contains hidden or 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
class Node { | |
constructor() { | |
this.value = null | |
this.prev = null | |
this.next = null | |
} | |
} | |
class Deque { | |
constructor() { |
This file contains hidden or 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
Object.prototype[Symbol.iterator] = function* () { | |
for (const key of Object.keys(this)) { | |
yield this[key] | |
} | |
} | |
var obj = { | |
'mark': 32, | |
'alex': 19, | |
'mary': 25 |
This file contains hidden or 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
class Stack { | |
constructor() { | |
this.array = [] | |
} | |
push(value) { | |
this.array.push(value) | |
} | |
pop() { |
This file contains hidden or 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 getDigit(n, i) { | |
n = Math.abs(n) | |
return (n / 10 ** i | 0) % 10 | |
} | |
function countDigit(n) { | |
if (n === 0) { | |
return 1 | |
} | |
n = Math.abs(n) |
This file contains hidden or 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 pivotHelper(array, start = 0, end = array.length) { | |
let pivotValue = array[start] | |
let pivotIndex = start | |
for (let i = start + 1; i < end; i++) { | |
if (pivotValue >= array[i]) { | |
pivotIndex++ | |
[array[pivotIndex], array[i]] = [array[i], array[pivotIndex]] | |
} | |
} |
NewerOlder