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
class Entity | |
applyEvent: (event, args) -> | |
@[Entity._handler event] args... | |
@_handler: (name) -> "on_#{name}" | |
@event: (name, handler) -> | |
@::[name] = -> | |
@applyEvent name, arguments | |
@::[Entity._handler name] = handler |
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 common; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Global { | |
private static boolean inTests; | |
private static final Map<Class<?>, Object> globals = new HashMap<Class<?>, Object>(); | |
private Global() {} |
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() { | |
var origDefine = define; | |
function redefine(name, definitions) { | |
return function (prereqs, definition) { | |
if (arguments.length > 2) { | |
throw new Error('Cannot have more than two arguments to define in ' + name); | |
} else if (arguments.length === 1) { | |
definition = prereqs; | |
prereqs = []; |
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
public static class PredicatedCursor<T> implements Cursor<T> { | |
public interface Predicate<T> { | |
boolean apply(T element); | |
} | |
private final Predicate<? super T> predicate; | |
private final Cursor<T> delegate; | |
public PredicatedCursor(Cursor<T> delegate, Predicate<? super T> predicate) { | |
Cursor<T> current = delegate; |
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
class Args | |
def self.expect &proc | |
parser = self.new | |
parser.instance_eval &proc | |
return parser | |
end | |
attr_reader :positional | |
def [](name) | |
@args.fetch(name.to_s, NullMarshaler).value |
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 java.lang.reflect.InvocationTargetException; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Exceptions { | |
private static Throwable toThrow; | |
private Exceptions() throws Throwable { | |
throw toThrow; | |
} | |
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 java.util.concurrent.Callable; | |
import java.util.concurrent.atomic.AtomicReference; | |
import javax.swing.SwingUtilities; | |
public class EventQueue { | |
private EventQueue() {} | |
public static void invokeAndWait(Runnable doRun) { |
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 hydra; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.locks.AbstractQueuedSynchronizer; | |
/** | |
* Taken mostly from the documentation of {@link AbstractQueuedSynchronizer} | |
*/ | |
public class BooleanLatch { | |
@SuppressWarnings("serial") |
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
// The wait free algorithm is at the very bottom of the page. | |
package performance; | |
import java.util.ArrayDeque; | |
import java.util.Queue; | |
import java.util.concurrent.ConcurrentLinkedQueue; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.LinkedBlockingQueue; |
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 net.deardeuff.roleobject; | |
import com.google.common.base.Preconditions; | |
/** | |
* A Key based on a Class | |
*/ | |
public final class ClassKey<T> implements View.Key<T> { | |
private final Class<T> delegate; | |
OlderNewer