Skip to content

Instantly share code, notes, and snippets.

@japajoe
japajoe / utf8.cpp
Created October 8, 2025 18:29
Check if string is valid UTF8
bool isValidUTF8(const char *pText, size_t size, size_t &charCount) {
if(size == 0)
size = strlen(pText);
int numBytes = 0; // Number of bytes expected in the current UTF-8 character
unsigned char byte;
const uint8_t *pPayload = reinterpret_cast<const uint8_t*>(pText);
for (size_t i = 0; i < size; ++i) {
byte = pPayload[i];
@japajoe
japajoe / GLSL-Noise.md
Created June 2, 2025 14:28 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@japajoe
japajoe / DLLExportReader.cpp
Created February 11, 2025 04:53
Reads exported symbols from a DLL file
//Generated by DeepSeek R1
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdint>
#include <string>
#include <iomanip>
using namespace std;
@japajoe
japajoe / MemoryViewer.cs
Created January 29, 2025 15:56
ImGui MemoryViewer in C#
using System;
using System.Runtime.InteropServices;
using ImGuiNET;
using System.Numerics;
public sealed unsafe class MemoryViewer
{
public bool Open = true;
public bool ReadOnly = false;
public int Cols = 16;
@japajoe
japajoe / CTokenizer.cs
Last active January 29, 2025 15:54
Simple tokenizer for C
using System.Collections.Generic;
using System.Text;
public class CTokenizer
{
public enum TokenType
{
Number,
Identifier,
Keyword,
@japajoe
japajoe / gist:62670f36b36c68f98eec599586606791
Last active January 24, 2024 11:09
OpenGL context with X11 and Glad
//Compiling:
//g++ main.cpp -o app -lX11 -lGL -ldl
//Don't forget to add glad to your sources
#include <X11/Xlib.h>
#include "glad/glad.h"
#include <GL/glx.h>
#include <iostream>
static int CreateTriangle();
@japajoe
japajoe / main.cpp
Created December 11, 2023 13:18
Audio playback with ALSA
#include <cstdint>
#include <thread>
#include <iostream>
#include <alsa/asoundlib.h>
#include <cmath>
#define ALSA_PCM_NEW_HW_PARAMS_API
#define PI 3.14159265359
class AudioMixer