Skip to content

Instantly share code, notes, and snippets.

View R2ZER0's full-sized avatar

Rikki Guy R2ZER0

View GitHub Profile
@R2ZER0
R2ZER0 / memory.txt
Created January 15, 2013 20:44
A fairly simple malloc implementation for the ZCPU
// memory.txt - a HL-ZASM malloc implementation
// by Rikki "R2ZER0" Guy 2012-13
// Released into the public domain.
// Usage:
// first call heap_format(ptr, size);
// where ptr in the pointer to a block of memory to be used as a heap
// and size is the size of the heap (in bytes)
// A simple way is to use __PROGRAMSIZE__ as a heap pointer
//
<?php
function matchAirport($str)
{
$result = array();
if(preg_match('/\(([A-Z]{3})\)\s-\s[A-Z]{2}/', $str, $matches))
{
$result["type"] = "airport";
$result["iata_code"] = $matches[1];
}
@R2ZER0
R2ZER0 / example.c
Created October 24, 2014 21:58
C encapsulation example
/* Example usage */
#include <stdlib.h>
#include <stdio.h>
#include "foo.h"
void main(void)
{
Foo my_foo = new_foo();
@R2ZER0
R2ZER0 / bar.c
Last active August 29, 2015 14:08
#include "bar.h"
#include <stdlib.h>
void bar_init(struct bar* self,
int member1)
{
self->member1 = member1;
self->member2 = "Hello, World!";
self->member3 = NULL;
@R2ZER0
R2ZER0 / crc.c
Created December 2, 2014 22:54
something like a crc calculator?
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
typedef struct {
unsigned long val : 48;
} uint48;
uint48 add48(uint48 a, uint48 b)
{
#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
// See: http://nehe.gamedev.net/tutorial/lessons_01__05/22004/
/* Render a frame */
void DrawGLScene(void)
{
#!/usr/bin/perl
use strict;
use warnings;
(sub { print "arg"; })();