This file contains hidden or 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
%option noyywrap | |
%{ | |
/* | |
* Copyright (c) 2010 Forest Belton (apples) | |
* | |
* Permission is hereby granted, free of charge, to any person | |
* obtaining a copy of this software and associated documentation | |
* files (the "Software"), to deal in the Software without |
This file contains hidden or 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
# Computes ab in the symmetric group S_n, where a and b are given in cyclic | |
# notation. | |
def compose(a, b, n): | |
i = 1 | |
out = [] | |
while not i in out: | |
out.append(i) | |
i = apply(a, apply(b, i)) | |
This file contains hidden or 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 <assert.h> | |
#include <stdlib.h> | |
#define LIST(a) struct { \ | |
a v; \ | |
void *n; \ | |
} | |
#define CAR(xs) xs->v | |
#define CDR(xs) xs->n |
This file contains hidden or 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
# Copyright (C) 2011 Forest Belton | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in |
This file contains hidden or 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 pygame, sys | |
from pygame.locals import * | |
from math import floor | |
import math | |
WIDTH, HEIGHT = 320, 200 | |
pygame.init() | |
pygame.display.set_mode((WIDTH, HEIGHT)) | |
pygame.display.set_caption('Function plotter') |
This file contains hidden or 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 ID3 import * | |
import os, re, string, urllib2 | |
embed_data = re.compile(r'var EmbedData = {.*?album_title : "([^"]+?)".*?artist : "([^"]+?)".*?};', re.DOTALL) | |
track_data = re.compile(r'trackinfo : \[([^\]]+?)\]', re.DOTALL) | |
def grab(url): | |
f = urllib2.urlopen(url) | |
data = f.read() | |
This file contains hidden or 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 Control.Monad | |
import Data.Char | |
import Data.List | |
op f (y:x:xs) = (f x y):xs -- Pop two, evaluate, push. | |
parse [value] [] = value -- Done parsing, evaluate. | |
parse _any [] = error "wrong stack size" -- This shouldn't happen! | |
parse stack (' ':xs) = parse stack xs -- Ignore spaces. | |
parse stack ('+':xs) = parse (op (+) stack) xs -- Addition. |
This file contains hidden or 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
char **strsplit(const char *s, int delim) { | |
int state; | |
char *sout; | |
char **out; | |
size_t i, count, word; | |
/* Skip any leading delimiters. */ | |
while(*s == delim) | |
++s; | |
This file contains hidden or 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
#define find_chunk(ptr) (struct mchunk*)((char*)(ptr) - offsetof(struct mchunk, data)) | |
struct mchunk { | |
size_t sz; | |
char data[]; | |
}; | |
void *qmalloc(size_t sz) { | |
struct mchunk *chunk = malloc(sizeof *chunk + sz); | |
This file contains hidden or 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
void gswap(void *v1, void *v2, size_t sz) { | |
char *c1 = v1; | |
char *c2 = v2; | |
char tmp; | |
while(sz--) { | |
tmp = *c1; | |
*c1++ = *c2; | |
*c2++ = tmp; | |
} |