Skip to content

Instantly share code, notes, and snippets.

@androideveloper
androideveloper / okhttp-silent-retry.kt
Last active April 19, 2019 17:19
Okhttp silent retry when idempotent request fails on reused connection
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.logging.HttpLoggingInterceptor
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.SocketPolicy
import org.junit.Assert.assertThat
import kotlin.test.assertEquals
fun main() {
@androideveloper
androideveloper / pre-commit
Last active October 2, 2023 21:10
Git hook to enforce branch naming policy
#!/usr/bin/env bash
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(feature|bugfix|improvement|library|prerelease|release|hotfix)\/[a-z0-9._-]+$"
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again."
if [[ ! $local_branch =~ $valid_branch_regex ]]