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 sys, re | |
from subprocess import check_output | |
commit_msg_filepath = sys.argv[1] | |
issue_key_regex = "([A-Z][A-Z]+-\d+)" | |
branch = check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip() |
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
trait List[+A] { | |
def foldRight[B](z: B)(f: (A, B) => B): B = { ... | |
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
//wont compile | |
def append(ls: List[A]): List[A] = { | |
foldRight(ls)((a,b) => Cons(a, b)) | |
} | |
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 collector that will collect the stream into an immutable map. | |
* | |
* @param keyMapper A function that given a stream element returns a key | |
* @param valueMapper A function that given a stream element returns a value | |
* @param <T> The type of element in the stream | |
* @param <K> The type of keys used in the map | |
* @param <V> the type of values contained in the map | |
* @return a collector that will collect the a stream into an immutable map | |
*/ |
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 abstract class Json { | |
private Json() { | |
} | |
public abstract <T> T match(Function<Jseq, T> a, | |
Function<Jobj, T> b, | |
Function<Jnumber, T> c, | |
Function<Jstring, T> d, | |
Function<Jboolean, T> e, |
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 String show(final Json json) { | |
return json.match( | |
seq -> seq.getElems().stream() | |
.map(j -> show(j)) | |
.collect(Collectors.joining(",", "[", "]")), | |
jobject -> jobject.getMembers().entrySet().stream() | |
.map(kv -> "\"" + kv.getKey() + "\":" + show(kv.getValue())) | |
.collect(Collectors.joining(",", "{", "}")), | |
jnumber -> jnumber.getNum().toString(), | |
jstring -> "\"" + jstring.getStr() + "\"", |
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 abstract class Json { | |
private Json() { | |
} | |
public abstract <T> T match(Function<Jseq, T> a, | |
Function<Jobj, T> b, | |
Function<Jnumber, T> c, | |
Function<Jstring, T> d, | |
Function<Jboolean, T> e, |
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 final class Jobj extends Json { | |
private final Map<String, Json> members; | |
public Jobj(final Map<String, Json> members) { | |
this.members = members; | |
} | |
public Map<String, Json> getMembers() { |
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 <T> CompletableFuture<List<T>> sequence(final List<CompletableFuture<T>> futures) { | |
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])) | |
.thenApply(unit -> futures | |
.stream() | |
.map(CompletableFuture::join) | |
.collect(toList())); | |
} |
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 io.atlassian.fugue; | |
import java.util.function.Function; | |
public abstract class Try<T> { | |
public interface CheckedFunction<T, R> { | |
R apply(T t) throws Throwable; | |
} |
OlderNewer