Skip to content

Instantly share code, notes, and snippets.

@thelinked
thelinked / StreamingBufferObject.hpp
Last active December 31, 2015 08:39
One of the best ways I've found to stream instance data into vbos in OpenGL. Write data into a vbo and then orphan and remap it when it fills up. Is a bit like double buffering vbos except the details are handled at the driver level.
class StreamingBufferObject
{
public:
StreamingBufferObject() : vbohandle(0), cursor(0) {}
~StreamingBufferObject()
{
if (vbohandle != 0) glDeleteBuffers(1, &vbohandle);
}
template<typename T>
@thelinked
thelinked / LockingQueue.hpp
Last active May 28, 2025 11:22
C++11 blocking queue using the standard library.
#pragma once
#include <queue>
#include <mutex>
#include <condition_variable>
template<typename T>
class LockingQueue
{
public:
void push(T const& _data)
@thelinked
thelinked / gist:5439649
Created April 22, 2013 23:57
BF interpreter
open System
open System.Collections.Generic
let brainfuck raw =
let code = [for c in raw -> c] |> Array.ofList
let memory = Array.create 1024 0
let createJumpTable =
let mutable stack = new Stack<char*int>()
let mutable jumpTable = new Map<int,int>([])
for i = 0 to (code.Length-1) do
@thelinked
thelinked / morse.fs
Last active December 16, 2015 10:49
Morse Code in the most wasteful way possible.
let START = []
let STOP = []
let _ = []
let inline morse c left right = left @ c::[] @ right
let inline SPACE left right = morse ' ' left right
let inline (.-) left right = morse 'A' left right
let inline (-...) left right = morse 'B' left right
let inline (-.-.) left right = morse 'C' left right
let inline (-..) left right = morse 'D' left right
@thelinked
thelinked / gist:4718921
Created February 5, 2013 23:59
F# merge sort using continuation passing style
let split input =
let n = ((List.length input)/2)
let rec splitHelper cur cont = function
| head::tail when cur < n ->
splitHelper (cur+1) (fun acc ->
cont (head::acc)) tail
| rest -> cont [], rest
splitHelper 0 id input
let merge xs ys =