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
#define MAX_STEPS 100000 | |
#define MAX_DIST 300.0f | |
#define EPSILON 0.001f | |
#define ID_SPHERE 1 | |
#define ID_BIZZO 2 | |
#define ID_FLOOR 3 | |
#define ID_COLUMN 4 | |
#define BIZZO_ITERATIONS 6 |
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
/** kinds of things that can make up a sentence */ | |
sealed trait Term { | |
def show: String | |
def complexity: Int = 1 | |
def root: Term = this | |
} | |
case class Word(show: String) extends Term | |
trait NounTerm extends Term |
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
# layout - kinda python-like. | |
# indents are multiples of 4 spaces, no tabs allowed, violations won't compile | |
# if something is indented from the line before, it's implied that it is part of | |
# the thing defined on the line before | |
# defining an interface | |
# when things are immutable, a property is no different to a no-arg function | |
Verified | |
verifications: Int |
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
/** | |
* simple demo of using Phasers to sync completion and waiting for things to complete. | |
*/ | |
import java.util.concurrent._ | |
import java.lang.{Thread, Runnable} | |
/** | |
* Run a function in another thread, yeah it's ugly, whatever, this is a demo. | |
* This is not the interesting part. | |
*/ |
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
/** | |
* I know Either is a well known class in Scala, but I'm wondering if I've stumbled onto a well known pattern with this | |
* extract() function? | |
*/ | |
public static final class Either<A,B> { | |
private final A left; | |
private final B right; | |
public boolean ifLeft(@Nonnull Consumer<A> todo){ | |
if (left != null) { |
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
// fully qualified Java clases deliberately, so it screams THIS IS FOR JAVA | |
// please excuse ASCII art for readability of very similar functions | |
implicit def toJavaConsumer[T] (con: T=>Unit) = new java.util.function.Consumer[T] { def accept(t:T) = con(t) } | |
implicit def toJavaBiConsumer[A,B] (con: (A,B)=>_) = new java.util.function.BiConsumer[A,B] { def accept(a:A,b:B) = con(a,b) } | |
implicit def toJavaSupplier[T] (sup: Unit=>T) = new java.util.function.Supplier[T] { def get(): T = sup() } | |
implicit def toJavaFunction[T,R] (fun: T=>R) = new java.util.function.Function[T,R] { def apply(t:T) = fun(t) } | |
implicit def toJavaBiFunction[T,U,R] (fun: (T,U)=>R) = new java.util.function.BiFunction[T,U,R] { def apply(t:T, u:U) = fun(t, u) } |
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 HttpField getField(String name) | |
{ | |
for (int i=0;i<_fields.size();i++) | |
{ | |
HttpField f=_fields.get(i); | |
if (f.getName().equalsIgnoreCase(name)) | |
return f; | |
} | |
return null; | |
} |
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 monty; | |
import static com.google.common.collect.ImmutableSet.of; | |
import static com.google.common.collect.Sets.difference; | |
import static java.util.stream.Collectors.toList; | |
import static org.junit.Assert.assertEquals; | |
import java.util.List; | |
import java.util.Set; |
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
#!/bin/sh | |
# | |
# Show resource usage as reported by Singularity | |
# | |
# author: github.com/benhardy | |
set -o errexit -o nounset | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 singularity-resource-usage.sh SINGULARITY_SERVER" |
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
// I probably should make a Maven plugin that generates this code. | |
public final class AddressBuilder { | |
public interface Street2 { | |
City street2(String street2); | |
} | |
public interface City { | |
State city(String city); | |
} | |
public interface State { |
NewerOlder