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 / calc6502.asm
Last active April 2, 2023 04:01
Simple calculator implementation in 6502 assembly
; 6502 STACK BASED CALCULATOR.
; THE FIRST ARGUMENT MUST BE
; THE ID FOR THE OPERATION.
; 1 = ADDITION | 2 = SUBTRACTION
; 3 = MULTIPLICATION | 4 = DIVITION
; THE RETURN VALUE OF THE OPERATIONS
; IS STORED IN THE TOP OF THE STACK.
;
; *** NOTE: THIS IS NOT A FAST IMPLEMENTATION ***
JMP MAIN
@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 / websocket-server-winsock.cpp
Created December 29, 2016 05:02
WebSocket Server using WinSock2 and gaius engine.
void socket_run(void*)
{
//addrinfo hints;
//addrinfo* result = NULL;
//addrinfo* pointer = NULL;
uint32 success = 0;
SOCKET listen_socket = INVALID_SOCKET;
SOCKET client_socket = INVALID_SOCKET;
WSADATA wsa_data;
@bitnenfer
bitnenfer / index.html
Last active September 1, 2022 16:18
wasm binary loader with fallback to asm.js
<!DOCTYPE html>
<html>
<head>
<title>LOADING...</title>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
@bitnenfer
bitnenfer / rasterbars.s
Last active January 8, 2022 16:53
game boy effects
isdmg
offbankgroup
puball
title group $00
org $0040
reti
org $0048
reti
org $0050
reti