This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Looking at vals, delegated properties are not immutable. Remember, val does not imply anything with regards to mutability | |
// it merely says that the variable/property is read-only | |
private val aBeautifulNumber: Double | |
get() = Math.random() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Finds the generic type T in List. | |
* | |
* @return first item that is instance of T or null. | |
*/ | |
inline fun <reified T> List<Any>.findType(): T? { | |
return find { it is T } as? T | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class foo { | |
fun bar(list: List<Any>) | |
} | |
// verifies the list is empty when passed to bar() | |
verify { foo.bar(match { it.isEmpty() }) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
every { handler.removeCallbacks(any()) } returns Unit | |
every { handler.postDelayed(any(), any()) } answers { | |
// capture runnable | |
(this.args[0] as Runnable).run() | |
true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build with docker compose | |
docker-compose build | |
# run with docker-compose and open bash | |
docker-compose run --rm <image> /bin/bash | |
# Stop all Docker containers | |
docker stop $(docker ps -a -q) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When you can't checkout a remote branch with Git and getting this error: | |
“unable to resolve reference” you should do the following: | |
Try cleaning-up your local repository with: | |
$ git gc --prune=now | |
$ git remote prune origin | |
See: https://stackoverflow.com/questions/2998832/git-pull-fails-unable-to-resolve-reference-unable-to-update-local-ref |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://support.google.com/googleplay/android-developer/answer/113469#targetsdk | |
https://developer.android.com/distribute/best-practices/develop/target-sdk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.CoroutineStart.LAZY | |
import kotlinx.coroutines.Deferred | |
import kotlinx.coroutines.async | |
import kotlinx.coroutines.cancelAndJoin | |
import kotlinx.coroutines.coroutineScope | |
import kotlinx.coroutines.sync.Mutex | |
import kotlinx.coroutines.sync.withLock | |
import kotlinx.coroutines.yield | |
import java.util.concurrent.atomic.AtomicReference | |
import kotlin.DeprecationLevel.ERROR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content"> | |
<ImageView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:layout_constraintWidth_min="10dp" |