Skip to content

Instantly share code, notes, and snippets.

@henkboom
henkboom / heap.c
Last active August 29, 2015 14:03
heap
// just wanted to put this somewhere
// it's not tested or debugged! probably don't use it.
enum { heap_buffer_size = 1024 };
static int heap_size;
// element 0 unused for simpler math
static message_s heap[heap_buffer_size];
static bool heap_full(void)
@henkboom
henkboom / gist:7212b480d344f34dd3e6
Last active August 29, 2015 14:02
two squares in a circle
// uses love2d 'effect' entry point
uniform float time = 0.0f;
float pi = 3.14159;
float intersect(float value1, float value2)
{
return value1 * value2;
}
@henkboom
henkboom / android_main.c
Created October 21, 2012 16:36
Bootstrapping LuaJIT on Android
#include <android/log.h>
#include "android_native_app_glue.h"
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "beamer", __VA_ARGS__))
#define LOGF(...) ((void)__android_log_print(ANDROID_LOG_FATAL, "beamer", __VA_ARGS__))
@henkboom
henkboom / SceneData.cs
Created October 16, 2012 15:32
Data that expires on scene close. (Unity)
using UnityEngine;
using System.Collections.Generic;
// Data that expires on scene close.
// Pretty much a hack, there must be a better way!
class SceneData<T> where T : class
{
GameObject go;
T data;
@henkboom
henkboom / portaudio.lua
Created June 5, 2012 00:51
Phase modulation synth in LuaJIT and C
local ffi = require 'ffi'
local pa = ffi.load('portaudio')
ffi.cdef [[
int Pa_GetVersion( void );
const char* Pa_GetVersionText( void );
typedef int PaError;
typedef enum PaErrorCode
{
-- state migration prototype inspired by circa's demo video and circa's
-- notes/stateful_code
---- handles state migration --------------------------------------------------
local saved_states = {}
local index = 1
function prepare_for_reload()
index = 1