Skip to content

Instantly share code, notes, and snippets.

View leinardi's full-sized avatar

Roberto Leinardi leinardi

  • Munich
View GitHub Profile
@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"$'
@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 = git@github.com: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:

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) }
}
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 {
@leinardi
leinardi / analytics.sh
Created March 8, 2018 12:04
Track an Event from command line to Google Analytics
#!/usr/bin/env bash
TID="UA-XXXX-Y" # The tracking ID / web property ID. The format is UA-XXXX-Y. All collected data is associated by this ID.
while getopts ":a:c:l:" opt; do
case $opt in
a)
ACTION="$OPTARG"
;;
c)
#!/usr/bin/env bash
if [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then
echo "`basename $0` - run a command spawning an Android Emulator before. It can be used to run Android Tests."
echo "Usage: `basename $0` COMMAND"
echo "Example: $ `basename $0` ./gradlew connectedPayGermanyCompatDebugAndroidTest --info"
exit 0
fi
# grab some variables
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
CPU Family: 0x6
SteamVR System Report created ven feb 24 22:16:24 2017
<Report>
SteamVR Version: 1487904548
SteamVR Date: 2017-02-24
Steam: Public
Steam Branch: beta
Steam AppID: 250820
Tracking: lighthouse
OS: Linux version 4.8.0-37-generic (buildd@lcy01-17) (gcc version 6.2.0 20161005 (Ubuntu 6.2.0-5ubuntu12) ) #39-Ubuntu SMP Thu Jan 26 02:27:07 UTC 2017
@leinardi
leinardi / ProgressDialogFragment.java
Created October 25, 2016 12:01
Yet another ProgressDialogFragment implementation
public class ProgressDialogFragment extends DialogFragment {
private static final String TAG = ProgressDialogFragment.class.getName();
private static final String KEY_TITLE = TAG + "_message";
private static final String KEY_MESSAGE = TAG + "_title";
/**
* Create and show a ProgressDialogFragment with the given message.
*
* @param fragmentManager The FragmentManager this fragment will be added to
* @param message displayed message