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
/* Write a function that takes in an integer n and returns the nth Fibonacci number. | |
* | |
* The Fibonacci sequence is defined as follows: the first number of the sequence is `0`, | |
* the second number is `1`, and the nth number is the sum of (n - 1)th and (n - 2)th numbers. | |
* | |
* Note: For the purpose of this question, n starts at 1, so `getNthFib(1) == 0` and `getNthFib(2) == 1` | |
* | |
* Sequence: 0, 1, 1, 2, 3, 5 , 8, 13, 21, ... | |
* | |
* Sample input: n = 2 |
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
// From https://discuss.kotlinlang.org/t/pipe-forward-operator/2098/22 | |
// Showes how to implement a pipe function in Kotlin | |
infix fun <T, R> T.into(func: (T) -> R) = func(this) | |
// How to use | |
fun add(x: Int): Int = x + 1 | |
fun mul(x: Int): Int = x * 12 |
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.* | |
import kotlinx.coroutines.flow.* | |
import kotlin.random.Random | |
fun main() = runBlocking { | |
val providers: List<Provider> = listOf(Provider("p1"), Provider("p2"), Provider("p3")) | |
println(executeAllProviderAsync(providers)) | |
} | |
suspend fun executeAllProviderAsync(providers: List<Provider>): List<Int> = withContext(Dispatchers.Default){ |
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://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository | |
# Add the remote, call it "upstream": | |
git remote add upstream https://github.com/whoever/whatever.git | |
git fetch upstream | |
git fetch --tags upstream | |
git checkout master |
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
git fetch origin branch_name | |
git reset --hard origin/branch_name |
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
git checkout `git rev-list -n 1 --first-parent --before="2019-04-01 01:00" master` |
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
# number of @Test in all files in this directory | |
grep -o -r "@Test" . | wc -l |
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" |
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
https://support.google.com/googleplay/android-developer/answer/113469#targetsdk | |
https://developer.android.com/distribute/best-practices/develop/target-sdk |
NewerOlder