This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Willpower trainer | |
# | |
# It's a really bad, ad hoc state machine | |
# | |
import random | |
import pygame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import random | |
import time | |
import string | |
import Queue | |
import threading | |
from urllib2 import Request, urlopen, URLError, HTTPError | |
import hashlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
from math import log | |
from random import randint | |
def log2(n): | |
return log(n) / log(2) | |
# | |
# Simple count min |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; Censor text temporarily in emacs | |
;; | |
;; (Using this for screen shots mostly) | |
(defvar censor-face | |
'(:foreground "black" :background "black") | |
"Face to use for censoring") | |
(defun censor () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Entity Attribute Value Model in Postgres | |
CREATE TABLE public.entity ( | |
id serial NOT NULL, | |
type varchar(25) NOT NULL, | |
PRIMARY KEY (id) | |
); | |
CREATE TABLE public.defined_attributes ( | |
key varchar(25) NOT NULL, |
OlderNewer