This file contains 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
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <fstream> | |
#include <algorithm> | |
#include <queue> | |
#include <ostream> | |
#include <ranges> | |
struct location { |
This file contains 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
#include <iostream> | |
#include <type_traits> | |
namespace detail { | |
struct false_type | |
{ | |
const static bool value = false; | |
}; | |
struct true_type |
This file contains 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
export default class TaskQueue { | |
constructor(concurrency) { | |
this.concurrency = concurrency | |
this.running = 0 | |
this.queue = [] | |
} | |
async next() { | |
while(this.running < this.concurrency && this.queue.length) { | |
const task = this.queue.shift() |
This file contains 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
import https from "https"; | |
import { createHash, randomInt } from "crypto"; | |
import { PassThrough, Readable } from "stream"; | |
import { promises as fs } from "fs"; | |
/** | |
* | |
* Please feel free to inform me about a better solution. | |
* | |
*/ |
This file contains 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 DecoratedConsole { | |
constructor(console) { | |
this.console = console; | |
this.RED = "\x1b[31m"; | |
this.GREEN = "\x1b[32m"; | |
this.YELLOW = "\x1b[33m"; | |
this.RESET = "\x1b[0m"; | |
} | |
_getColorString(color, message) { |
This file contains 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 createConsoleProxy(console) { | |
return new Proxy(console, { | |
get: (target, property) => { | |
const proxyFunctionNames = ["log", "error", "debug", "info"]; | |
if (proxyFunctionNames.includes(property)) { | |
return function (...argumentList) { | |
const isoDate = new Date().toISOString(); | |
// Every argument after argumentList[0] will be used as substitution values | |
const newMessage = `${isoDate}: ${argumentList[0]}`; |
This file contains 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
import http from "http"; | |
/*------------------------------------------------------------------------------------------------------------*/ | |
class Queue { | |
constructor(executor) { | |
const queue = []; | |
let resolverFunctions = []; | |
async function enqueue(element) { | |
if(resolverFunctions.length) { | |
const resolve = resolverFunctions.shift(); |
This file contains 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
constexpr unsigned int WIDTH = 1280, HEIGHT = 640; | |
// Update rate in hz | |
constexpr float timerUpdateRate = 60; | |
constexpr float cpuUpdateRate = 600; | |
// How many ticks before timers have to be updated | |
constexpr float cpuTicksToDo = cpuUpdateRate / timerUpdateRate; | |
float currentCpuTicks = 0; |