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
/* | |
* Returns a list of all the text nodes under the given node. | |
* | |
* The order should be depth-first, first-to-last across siblings. | |
*/ | |
function findTextNodes(node) { | |
var HTML_TEXT_NODE = 3; | |
if (node.nodeType == HTML_TEXT_NODE) { | |
return [node]; | |
} |
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
# This is free and unencumbered software released into the public domain. | |
# | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any | |
# means. | |
# | |
# In jurisdictions that recognize copyright laws, the author or authors | |
# of this software dedicate any and all copyright interest in the | |
# software to the public domain. We make this dedication for the benefit |
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
{ | |
// NOTE: Only expect this to work on FF, Chrome or Edge. | |
// There are several arrow functions sprinkled around, | |
// and caniuse suggests that these are the only browsers | |
// that can handle them natively | |
init: function(elevators, floors) { | |
// The backlog is (an approximation of) the number of people currently waiting at | |
// the given floor. | |
// |
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 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(); |
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 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() || |
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
# 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 |
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 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; |
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
/** | |
* 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. | |
* |
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
// 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 |
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
<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; |