Skip to content

Instantly share code, notes, and snippets.

@bitnenfer
bitnenfer / frame-time.js
Created March 15, 2024 12:43
Simple frame time counter with display for HTML and JS
class FrameTime {
constructor() {
this.parent = document.body;
this.lastTime = performance.now();
this.lastFrameTime = 0.0;
this.frameCounter = 0;
this.accumulatedTime = 0.0;
this.framesPerSecond = 0.0;
this.container = document.createElement('div');
this.container.style.position = 'fixed';
@bitnenfer
bitnenfer / linkedlist_reverse.cpp
Created January 30, 2024 01:30
Reverse linked list
struct LinkedList
{
struct Node
{
Node* next;
int value;
};
LinkedList(std::initializer_list<int> list)
{
@bitnenfer
bitnenfer / quicksort.cpp
Created January 29, 2024 23:34
Quicksort in C++
#include <vector>
#include <stack>
int partition(std::vector<int>& input, int left, int right)
{
if (left < right)
{
int pivotValue = input[right];
// This represent the current position of the pivot
int pivotIndex = left;
/*.sln
*.suo
*.opensdf
*.sdf
/Engine/DerivedDataCache/*
**/DerivedDataCache/Boot.ddc
**/DerivedDataCache/**/*.udd
*/Intermediate/*
*/Saved/*
/Engine/Programs/UnrealBuildTool/*
@bitnenfer
bitnenfer / RenameZip.bat
Created March 31, 2023 00:50
Renami zip batch file
@echo off
setlocal enabledelayedexpansion
for %%f in (*.zip.*) do (
set "filename=%%f"
if /i not "!filename:~-4!"==".zip" (
echo Renaming !filename! to !filename!.zip
ren "!filename!" "!filename!.zip"
) else (
set "restoredFilename=!filename:~0,-4!"
@bitnenfer
bitnenfer / rename_zip_volumes.py
Created March 29, 2023 15:57
Simple script to rename zip volumes to end with .zip and also to revert the change.
import os
import re
exp = re.compile("\.zip\.\d+")
for file_name in os.listdir("./"):
if exp.search(file_name):
if not file_name.endswith(".zip"):
print("Renaming " + file_name + " to " + file_name + ".zip")
os.rename(file_name, file_name + ".zip")
else:
@bitnenfer
bitnenfer / TinyPool.h
Last active January 8, 2022 16:53
Fast tiny pool of 64 elements that allows random allocation and freeing
/* x64 Fast tiny pool of 64 elements that allows random allocation and freeing */
/* by Felipe Alfonso - http://voitptr.io */
#include <stdint.h>
#if _WIN32
#include <intrin.h>
#endif
template<typename T>
struct TinyPool
{
#if _WIN32
@bitnenfer
bitnenfer / X.js
Last active February 10, 2019 23:08
Commented code for the 2019 JS1K demo "X" (https://js1k.com/2019-x/demo/4039)
// This is the WebGL code:
// ======================
// GL function shortcuts taken from: http://xem.github.io/articles/archive.html#webgl_quest
for(i in g)g[i[0]+i[6]]=g[i];
// `with` helps us avoid doing g.xxx() and just do xxx()
with(g)
// Time variable.
@bitnenfer
bitnenfer / img2dmg.c
Created January 30, 2019 03:26
Small program for transforming images to DMG (Game Boy) tile format.
// Everything except stb_image was made by Felipe Alfonso (@bitnenfer)
//
// This is a crappy software but it does what it needed from it. It just
// transform images (PNG, JPG, TGA, etc.) to DMG encoded tiles. It wont check
// for repeating tiles. Maybe in the future I can add that.
//
// Compile with GCC. gcc img2dmg.c -o img2dmg
// and it's done.
//
// Usage:
@bitnenfer
bitnenfer / build_game.bat
Created January 30, 2019 03:25
A simple batch file that assembles, links and does a checksum fix using the RGBDS toolchain.
@echo off
cls
rem ================================================
rem ================================================
rem The project structure looks like this:
rem ROOT_PATH/
rem PROJECT_NAME/
rem code/