Skip to content

Instantly share code, notes, and snippets.

View gngenius02's full-sized avatar

Ninos Shihale gngenius02

  • Planet Earth
View GitHub Profile
@gngenius02
gngenius02 / setTimeoutReplacement.js
Created July 4, 2021 18:11
replace settimeout with a worker version that works in the background. even when tab is out of focus. This is not tested across browsers. just works on chromium based browsers.
;(function (exports) {
let tid = 0
const timers = new Map()
const jsblob = `
const timers = new Map()
const runTimer = function (id) {
this.postMessage({ id })
timers.delete(id)
}
this.addEventListener('message', (evt) => {
{"_id":"60d90843f2de503b38cedd21","asks":[{"price":"34335.41","volume":"2.945558"},{"price":"34336.91","volume":"1.957166"},{"price":"34336.92","volume":"0.198337"},{"price":"34337.14","volume":"0.58016"},{"price":"34337.18","volume":"0.062053"},{"price":"34340.25","volume":"0.089595"},{"price":"34340.62","volume":"0.093975"},{"price":"34341.99","volume":"0.224002"},{"price":"34342","volume":"0.64"},{"price":"34342.83","volume":"0.187001"}],"bids":[{"price":"34335.4","volume":"0.487535"},{"price":"34333.82","volume":"0.040469"},{"price":"34332.59","volume":"0.004369"},{"price":"34329.53","volume":"0.000295"},{"price":"34326.78","volume":"0.251112"},{"price":"34326.77","volume":"0.4"},{"price":"34325.02","volume":"0.317457"},{"price":"34325.01","volume":"0.19687"},{"price":"34325","volume":"0.001"},{"price":"34323.03","volume":"0.307214"}],"seq":553600,"time":"2021-06-27T16: 22: 42.984-07: 00"}
/**
* FizzBuzz short and quick method.
*/
const fizzbuzz = (int) => !(int % 15) ? "FizzBuzz" : !(int % 5) ? "Buzz" : !(int % 3) ? "Fizz" : int;
let i = 1;
console.log(new Array(100).fill().map(_ => fizzbuzz(i++)))
//delay fn
const delay = (time) => new Promise((resolve) => setTimeout(resolve, parseInt(time * 1000)));
//random fn
const random = () => Math.random() * 1.5;
const iterationArray = new Array(10);
const runFn = async (rounds) => {
let i = -1
for await (round of rounds) {
const time = random()
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("Rolling");
float time = Time.realtimeSinceStartup;
for (int i = 0; i < 10000; i++)
{
GenerateSHA512String('abc');
}
//call the module
const looper = require('./looper')
//create an object to pass to the loop module
const loopOptions = {
fn: () => Math.random(),
max: 1e9
}
looper(loopOptions);