Skip to content

Instantly share code, notes, and snippets.

View daviddenton's full-sized avatar

David Denton daviddenton

View GitHub Profile
@daviddenton
daviddenton / maven
Last active June 12, 2025 16:13
download gradle dependencies
tasks.register<Copy>("downloadDependencies") {
from(configurations.runtimeClasspath)
into("local-repo/jars")
}
tasks.register("downloadDependenciesWithMetadata") {
doLast {
configurations.runtimeClasspath.get().resolvedConfiguration.resolvedArtifacts.forEach { artifact ->
val moduleVersion = artifact.moduleVersion.id
val group = moduleVersion.group.replace(".", "/")
rbenv is a Ruby version manager that allows you to install multiple versions of Ruby and switch between them. Follow the steps below to install Ruby using rbenv.
Install all required dependencies for the ruby-build plugin to download and compile Ruby.
console
Copy
$ sudo apt install autoconf patch build-essential rustc libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev libtool uuid-dev
Install the latest rbenv installation script.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@daviddenton
daviddenton / functionalMap.kt
Created May 17, 2024 08:48
Implement a map using only functions
// This is our map type
typealias FunctionalMap<K, V> = (K) -> V?
// An empty map never has the value
fun <K, V> emptyMap(): FunctionalMap<K, V> = { _ -> null }
// Match the key to the value or fallback
fun <K, V> FunctionalMap<K, V>.put(key: K, value: V): FunctionalMap<K, V> = { k ->
if (k == key) value else this(k)
}
@daviddenton
daviddenton / AdjustableTickingClock.kt
Created June 21, 2023 09:22
AdjustableTickingClock
class AdjustableTickingClock(
private val startTime: Instant = EPOCH,
private val tick: Duration = Duration.ofSeconds(5)
) : Clock() {
private var currentTime = startTime
override fun getZone() = ZoneId.of("UTC")
override fun withZone(zone: ZoneId?) = this
override fun instant() = currentTime.also { currentTime += tick }
@daviddenton
daviddenton / SQSToLambdaBridge.kt
Last active August 30, 2021 15:01
Bridging an SQS queue to an AWS Request SQS Event Lambda
package org.http4k.example
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.events.SQSEvent
import org.http4k.aws.AwsSdkClient
import org.http4k.client.JavaHttpClient
import org.http4k.core.HttpHandler
import org.http4k.core.Uri
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider.create
@daviddenton
daviddenton / AzureSdkHttpClient.kt
Last active May 14, 2021 13:21
http4k AzureSdkHttpClient adapter
import com.azure.core.http.HttpClient
import com.azure.core.http.HttpHeader
import com.azure.core.http.HttpHeaders
import com.azure.core.http.HttpRequest
import com.azure.core.http.HttpResponse
import org.http4k.core.Body
import org.http4k.core.Body.Companion.EMPTY
import org.http4k.core.HttpHandler
import org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.contract.PreFlightExtraction
import org.http4k.contract.contract
import org.http4k.contract.meta
import org.http4k.core.Body
import org.http4k.core.Filter
import org.http4k.core.Method.POST
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status.Companion.BAD_REQUEST
import org.http4k.core.Status.Companion.OK
@daviddenton
daviddenton / main.kt
Created October 16, 2020 17:09
Composing multiple http4k apps
val app1 = routes(
"/bob" bind GET to { Response(OK).body("you GET bob") },
"/rita" bind POST to { Response(CREATED).body("you POST rita") }
)
val app2 = routes(
"/sue" bind DELETE to { Response(ACCEPTED).body("you DELETE sue") }
)
// we can compose the apps together into one large app here at the root,
### Keybase proof
I hereby claim:
* I am daviddenton on github.
* I am daviddenton (https://keybase.io/daviddenton) on keybase.
* I have a public key ASBCXxFMUhDpkU0nuStiO7UXK879HTLE5CitEDuRXB9oyQo
To claim this, I am signing this object: