Skip to content

Instantly share code, notes, and snippets.

View pmttavara's full-sized avatar

Phillip Trudeau pmttavara

View GitHub Profile
@albertz
albertz / bin2c.c
Created January 2, 2012 16:29
bin2c
#include <stdio.h>
#include <assert.h>
int main(int argc, char** argv) {
assert(argc == 2);
char* fn = argv[1];
FILE* f = fopen(fn, "r");
printf("char a[] = {\n");
unsigned long n = 0;
while(!feof(f)) {
@jsimmons
jsimmons / jsb_map.h
Last active April 5, 2018 17:22
Quicky hash map in C
// We don't block multiple includes of this file since each inclusion should
// be for a different type. Be careful.
//
// A map using hopscotch hashing[1], an open-addressing scheme for resolving
// hash collisions.
//
// [1] Herlihy, Maurice and Shavit, Nir and Tzafrir, Moran (2008).
// "Hopscotch Hashing".
// DISC '08: Proceedings of the 22nd international symposium on
@ruby0x1
ruby0x1 / hash_fnv1a.h
Last active October 18, 2024 07:56
FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit
#pragma once
#include <stdint.h>
//fnv1a 32 and 64 bit hash functions
// key is the data to hash, len is the size of the data (or how much of it to hash against)
// code license: public domain or equivalent
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) {
@symisc
symisc / bin2c.c
Created August 26, 2017 13:43 — forked from albertz/bin2c.c
bin2c
#include <stdio.h>
#include <assert.h>
int main(int argc, char** argv) {
assert(argc == 2);
char* fn = argv[1];
FILE* f = fopen(fn, "r");
printf("char a[] = {\n");
unsigned long n = 0;
while(!feof(f)) {
int parse_int(const char *str, bool *overflow) {
int pos = 1;
if (*str == '-') {
pos = 0;
str++;
}
int num = 0;
*overflow = false;
while (isdigit(*str)) {
int d = *str - '0';
@talyian
talyian / fragment.glsl
Last active December 24, 2019 18:09
Slowest Font Renderer in the West
uniform int n_lin_segments;
uniform vec2 lin_segments[256];
uniform int n_quad_segments;
uniform vec2 quad_segments[512];
varying vec3 pos;
varying vec2 uv;
void main() {
vec2 point = uv;
// point = (point + vec2(0.3, 0)) * 0.1;