View Dictionary.php
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
<?php | |
class Dictionary { | |
var $file; | |
var $index; | |
var $current; | |
function Dictionary($file) { | |
$this->file = $file; | |
$this->index = array(); |
View tree.go
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
package main | |
import ( | |
"fmt" | |
"strconv" | |
"io" | |
"encoding/binary" | |
) | |
type BinaryTree struct { |
View genius.py
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 fcntl | |
import signal | |
import time | |
import contextlib | |
class Genius(object): | |
''' | |
A genius is basically a roman daemon. It differs from python-daemon | |
in the following ways: |
View palindrome.py
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 random | |
import io | |
import time | |
def profile(func): | |
def wrapper(*args): | |
start = time.clock() | |
rv = func(*args) | |
end = time.clock() |
View life.py
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 | |
import argparse | |
import numpy | |
import pygame | |
pygame.init() | |
from pygame.locals import QUIT # Dat deze uit z'n namespace moet is echt stom | |
# 3 regels: | |
# 1. Levende cellen met minder dan 2 levende buren gaan dood |
View volume.js
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
function calculateVolume(heights) { | |
var left = 0, right = 1, volume = 0; | |
while (right < heights.length) { | |
var level = heights[left]; | |
if (heights[right] <= level) { | |
// tag the 'left cursor' along | |
left = right; | |
right = right + 1; | |
} else { |
View ve.py
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 | |
import argparse | |
import os | |
import os.path | |
import sys | |
import subprocess | |
import shutil | |
try: | |
import virtualenv |
View proposal-gsoc-2014.html
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
<h3>What is your e-mail address and IRC nick?</h3> | |
<p>bartwiegmans@gmail.com, brrt on freenode</p> | |
<h3>What is your web page, blog, or microblog?</h3> | |
<p><a href="https://plus.google.com/u/0/+BartWiegmans/posts">I have a google+ page</a> - although I don't actually post a lot of things there.</p> |
View compact.py
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
def compact(a_list): | |
# strategy - find the first empty and nonempty items | |
empty, nonempty = 0, 0 | |
while empty < len(a_list) and nonempty < len(a_list): | |
# ok, so in principle this works really well... why? | |
# what happens is that nonempty looks for the earliest nonempty | |
# element and empty looks for the earliest empty element | |
if a_list[nonempty] is None: | |
nonempty += 1 |
View broken-re.py
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 | |
import re | |
s = r'"foo \" bar" baz "quix"' | |
# same regex right? | |
p_a = r'"(\\"|[^"])*"' | |
p_b = r'"([^"]|\\")*"' | |
# no | |
print(re.match(p_a, s).group(0)) |
OlderNewer