Skip to content

Instantly share code, notes, and snippets.

antonijn, 2017
___ _ _ _ _
|_ _|_ _| |_ _ _ ___ __| |_ _ __| |_(_)___ _ _
| || ' \ _| '_/ _ \/ _` | || / _| _| / _ \ ' \
|___|_||_\__|_| \___/\__,_|\_,_\__|\__|_\___/_||_|
Because all other text editors suck (although
$ ./cheaky
> (let i 0)
> i
0
> (let j 10)
> j
10
> (let k j)
> k
10
@antonijn
antonijn / list.h
Last active April 18, 2016 17:32
Linux kernel linked list, modified for userspace
#ifndef LINUX_LIST_H
#define LINUX_LIST_H
#include <stddef.h>
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
vec4 mat4_col(const mat4 *m, int c)
{
vec4 res;
res.x = m->frows[0][c];
res.y = m->frows[1][c];
res.z = m->frows[2][c];
res.w = m->frows[3][c];
return res;
}
#include <stdio.h>
#include <item/ast.h>
#include <item/io.h>
int main(int argc, char **argv)
{
item_mod *mod = item_create_mod();
item_type *i32 = item_e2b(item_get_int(mod, 32));
item_fun *fun = item_create_fun(mod, i32, "main", L_GLOBAL);
@antonijn
antonijn / infix.c
Last active January 7, 2016 20:05
Infix evaluator
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
typedef int bool;
#define TRUE 1
#define FALSE 0
/* Returns the operator precedence for an operator */
@antonijn
antonijn / complex.cs
Last active January 1, 2016 23:59
How exception handling works.
private static void f()
{
ThreadExEnv env = Thread.current().getExEnv();
void() fin = void () ->
{
// finally block
// ...
};
if (!env.registerHandler(fin))
{
Base:
class boh.std.Object
this();
virtual boh.std.Type getType();
virtual long hash();
virtual boolean equals(Object other);
virtual boh.std.String toString();
static boolean valEquals(boh.std.Object l, boh.std.Object r);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace linecounter
{
class Program
{
@antonijn
antonijn / dragon.cs
Created November 28, 2013 18:17
Dragon curve (memory inefficient)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace dragon
{
internal struct Vector2
{