This file contains 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
// testImplementation "com.squareup.okhttp3:mockwebserver:4.7.2" | |
class RetrofitTest { | |
@get:Rule | |
private val server = MockWebServer().apply { dispatcher = MockDispatcher() } | |
private lateinit var api: Api | |
@Before | |
fun setup() { |
This file contains 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
# Add curl | |
apk add curl | |
# Response time | |
curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://www.google.com |
This file contains 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 android.databinding.DataBindingUtil | |
import android.databinding.ViewDataBinding | |
import android.support.annotation.IdRes | |
import android.support.v7.widget.RecyclerView | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
abstract class BaseBindingListAdapter<T, in DB : ViewDataBinding> : RecyclerView.Adapter<BaseBindingListAdapter<T, DB>.BaseViewHolder>() { |
This file contains 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
object MrzValidator { | |
private val COEFFICIENTS = listOf(7, 3, 1) | |
private const val EMPTY = '<' | |
/** | |
* Samples: | |
* - Document number: isValid("D123456785", 0, 9) actual document number is "D12345678" check character is "5" | |
* - Date: isValid("7903063", 0, 6)) actual date is "790306" check character is "3" | |
*/ |
This file contains 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
fun <T> debounce( | |
waitMs: Long = 300L, | |
scope: CoroutineScope, | |
destinationFunction: (T) -> Unit | |
): (T) -> Unit { | |
var debounceJob: Job? = null | |
return { param: T -> | |
debounceJob?.cancel() | |
debounceJob = scope.launch { | |
delay(waitMs) |
This file contains 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
1.Code formatting | |
On Windows: Shift + Alt + F | |
On Mac: Shift + Option + F | |
On Ubuntu: Ctrl + Shift + I | |
2.Copy line up/down | |
On Windows: Shift + Alt + Up/Down | |
On Mac: Shift + Option + Up/Down | |
On Ubuntu: Ctrl + Shift + Alt + Up/Down |
This file contains 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
#Switch to dev branch, pull it then come back to my current branch | |
current="$(git branch | grep \* | cut -d ' ' -f2)";git checkout dev;git pull origin dev;git checkout $current |
This file contains 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
echo "1/7 Stopping nginx" | |
sudo service nginx stop | |
echo "2/7 Removing mongod.lock" | |
rm /var/lib/mongodb/mongod.lock | |
echo "3/7 Stopping mongod" | |
sudo service mongod stop | |
echo "4/7 Renewing letsencrypt" |
This file contains 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
// Conditional string | |
android:text="@{viewModel.startButtonText ? @string/title_start_travel : @string/title_start}" | |
// Conditional visibility | |
<import type="android.view.View" /> | |
android:visibility="@{viewModel.visibility == 1 ? View.VISIBLE : View.GONE}" | |
// Non-string text | |
android:text="@{String.valueOf(data.minutes)}" |
This file contains 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
// Depenency graph | |
./gradlew -q dependencies app:dependencies |
NewerOlder