Skip to content

Instantly share code, notes, and snippets.

View tiffany352's full-sized avatar

Tiffany Bennett tiffany352

View GitHub Profile
@tiffany352
tiffany352 / option.c
Last active August 29, 2015 13:56
Implementation of option types and option destructuring in C using horrifying hacks. `some`'s comma could probably be cleaned up with a decltype extension.
#include <assert.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#define option(T, name) \
typedef struct option_##name { \
optionhdr hdr; \
T val; \
} option_##name; \
/*
* robotMaze.js
*
* The blue key is inside a labyrinth, and extracting
* it will not be easy.
*
* It's a good thing that you're a AI expert, or
* we would have to leave empty-handed.
*/
// clang -g -I ../IntenseLogic/src raytrace.c -o raytrace -lGL -lGLEW -lSDL2 -L ../IntenseLogic/build -lilcommon -lilmath -lilutil -lilgraphics -ldl -lm -pthread
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/time.h>
#include <math.h>
#include <assert.h>
#include <pthread.h>
trait CloneParser<T> {}
impl<T, U: Parser<T>> CloneParser<T> for U {} // I think it's the `U: Parser<T>` here.
pub trait Parser<T>: CloneParser<T> {}
impl<'l, T> Parser<T> for uint {} // ok without this line.
fn main() {
}
struct thingvec {
thing *data;
size_t capacity, size;
};
void append(struct thingvec *self, thing t)
{
if (self->size >= self->capacity) { // there's no free slots left
size_t newcap = self->capacity * 2; // double in capacity, hits O(N) case every log(N) appends
size_t ts = sizeof(thing);
// Implementation of the QuickHeap priority queue
// From http://swp.dcc.uchile.cl/TR/2008/TR_DCC-2008-006.pdf
// tiffany <tiffany@stormbit.net>
// zlib/libpng, I guess
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <assert.h>
/* Copyright 2014 tiffany <tiffany@stormbit.net>
* Licensed under zlib/libpng
*/
#ifndef FRP_HPP
#define FRP_HPP
#include <vector>
#include <functional>
if (false)
foo;
bar; // oops
if (false) {
foo;
bar;
}
if (false) foo;

Keybase proof

I hereby claim:

  • I am tiffany352 on github.
  • I am tiffany (https://keybase.io/tiffany) on keybase.
  • I have a public key whose fingerprint is BC69 595D A4AC 1B32 1854 9398 33F5 3ED0 A9B5 62C1

To claim this, I am signing this object:

@tiffany352
tiffany352 / template_printer.lua
Last active August 29, 2015 14:25
Template Pretty-Printer
#!/usr/bin/env lua
local args = {...}
local indent = 0
local skip = 0
local ignore = false
function print_nl()
io.stdout:write('\n'..(' '):rep(indent))
end