Skip to content

Instantly share code, notes, and snippets.

View MadeinDave's full-sized avatar

MadeinDave MadeinDave

View GitHub Profile
@matteocaberlotto
matteocaberlotto / helper.cpp
Created June 19, 2024 07:31
An helper to cycle RGB colors in cpp
/**
* Example usage:
Color *colors[100] = {
new Color(255,0,0),
new Color(0,255,0),
new Color(0,0,255)
};
ColorLoop *loop = new ColorLoop(colors, 3, 50);
@avgmensch
avgmensch / Makefile
Last active February 17, 2024 15:25
Makefile_GCC_Artistic-Style
# MIT License
#
# Copyright (c) 2024 AverageMensch
#
# https://gist.github.com/avgmensch/3c78902ac0dca05869e6540c36596c2c
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@guest271314
guest271314 / javascript_engines_and_runtimes.md
Last active September 27, 2025 22:47
A list of JavaScript engines, runtimes, interpreters

V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others. It implements ECMAScript and WebAssembly, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors. V8 can run standalone, or can be embedded into any C++ application.

SpiderMonkey is Mozilla’s JavaScript and WebAssembly Engine, used in Firefox, Servo and various other projects. It is written in C++, Rust and JavaScript. You can embed it into C++ and Rust projects, and it can be run as a stand-alone shell. It can also be [compiled](https://bytecodealliance.org/articles/making-javascript-run-fast-on

@thass0
thass0 / 0-c-arrays.md
Last active December 18, 2024 08:59
Using heap-allocated and bound-check arrays in C

The following programs demonstrate how VLAs can be used in some pretty cool ways in C. They allow creating dynamic array types, with information about the size of the array being known only at runtime.

  • The first example shows how this kind of information can be attached to VLAs which are completely heap-allocated, and never touch the stack.
  • In the second example, the information attached to the type of the array is used in combination with UBSan to check for out of bounds access to the array at runtime!
  • Lastly, the third example demonstrates why we have to use this weird special syntax to correctly dereference and access pointers to VLAs.

Examples two and three make use of the fact that classic, fixed-size C arrays are interoperable with VLAs. That is, given a fixed-size array, we're able to pass it and its its size to a function that expects a VLA.

@imaami
imaami / Makefile
Last active March 6, 2024 19:52
#template<>
override BIN := test
override SRC := test.c msg.c
override OBJ := $(SRC:%=%.o)
override DEP := $(SRC:%=%.d)
CFLAGS := -O2 -march=native -mtune=native -flto
$(BIN): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
@papes1ns
papes1ns / dexec.sh
Created May 17, 2023 02:15
dexec.sh
#!/usr/bin/env bash
set -eu # do not proceed on error
if [ $# -lt 1 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
cat <<EOF
Quick command to get a shell inside a running docker container.
Usage: dexec [container_name] [command]
@rbitr
rbitr / random_notes.md
Last active November 10, 2023 16:34
Confusion about using $RANDOM to generate random numbers

Random numbers in bash et al

There is a variable $RANDOM than you can read in bash or zsh to get a random number beteen 0 and 32767. Here in zsh on my (old) mac:

% echo $RANDOM
13757
% echo $RANDOM
16896
@raysan5
raysan5 / raylib_vs_sdl.md
Last active September 13, 2025 19:36
raylib vs SDL - A libraries comparison

raylib_vs_sdl

In the last years I've been asked multiple times about the comparison between raylib and SDL libraries. Unfortunately, my experience with SDL was quite limited so I couldn't provide a good comparison. In the last two years I've learned about SDL and used it to teach at University so I feel that now I can provide a good comparison between both.

Hope it helps future users to better understand this two libraries internals and functionality.

Table of Content

@HipHopHuman
HipHopHuman / incremental-game-loop.md
Last active September 27, 2025 09:41
How to make a game loop for your idle game

How do I make a game loop for my Idle Game?

Interval-Based Resource Generators

So, you want to build an idle/incremental game in JavaScript and you’ve read on the internet that setInterval is the way to go when it comes to handling resources that automatically generate over time.

You get started, you write down your setInterval function, you set it to trigger once every 1000 milliseconds, and every time it triggers, you add 1 to the player’s total resource count. Perfect. It works.

Uh-oh.

@zserge
zserge / ray.cc
Last active April 9, 2024 11:49
Minimal ray tracer for leaning purposes
#include <array>
#include <cmath>
#include <fstream>
#include <iostream>
#include <vector>
struct Vec {
float x, y, z;
Vec(float vx, float vy, float vz) : x(vx), y(vy), z(vz) {}
Vec operator+(Vec vec) { return {x + vec.x, y + vec.y, z + vec.z}; }