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
# 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
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
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
/** | |
* 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
// 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
val matrix = Matrix() | |
val srcIndex = 0 | |
val dstIndex = 0 | |
val pointCount = 4 // or any other number of points you wanna transform | |
/** | |
* Set the matrix such that the specified src points would map to the specified dst points. The | |
* "points" are represented as an array of floats, order [x0, y0, x1, y1, ...], where each | |
* "point" is 2 float values. | |
*/ |
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
apply plugin: 'com.android.application' | |
apply plugin: 'android-apt' | |
android { | |
compileSdkVersion versions.compileSdk | |
buildToolsVersion versions.buildTools | |
defaultConfig { | |
applicationId "samples.linhtruong.com.ui_reactive_rxjava_realm" | |
minSdkVersion versions.minSdk |
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
// Understanding Handler and Looper in Android | |
// by Rahul Rastogi | |
// https://medium.com/@rastogi.tech/understanding-handler-and-looper-in-android-c6fa673c6822 | |
var handler: Handler? = null | |
Thread { | |
Looper.prepare() // Creating a Looper for this thread. | |
// Creating a Handler for given Looper object. |