Skip to content

Instantly share code, notes, and snippets.

View wrl's full-sized avatar

william light wrl

View GitHub Profile
/**
* rutabaga: an OpenGL widget toolkit
* Copyright (c) 2013 William Light.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@wrl
wrl / jprng.h
Created March 2, 2014 21:40
approximating gaussian white noise with equal-distribution random numbers
/**
* code from http://burtleburtle.net/bob/rand/smallprng.html
* "I wrote this PRNG. I place it in the public domain."
*/
#pragma once
#include <stdint.h>
#define JPRNG_RAND_MAX UINT32_MAX
@wrl
wrl / iso8601.c
Created February 10, 2014 21:34
generating ISO 8601 dates on win32 vs on anything else
/**
* released under http://unlicense.org/
*/
#include <time.h>
#ifdef _WIN32
#include <windows.h>
static void
class LameError < RuntimeError
end
ShibeTest::Suite.new('ShibeTest') do
should_pass 'assert true' do |assert|
assert.true { true }
end
should_fail 'fail assert true' do |assert|
assert.true { false }
@wrl
wrl / gc_map.c
Last active December 24, 2015 12:59
/*
** keeping track of objects that exist in both C and mruby is tricky! in
** situations where you're binding to a library which maintains its own
** internal lists of child objects (say, in a UI toolkit, a container
** object with a list of contained widgets), you want to do the least
** amount of bookkeeping possible, lest you do your bookkeeping wrong.
**
** here's a simple solution. it works by mapping a cptr to a ruby object,
** which preferably you'd use to wrap around said cptr with a MRB_TT_DATA
** object. the way you use it is simple: whenever you get a pointer back
@wrl
wrl / style.c
Created September 28, 2013 15:13
a compiled rutabaga stylesheet
/**
* rutabaga: an OpenGL widget toolkit
* Copyright (c) 2013 William Light.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
#!/bin/sh
# ustream
STREAM_KEY=""
STREAM_URL="rtmp://1.12617548.fme.ustream.tv/ustreamVideo/12617548/$STREAM_KEY flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)"
# livestream
#LS_USER=
#LS_PASSWD=
#URL="mogulus/$LS_USER/username=$LS_USER/password=$LS_PASS/isAutoLive=true"
@wrl
wrl / iter.c
Created May 26, 2013 09:54
k/v lists in C
#include <stdlib.h>
#include <stdio.h>
/**
* this code has been placed into the public domain
*/
/**
* ideally you'd have a hashmap (or lately i've been pretty happy with
* binary-trie-backed dicts), but in a pinch this sort of thing can be
@wrl
wrl / midi_mikro.c
Created April 30, 2013 23:14
maschine mikro -> midi translator
/**
* william light <wrl@illest.net> wrote this in 2012
*
* released under creative commons CC0
* http://creativecommons.org/publicdomain/zero/1.0/
*/
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
@wrl
wrl / fb_status.c
Created March 8, 2013 00:29
tiny helper routine for pretty-printing glCheckFramebufferStatus()
static void fb_status(const char *where)
{
switch (glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
case GL_FRAMEBUFFER_COMPLETE:
printf(" :: GL_FRAMEBUFFER_COMPLETE in %s\n", where);
break;
case GL_FRAMEBUFFER_UNDEFINED:
printf(" :: GL_FRAMEBUFFER_UNDEFINED in %s\n", where);
break;