Skip to content

Instantly share code, notes, and snippets.

@profan
profan / findFunction
Last active August 29, 2015 13:57
Search for a function through table, print names of matching functions.
function findFunction(search_table, funcname)
for k, v in pairs(search_table) do
if type(v) == "table" then
for i, l in pairs(v) do
if type(l) == "function" then
if string.match(i, funcname) then
io.write(k .. ".".. i .. "\n");
end
end
end
@profan
profan / keyeventmanager
Created May 22, 2014 21:40
Key Event Manager
#ifndef VOX_KEYEVENTMANAGER_HPP
#define VOX_KEYEVENTMANAGER_HPP
#include "easylogging++.h"
#include "Keyboard.hpp"
#include "KeyNew.hpp"
#include <SDL2/SDL.h>
#include <vector>
#include "Profiler.h"
@profan
profan / keybase.md
Last active August 29, 2015 14:02
keybase things

Keybase proof

I hereby claim:

  • I am profan on github.
  • I am profan (https://keybase.io/profan) on keybase.
  • I have a public key whose fingerprint is 1798 B62C B04E F796 5A68 BED3 A350 4CCE 50E5 110D

To claim this, I am signing this object:

@profan
profan / allocs.c
Last active December 5, 2020 21:52
awful allocation tracking macro
#include <stdlib.h>
#include <stdio.h>
struct Node {
size_t attempted_allocations;
size_t successful_allocations;
size_t size;
struct Node* next;
@profan
profan / scopedbuf.d
Created October 29, 2015 01:32
scoped buffer?
struct ScopedBuffer(T) {
private IAllocator allocator_;
private {
T[] buffer_;
}
@profan
profan / ilist.d
Last active February 15, 2016 05:29
Intrusive single linked list, wouldn't recommend anyone actually use it :D
/**
* Intrusive single linked list, uses next pointer already present in the type
* to avoid extra dynamic memory allocation.
*/
struct ILinkedList(T) {
T* head_;
void add(T* item) {
@profan
profan / thing.d
Last active July 17, 2016 15:18
more declarative opengl
import std.typecons : tuple;
import std.stdio;
import std.meta;
import derelict.sdl2.sdl;
import gland.win;
import gland.gl;
import util;
@profan
profan / flicker_and_glow.gd
Last active September 7, 2018 15:37
flickering rectangle thing
extends Node2D
export(float) var width
export(float) var height
var glow_speed = 0.00125 # per second
export(float) var glow_min_target = 0.425
export(float) var glow_max_target = 0.515
export(float) var glow_mul = 0.05
@profan
profan / new_flicker_and_glow.gd
Last active September 7, 2018 15:48
newer thing
extends Node2D
const Util = preload("res://util.gd")
const Flickering = Util.Flickering
export(float) var width
export(float) var height
var glow_speed = 0.00125 # per second
export(float) var glow_min_target = 0.425
@profan
profan / app.d
Created October 28, 2018 14:56
terrible message handling loop
import vibe.d;
import vibe.data.json;
import vibe.http.router;
import std.concurrency : spawnLinked, Tid, thisTid;
import orb.net : NetworkClient;
import orb.server : Server;
shared static this() {