Skip to content

Instantly share code, notes, and snippets.

View jweinst1's full-sized avatar
🎯
Focusing

Josh Weinstein jweinst1

🎯
Focusing
View GitHub Profile
@jweinst1
jweinst1 / inttoarrayfast.cpp
Last active July 29, 2026 06:29
murmur3 hash to larger array map
#include <iostream>
#include <vector>
#include <unordered_map>
#include <random>
#include <chrono>
#include <cstdint>
#include <limits>
#include <cstring>
#include <cstdlib>
#include <cstdio>
@jweinst1
jweinst1 / chunk_analyzer.py
Created July 26, 2026 07:42
analyzes log files in unique chunks for indexing
import sys
from collections import Counter
from pathlib import Path
def analyze_chunk_distribution(
file_path: str, top_n: int = 15, sample_bytes: int = 50 * 1024 * 1024
):
path = Path(file_path)
if not path.is_file():
@jweinst1
jweinst1 / glass_shatter.cpp
Created July 25, 2026 00:30
glass shattering game in C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <random>
// Linearly interpolate between two points
inline SDL_FPoint lerp(const SDL_FPoint& a, const SDL_FPoint& b, float t) {
return SDL_FPoint{
@jweinst1
jweinst1 / tilt_sphere.cpp
Created July 21, 2026 08:42
3d sphere with Z coordinate transorms in sdl3
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
// Calculates the X and Y screen coordinates for a circle centered anywhere
void get_arbitrary_circle_point_trig(
float centerX, float centerY,
float radius, float angle_radians,
float* out_x, float* out_y
) {
@jweinst1
jweinst1 / sphere_vertex.cpp
Last active July 21, 2026 08:06
sphere made via vertex in C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
#include <vector>
// Calculates the X and Y screen coordinates for a circle centered anywhere
void get_arbitrary_circle_point_trig(
float centerX, float centerY,
@jweinst1
jweinst1 / rotate_with_indices.cpp
Created July 19, 2026 08:59
rotate 3 way pyramid with indices in C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
struct Vec3 {
float x, y, z;
};
typedef struct {
Vec3 position;
@jweinst1
jweinst1 / rotating_cube.cpp
Created July 18, 2026 08:33
rotating Cube in SDL3 with trig and C++
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
struct Vec3 {
float x, y, z;
};
typedef struct {
Vec3 position;
@jweinst1
jweinst1 / circle_with_trig.cpp
Created July 18, 2026 07:41
draw a circle with sin and cos in C++ SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
// Calculates the X and Y screen coordinates for a circle centered anywhere
void get_arbitrary_circle_point_trig(
float centerX, float centerY,
float radius, float angle_radians,
float* out_x, float* out_y
) {
@jweinst1
jweinst1 / 3dcube.cpp
Last active July 16, 2026 08:33
triangle and geometry drawing in C++ with SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
typedef struct {
SDL_FPoint position;
SDL_FColor color;
} LocalVertex;
// 3d cube shape
static constexpr LocalVertex BLUEPRINT[] = {
@jweinst1
jweinst1 / chess.cpp
Last active July 14, 2026 23:46
Chess in SDL3 with C++
#include <SDL3/SDL.h>
#include <iostream>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>