Skip to content
View TestDiGraph.java
import static org.junit.Assert.*;
import org.junit.Test;
public class TestDiGraph {
/*
* Refactoring the commonalities of comparing toposorts with multiple
* valid results, into its own function.
*/
public void assertCorrectSort(DiGraphInterface graph, String... correct) {
String[] sorted = graph.topoSort();
View BinaryHeapTest.java
import static org.junit.Assert.*;
import org.junit.Test;
public class BinaryHeapTest {
/**
* If you are expecting null, then don't use this function - it is not null
* safe.
*/
private void entryPairAssertEqual(EntryPair expect, EntryPair actual) {
if (expect.getPriority() != actual.getPriority() ||
View compute-offsets.pl
# Computes the offsets of values in a MIPS .data segment
my $in_data = 0;
my $mem_offset;
my $current_label = "";
# Gets rid of C escapes like \n - note that this is only meant to preserve
# the length of the string, so it uses single-character placeholders rather
# than actually interpreting the escapes. For example, it would replace:
#
# Foo\'s bar\n
View ObservableFrame2DTest.java
package a6.test;
import a6.Pixel;
import a6.ColorPixel;
import a6.Coordinate;
import a6.Region;
import a6.Frame2D;
import a6.ObservableFrame2D;
import a6.ObservableFrame2DImpl;
import a6.ROIObserver;
View uKanren.scala
/**
* An implementation of microKanren (and probably most of miniKanren), with
* a few extras. Currently, it supports:
*
* - The essential core of microKanren: Unify, Fresh, Disjunction, Conjunction
* - Standard terms: Variables, Atoms, TermCons, EmptyTerm.
* - An implicit conversion from type T to Atom[T]. This makes writing programs
* much easier.
* - A decent reifier, which converts terms to strings.
*
View fizzbuzz.s
// FizzBuzz in x86 assembly - written on 32-bit Linux using the GNU ASsembler
.data
FIZZSTR:
.asciz "Fizz"
BUZZSTR:
.asciz "Buzz"
NEWLINE:
.asciz "\n"
// strtoa stores its data here. Since FizzBuzz runs 1-100, it won't need more than 3 bytes
View crowd.html
<canvas id="canvas" width="600" height="600">
</canvas> </br>
Method: <input id="algorithm" type="text"> </input> <br/>
Timestep (Hz): <input id="timestep" type="text"> </input> <br/>
<input id="start_stop" type="button" value="Start" onclick="run()"> </input> <br/>
<script>
////////////////////
var PERSON_RADIUS = 1;
var PERSON_SPEED = 5;
View usm
#!/bin/sh
set -u
USAGE='Usage: usm COMMAND ...
usm help
usm init
usm copy-script
usm add SOFTWARE VERSION
usm set-current SOFTWARE VERSION
View arithmetic.py
"""
This implements a fairly simple expression language via a Pratt-style parser.
The language supports fairly standard floating point literals, such as:
5
1.09
.16
12e7
View wikiword.py
"""
Converts a tree of wiki pages into a tree of HTML pages.
"""
from collections import defaultdict
import configparser
import glob
import itertools
import os, os.path
import re
import shutil
Something went wrong with that request. Please try again.