Skip to content

Instantly share code, notes, and snippets.

View kyhule's full-sized avatar

Kyle Lehman kyhule

  • Comcast
  • VT, USA
  • 13:27 (UTC -04:00)
  • X @kyhule
View GitHub Profile
@okshrey
okshrey / NetworkCallEventListener.kt
Last active July 19, 2022 12:01
NetworkCallEventListener logs network performance event metrics to an AnalyticsConsumer. Read more https://medium.com/@shr8bit/how-okcredit-app-boosted-network-performance-by-30-84109080c065
package tech.okcredit.base.network
import okhttp3.*
import okhttp3.EventListener
import java.io.IOException
import java.net.InetAddress
import java.net.InetSocketAddress
import java.net.Proxy
import java.net.URL
@autonomousapps
autonomousapps / ResolveDependenciesPlugin.kt
Created March 16, 2022 20:13
Plugin for resolving dependencies in a task action, to help with pre-populating a docker image
class ResolveDependenciesPlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run {
pluginManager.withPlugin("java") {
registerTask(theJars = artifactFilesProvider("compileClasspath", "jar"))
}
pluginManager.withPlugin("com.android.base") {
// This lets us call `./gradlew resolveDependencies` and have it Just Work.
val lifecycleTask = tasks.register(RESOLVE_DEPENDENCIES_TASK_NAME)
@alexvanyo
alexvanyo / jacoco.gradle.kts
Last active February 29, 2024 16:31
Kotlin DSL JaCoCo configuration for Android
import com.android.build.gradle.internal.tasks.factory.dependsOn
plugins {
id("com.android.application")
jacoco
}
// Register the main JaCoCo task to later depend on the per-variant tasks
val jacocoTestReport = tasks.register("jacocoTestReport")
@whatupfoo
whatupfoo / 1-orgs-archetype.md
Last active March 12, 2024 06:58
Orgs and Teams Best Practices

Organization archetypes

The intention of this document is to provide some guidance and suggestions to customers who are wondering how they should structure organizations and teams in their GitHub Enterprise environment. The idea isn't to give hard and fast rules on which approach is better than the other, but to give examples of when one approach might be preferable to another depending on the use case.

1. A single organization with direct organization membership for repository access (not teams)

          ________________
          |     Org      |
          |    ______    |
          |   |      |\  |

| | Repo | \ |

@arkivanov
arkivanov / DaggerParentChildExample.kt
Created October 14, 2020 15:50
Dagger parent-child example
// Deps
interface Database
interface Network
// Child
interface ChildRepository
class Child(dependencies: Dependencies) {
package com.example
import kotlin.annotation.AnnotationRetention.RUNTIME
import kotlin.annotation.AnnotationTarget.FUNCTION
/**
* @see TracingRunListener
*/
@Retention(RUNTIME)
@Target(FUNCTION)
@ValCanBuild
ValCanBuild / BottomNavigationBehavior.kt
Last active December 18, 2023 00:04
Full code of a BottomNavigationBehavior which hides itself on scroll and handles Snackbars, FAB and snapping. https://medium.com/@ValCanBuild/scroll-your-bottom-navigation-view-away-with-10-lines-of-code-346f1ed40e9e
/**
MIT License
Copyright (c) 2018 Valentin Hinov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@tonilopezmr
tonilopezmr / pre-commit-ktlint
Last active August 15, 2021 10:05
Pre-commit hook to run ktlint with auto-correct option and it adds the auto-correct changes into the commit.
#!/bin/sh
# https://github.com/shyiko/ktlint pre-commit hook
git diff --name-only --cached --relative | grep '\.kt[s"]\?$' | xargs ktlint -F --relative .
if [ $? -ne 0 ]; then exit 1; else git add .; fi
@squarism
squarism / java_upgrades_homebrew_jenv.md
Last active February 21, 2023 14:53
Automating Java Upgrades with Homebrew and Jenv

Goals:

  • never upgrade Java with the GUI pkg installer again.
  • never try to remember that /Library/Java is where JDKs go.
  • Just keep JDK8 and JDK9 up-to-date. Java is so stable, maybe these two major versions is all we need?

Note the assumptions in these goals. Making this a bit more generic would be nice.

I'm on a mac and I use the fish shell which I know is squarely in the edge case camp but I hope this is inspiring or useful to someone else because there's not much shell specific stuff here. I found jenv which is going to help.

First, upgrading java with homebrew is pretty easy. The assumption is that java8 is stable and java (9) is still emerging. This assumption would likely change so it'd be nice to have this scripted out of this assumption. For now, I'm just trying to avoid graphical Oracle installers.

@bnorm
bnorm / strings.kt
Created December 20, 2017 20:33
Turns a Kotlin Data class toString() into formatted JSON-like output
fun Any?.toIndentString(): String {
val notFancy = toString()
return buildString(notFancy.length) {
var indent = 0
fun StringBuilder.line() {
appendln()
repeat(2 * indent) { append(' ') }
}