Skip to content

Instantly share code, notes, and snippets.

@vwood
vwood / willpower.py
Created February 29, 2012 10:03
Willpower Game
#!/usr/bin/env python
#
# Willpower trainer
#
# It's a really bad, ad hoc state machine
#
import random
import pygame
@vwood
vwood / disjoint_set.c
Created February 8, 2012 09:32
Disjoint Sets
#include "disjoint_set.h"
void disjoint_set_new(disjoint_set_t *set) {
set->parent = set;
set->rank = 0;
}
disjoint_set_t *disjoint_set_find(disjoint_set_t *set) {
disjoint_set_t *root = set->parent;
@vwood
vwood / channel.c
Created November 17, 2010 03:33 — forked from vwood/channel.c
Channels with asynchronous support.
#include <semaphore.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "channel.h"
struct channel_s {
sem_t empty_semaphore;
sem_t fill_semaphore;
@vwood
vwood / channel.c
Created November 2, 2010 15:00
Channel library.
#include <semaphore.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "channel.h"
struct channel_s {
sem_t empty_semaphore;
sem_t fill_semaphore;
@vwood
vwood / cell.py
Created October 27, 2010 11:30
Simple Reactive programming.
from types import FunctionType
class cell:
def __init__(self, *args):
self.i_depend_on = []
self.depends_on_me = []
self.set(*args)
def get(self):
return self.value