Skip to content

Instantly share code, notes, and snippets.

void DrawMesh(Gob_Mesh *mesh) {
glVertexPointer(3, GL_FLOAT, mesh->positions.stride, GOB_BUFFER(mesh->positions.buffer)->data + mesh->positions.start);
char *index_buffer = GOB_BUFFER(mesh->indices.buffer)->data;
uint8_t index_size = mesh->indices.index_size;
GLenum index_type = (index_size == 2) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
for (size_t i = 0; i < mesh->sections_count; i++) {
glDrawElements(GL_TRIANGLES, mesh->sections[i].index_count, index_type, index_buffer + index_size * mesh->sections[i].index_start);
}
}
enum { BMAX = 32, BCUT = BMAX / 2, BHEIGHT = 6 };
typedef uint8_t BIndex;
struct BNode {
BIndex length;
Key keys[BMAX];
union {
BNode *children[BMAX];
Value values[BMAX];
@pervognsen
pervognsen / array.inl.h
Last active March 24, 2024 06:15
somewhat palatable templates in c
struct A {
int size;
int capacity;
T *data;
};
typedef struct A A;
void A_(Create)(A *array, int capacity);
void A_(Destroy)(A *array);
@dfletcher
dfletcher / tsws
Last active July 21, 2018 12:47
Totally simple web server using Bash and netcat (nc)
Moved to a proprer repositoy, TSWS is a real boy now!
https://github.com/dfletcher/tsws
PRs welcomed.
@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@aphyr
aphyr / zfs-sync
Created February 7, 2015 05:42
Sync ZFS filesystems, incrementally if possible.
#!/usr/bin/env ruby
# Synchronizes ZFS filesystems.
#
# Takes three args: source pool, destination pool, and filesystem name.
#
# Syncs most recent snapshot of filesystem from source to destination pool,
# using incremental transfer if possible.
# Take a snapshot line from zfs list -t snapshot and emit a struct
@wrouesnel
wrouesnel / .remote-backup-excludes.txt
Last active September 5, 2021 23:32
A script for performing a remote backup to another server using rsync and bup for versioning.
# this is an rsync-excludes format list of files to exclude.
@wrouesnel
wrouesnel / remote-backup.cmd
Created June 21, 2014 20:32
A batch file suitable for invoking a cygwin shell script which carries out a backup on Windows using unix-tooling.
rem This batch file is executed by vscsc.exe after the shadow copy has been
rem created. It is used to initate the backup.
rem
rem %1 is the volume ID of the backup, we pass it to the bash script which
rem runs rsync for us.
c:\cygwin64\bin\bash.exe --login -i ./do-remote-backup.bsh "%1"
@codingoutloud
codingoutloud / make-keys.bat
Last active August 3, 2023 19:05
Handy OpenSSL command-line combinations I've used - they might've been hard to find or come up with, so capturing them here.
@echo off
if _%1_==__ goto USAGE
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/CN=My Cert Name"
openssl pkcs12 -export -out mycert.pfx -inkey mycert.pem -in mycert.pem -passout pass:%1
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer
openssl pkcs12 -in mycert.pfx -nodes -passin pass:%1 | openssl x509 -noout -fingerprint
openssl x509 -in mycert.pem -noout -fingerprint
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 26, 2024 23:26 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.