Skip to content

Instantly share code, notes, and snippets.

View leinardi's full-sized avatar

Roberto Leinardi leinardi

  • Munich
View GitHub Profile
import android.annotation.SuppressLint
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
private const val INITIAL_MONTH_ADD_ON = "0"
private const val DEFAULT_MONTH = "01"
private const val SEPARATOR = "/"
class TwoDigitMonthYearInputTextWatcher(val editText: EditText) : TextWatcher {
import android.databinding.BaseObservable
import kotlin.properties.Delegates
fun <T> BaseObservable.dataBind(defaultValue: T, fieldId: Int, vararg fieldIds: Int, callback: ((oldValue: T, newValue: T) -> Unit)? = null) =
Delegates.observable(defaultValue) { _, old, new ->
if (old != new) {
callback?.invoke(old, new)
notifyPropertyChanged(fieldId)
fieldIds.forEach { notifyPropertyChanged(it) }
}
@leinardi
leinardi / pr.md
Created September 4, 2018 08:59 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@leinardi
leinardi / 51-android.rules
Created December 26, 2019 15:51
/lib/udev/rules.d/51-android.rules
/lib/udev/rules.d/51-android.rules # These rules refer: https://developer.android.com/studio/run/device.html
# and include many suggestions from Arch Linux, GitHub and other Communities.
# Latest version can be found at: https://github.com/M0Rf30/android-udev-rules
# check the syntax of this file using:
# grep -v '^#' 51-android.rules \
# | grep -Ev '^$' \
# | grep -Ev '^SUBSYSTEM=="usb", ATTR{idVendor}=="[0-9a-f]{4}", ATTR{idProduct}=="[0-9a-f]{4}", ENV{adb_user}="yes"$' \
# | grep -Ev '^SUBSYSTEM=="usb", ATTR{idVendor}=="[0-9a-f]{4}", ENV{adb_user}="yes"$'