Skip to content

Instantly share code, notes, and snippets.

View 4skinSkywalker's full-sized avatar
♥️
Stay strong guys!

Fred's GitHub 4skinSkywalker

♥️
Stay strong guys!
  • Italy
View GitHub Profile
@4skinSkywalker
4skinSkywalker / VPVR.pine
Last active May 24, 2024 08:41
Volume Profile Visible Range in Pine Script
// 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)
@4skinSkywalker
4skinSkywalker / smart-interval.js
Created October 2, 2021 16:00
This is like an interval but can be start/paused/resumed/forced and evaluates calls sequentially
// 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:
@4skinSkywalker
4skinSkywalker / async-utilities.js
Created October 2, 2021 15:57
This two snippets mimic what BehaviorSubject and Subject do (as I use them)
/* 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
class Stack {
constructor() {
this.array = []
}
push(value) {
this.array.push(value)
}
pop() {
class RandomizedQueue {
constructor(array = []) {
this.array = array
this.size = 0
}
isEmpty() {
return this.size < 1
}
class Node {
constructor() {
this.value = null
this.prev = null
this.next = null
}
}
class Deque {
constructor() {
Object.prototype[Symbol.iterator] = function* () {
for (const key of Object.keys(this)) {
yield this[key]
}
}
var obj = {
'mark': 32,
'alex': 19,
'mary': 25
class Stack {
constructor() {
this.array = []
}
push(value) {
this.array.push(value)
}
pop() {
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)
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]]
}
}