Skip to content

Instantly share code, notes, and snippets.

Avatar

Roland Yeghiazaryan androideveloper

View GitHub Profile
@androideveloper
androideveloper / okhttp-silent-retry.kt
Last active Apr 19, 2019
Okhttp silent retry when idempotent request fails on reused connection
View okhttp-silent-retry.kt
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 Apr 14, 2019
Git hook to enforce branch naming policy
View pre-commit
#!/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 ]]