Skip to content

Instantly share code, notes, and snippets.

@vwood
vwood / compact-search-engine.py
Created December 9, 2011 05:02
Short Python3 Search Engine
#!/usr/bin/env python
# Short indexer and search engine, 2011 Vaughn Wood
# Written in python 3
# Assumes the collection is a newline separated file called index on the current path
# Only uses TF (so perform queries accordingly)
from functools import *
def dict_join_add_values(d, e):
"""Given two dictionaries, add the items in the second to the first.
@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 / ecldemo.c
Created November 4, 2010 03:49
Example of ECL in a C program.
/*
Example of a C program embedding ECL with callbacks to C functions.
Compiled via: gcc ecldemo.c -lecl
*/
#include <stdio.h>
#include <stdlib.h>
#include "ecl/ecl.h"
#define DEFUN(name,fun,args) \
cl_def_c_function(c_string_to_object(name), \
@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