Skip to content

Instantly share code, notes, and snippets.

@huntj88
huntj88 / ProjectAuthorizationFeature.kt
Last active January 10, 2024 14:06
Ktor Custom Authorization Feature
package me.jameshunt.app.authorization
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.request.*
import io.ktor.routing.*
import io.ktor.util.*
import io.ktor.util.pipeline.*
import me.jameshunt.app.ApiException
import me.jameshunt.app.ApiKey
@huntj88
huntj88 / generateVersion.sh
Last active June 22, 2021 01:24
Generate sortable version string containing information to understand where a version came from
#!/bin/bash
# You can see how far along the master branch you are, how many
# commits you diverged from the master branch, and the commit hash
# the version is generated from
NEAREST_COMMON_ANCESTOR=$(git merge-base origin/master HEAD)
MASTER_COUNT=$(git rev-list --first-parent --count "$NEAREST_COMMON_ANCESTOR")
HEAD_COUNT=$(git rev-list --first-parent --count HEAD)
COUNT_DIFF=$((HEAD_COUNT-MASTER_COUNT))
SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)