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
import sys,json,os, collections | |
infile = 'res.json' | |
def __main__(): | |
if (len(sys.argv) < 3): | |
print "Usage: \npython gen.py [android | ios] outfile" | |
sys.exit() | |
type = sys.argv[1] | |
if (type != "android" and type != "ios" ): |
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
public class KeyboardSensitiveRelativeLayout extends RelativeLayout { | |
private OnKeyboardShowHideListener listener; | |
public KeyboardSensitiveRelativeLayout(Context context) { | |
super(context); | |
} | |
public KeyboardSensitiveRelativeLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); |
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
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
# 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
public final class PubKeyManager implements X509TrustManager { | |
private String publicKey; | |
public PubKeyManager(String publicKey) { | |
this.publicKey = publicKey; | |
} | |
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |
if (chain == null) { |
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
android { | |
// .... | |
applicationVariants.all { variant -> | |
renameApk(variant, defaultConfig) | |
} | |
} | |
// --------------------------- | |
def renameApk(variant, defaultConfig) { |
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 |
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>() { |
NewerOlder