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
(function() { | |
var nsify = function(ns, selChunk) { | |
sels = selChunk.replace(/ /g, '').split(','); | |
for(var i = 0; i < sels.length; ++i) | |
if(sels[i][0].match(/[.#]/)) | |
sels[i] = sels[i][0] + ns + '-' + sels[i].substring(1); | |
return sels.join(','); |
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 qualified Data.Set as Set | |
data Clause = Value Bool | Not Int | Literal Int | Or Clause Clause deriving (Eq,Ord) | |
type CNF = Set.Set Clause | |
instance Show Clause where | |
show (Value True) = "T" | |
show (Value False) = "F" | |
show (Not x) = "~" ++ show x | |
show (Literal x) = show x |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
package Env; | |
sub new { | |
my $class = shift; | |
my $names = shift; |
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; | |
} |
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
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
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
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 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
# 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 |
OlderNewer