ssh-keygen -t rsa -b 4096 -C "mjrulesamrat@gmail.com"
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
fun Exception.findDomainError(): JsonObject? { | |
val stack = generateSequence(this as Throwable) { throwable -> throwable.cause } | |
val statusRuntimeException = stack.firstOrNull { it is StatusRuntimeException } | |
?.let { it as StatusRuntimeException } | |
?: return null | |
val jsonString = statusRuntimeException.trailers[domainErrorKey] ?: return null | |
val jsonParser = JsonParser() | |
return jsonParser.parse(jsonString).asJsonObject | |
} |
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
var _ = Describe("When reading a book", func() { | |
var book *books.Book // Given | |
// Setup | |
BeforeEach(func() { | |
book = books.New("The Chronicles of Narnia", 300) | |
Expect(book.CurrentPage()).To(Equal(1)) | |
Expect(book.NumPages()).To(Equal(300)) | |
}) |
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
fun <T> MutableList<T>.processWindowWith( | |
withinWindow: (List<T>, T) -> Boolean, | |
process: (MutableList<T>) -> Unit, | |
): MutableList<T> { | |
if (isEmpty()) { | |
return this | |
} |
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.LocalDate | |
data class Event(val id: Int, val startDate: LocalDate, val endDate: LocalDate, val name: String) | |
fun LocalDate(string: String): LocalDate = LocalDate.parse(string) | |
fun Event.overlap(another: Event): Boolean { | |
// this:------(start)----------------(end)----------------------> |