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 uk.gov.justice.digital.hmpps.createandvaryalicenceapi.service | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
import com.fasterxml.jackson.module.kotlin.readValue | |
import uk.gov.justice.digital.hmpps.createandvaryalicenceapi.model.policy.LicencePolicy | |
import java.io.File | |
import java.nio.charset.StandardCharsets.UTF_8 | |
import kotlin.reflect.full.memberProperties | |
val seenTypes = mutableSetOf<Class<*>>() |
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/bash | |
set -e | |
CLIENT_ID=… | |
CLIENT_SECRET=… | |
# ID for Pixies | |
ARTIST=6zvul52xwTWzilBZl6BUbT | |
DURATION_MS=$((15 * 60 * 1000)) |
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.time.LocalTime | |
fun isAvailable(request: Request) { | |
val timeLine = createTimeLine(LocalTime.of(8, 0), LocalTime.of(18, 0), 5) | |
val bookings = getTodaysBookings() // listOf(RoomBooking(Room.ONE, TimeRange("2007-12-03T10:10:00", "2007-12-03T10:40:00"))) | |
bookings.filter { notPartOf(request.bookingToAmmend) }. forEach { timeLine.add(it) } | |
return timeLine.isAvailable(request) |
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
static class Service { | |
enum GetChildError {NOT_FOUND, OBSCURE_ERROR} | |
public Result<Double, GetChildError> getChild(String id, String childKey) { | |
if (id.equalsIgnoreCase("notfound")) { | |
return Result.failure(GetChildError.NOT_FOUND); | |
} | |
if (id.equalsIgnoreCase("obscure")) { |
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.SortedSet | |
fun main(args: Array<String>) { | |
val input = "A_DEAD_DAD_CEDED_A_BAD_BABE_A_BEADED_ABACA_BED" | |
val huffmanTree = createHuffmanTree(input) | |
val encoder = encoder(huffmanTree) | |
val decoder = decoder(huffmanTree) |
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 aaa | |
import java.util.concurrent.ThreadLocalRandom | |
private fun caesar(key: Int) : (Char) -> Char { | |
val seq = generateSequence('a' + key) { last -> if (last + 1 > 'z') 'a' else last + 1} | |
return { c -> seq.elementAt(c - 'a') } | |
} | |
private fun unCaesar(key: Int) : (Char) -> Char { |
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 uk.co.optimisticpanda.functionutils.pairs; | |
import java.util.Optional; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
import java.util.stream.Stream; | |
import org.apache.commons.lang3.tuple.Pair; | |
import org.apache.commons.lang3.tuple.Triple; |
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 uk.co.optimisticpanda.functionutils.predicates; | |
import java.util.function.Function; | |
import java.util.function.Predicate; | |
public class Predicates { | |
public static <T, U> Predicate<T> has(Function<T, U> f, Predicate<U> p) { | |
return t -> p.test(f.apply(t)); | |
} |
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 uk.co.optimisticpanda.configtaskchain.model; | |
import static java.util.stream.Collectors.toList; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.function.Function; | |
import java.util.function.UnaryOperator; | |
import java.util.function.Supplier; |
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 uk.co.optimisticpanda.test; | |
import java.util.HashMap; | |
import java.util.Map; | |
/** | |
* Supporting subset of map operations based on the key containing type information. | |
*/ | |
public class TypeSafeMapTest { |
NewerOlder