- "Introduction to Bluetooth Low Energy" by Adafruit.
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 connectionObserveration(context: Context): Disposable? { | |
if ((firstObserver == null || firstObserver!!.isDisposed) && (secondObserver == null || secondObserver!!.isDisposed())) { | |
secondObserver = ReactiveNetwork.observeNetworkConnectivity(context) | |
.subscribeOn(AndroidSchedulers.mainThread()) | |
.filter(ConnectivityPredicate.hasState(NetworkInfo.State.CONNECTED, NetworkInfo.State.DISCONNECTED)) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe({ connectivity -> | |
if (connectivity.state == NetworkInfo.State.CONNECTED) { | |
firstObserver = ReactiveNetwork.observeInternetConnectivity() | |
.subscribeOn(AndroidSchedulers.mainThread()) |
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
package hello.world | |
import android.bluetooth.BluetoothDevice | |
import android.content.Context | |
import android.content.Intent | |
import android.content.IntentFilter | |
import android.content.BroadcastReceiver | |
import com.polidea.rxandroidble2.RxBleDevice | |
import io.reactivex.Completable | |
import io.reactivex.disposables.Disposables |
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 java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class DemoFreeSpacingRegex { | |
public static void main(String[] args) { | |
String re = "(?x)\n" | |
+ "# ?x is free-spacing flag to allow #comments, must be right at start of String\n" | |
+ "(19|20\\d\\d) # year (group 1)\n" | |
+ "[- /.] # separator\n" |
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
/*: | |
This is an implementation of Algorithm W, as found in [Principal Types for functional programs](http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_types.pdf). | |
We'll start by defining literals and expressions: | |
*/ | |
enum Literal { | |
case string(String) | |
case int(Int) |
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, K> Iterable<T>.multiDistinctBy(vararg selectors: (T) -> K): List<T> { | |
require(selectors.isNotEmpty()) | |
val set = HashSet<Int>() | |
val distinct = ArrayList<T>() | |
for (element in this) { | |
val key = selectors.fold(0) { sum, selector -> | |
sum.plus(selector(element)?.hashCode() ?: 0) } | |
if (set.add(key)) |
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.annotation.TargetApi; | |
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.graphics.drawable.VectorDrawable; | |
import android.os.Build; | |
import android.support.annotation.DrawableRes; | |
import android.support.graphics.drawable.VectorDrawableCompat; |
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
package com.xwray.vectorbinding; | |
import android.databinding.BindingAdapter; | |
import android.databinding.DataBindingUtil; | |
import android.graphics.drawable.Drawable; | |
import android.os.Bundle; | |
import android.support.graphics.drawable.VectorDrawableCompat; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.TextView; |
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
@RunWith(Parameterized::class) | |
class KotlinTest(val paramOne: Int, val paramTwo: String) { | |
companion object { | |
@JvmStatic | |
@Parameterized.Parameters | |
fun data() : Collection<Array<Any>> { | |
return listOf( | |
arrayOf(1, "I"), // First test: (paramOne = 1, paramTwo = "I") | |
arrayOf(1999, "MCMXCIX") // Second test: (paramOne = 1999, paramTwo = "MCMXCIX") |
NewerOlder