Skip to content

Instantly share code, notes, and snippets.

View FormerlyZeroCool's full-sized avatar
💭
Back on the grind!

Drew FormerlyZeroCool

💭
Back on the grind!
View GitHub Profile
[1, 2, 3]
[1, next] -> [2, next] -> [3, next] -> null
struct Node {
public:
int data;
Node* next;
export function sleep(ms:number):Promise<void> {
return new Promise<void>((resolve:any) => setTimeout(resolve, ms));
}
export async function crop(image:HTMLImageElement, x:number, y:number, width:number, height:number, image_type:string = "image/png", recurs_depth:number = 0):Promise<HTMLImageElement>
{
const canvas = document.createElement("canvas");
if(image && image.height && image.width)
{
canvas.width = image.width;
canvas.height = image.height;
@FormerlyZeroCool
FormerlyZeroCool / Chip8.cpp
Created March 11, 2023 20:38
chip8 interpreter with verifier
#include <vector>
#include <fstream>
#include <array>
#include <exception>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <thread>
#include <mutex>
@FormerlyZeroCool
FormerlyZeroCool / RGB.ts
Last active March 6, 2023 01:01
Sprite with RGB dependency
export function blendAlphaCopy(color0:RGB, color:RGB):void
{
const alphant:number = color0.alphaNormal();
const alphanc:number = color.alphaNormal();
const a:number = (1 - alphanc);
const a0:number = (alphanc + alphant * a);
const a1:number = 1 / a0;
color0.color = (((alphanc * color.red() + alphant * color0.red() * a) * a1)) |
(((alphanc * color.green() + alphant * color0.green() * a) * a1) << 8) |
@FormerlyZeroCool
FormerlyZeroCool / CrossPlatform.hpp
Last active February 9, 2023 04:12
Conway's Game SDL
/*
* CrossPlatform.hpp
*
* Created on: Jan 11, 2021
* Author: andrewrubinstein
*/
#ifndef CROSSPLATFORM_HPP_
#define CROSSPLATFORM_HPP_
#include <inttypes.h>
@FormerlyZeroCool
FormerlyZeroCool / Makefile
Created February 5, 2023 08:02
Conway's game of life implemented with SDL(with makefile for macos)
#
# Makefile for conway/SDL2
#
CC = g++
CXX = g++
INCLUDE = -I/usr/local/include/SDL
CFLAGS =
CXXFLAGS = -O3 -std=c++2a $(INCLUDE)
#include <array>
#include <iostream>
#include <string_view>
#include <exception>
bool isOperator(char c) noexcept
{
return (c == '*' | c == '/' | c == '+' | c == '-');
}
bool is_digit(unsigned char c) noexcept
{
#include <iostream>
#include <sstream>
int main()
{
//extend this calculator to be able to evaluate eny postfix expression
//building a simple calculator
std::string input("2 3 -");
std::stringstream tokens(input);
int a = 0, b = 0;
#include <string>
#include <array>
#include <iostream>
void naive_solution(std::string &left, std::string &right)
{
for(int i = 0; i < right.length(); i++)
{
//to check if the given character in the right matches any character in the left
for(int j = 0; j < left.length(); j++)
{
const jobs = 1200;
const example_input = 27;
const threads = 16;
const example = async () => {
const pool = new ProcessPool<number, number>(Math.floor(threads), (input:number) => {
let fib = (x:number) => x <=1 ? x : fib(x-1) + fib(x-2);
return fib(input);
}, [], []);
const input:number[] = [];