I hereby claim:
- I am jamiesanson on github.
- I am jamiesanson (https://keybase.io/jamiesanson) on keybase.
- I have a public key ASCJYZckhawpHlJ9PCpvFro0NqeHdopuwDh-hk1suNZ80Ao
To claim this, I am signing this object:
pip install textract | |
# If this doesnt work, or fails at some point do this instead | |
pip install --no-deps textract |
''' | |
Script to generate text from Chopra's writings. | |
At least 20 epochs are required before the generated text | |
starts sounding coherent. | |
It is recommended to run this script on GPU, as recurrent | |
networks are quite computationally intensive. | |
If you try this script on new data, make sure your corpus |
import android.arch.lifecycle.* | |
import android.support.v4.app.ActivityCompat | |
import android.support.v4.app.Fragment | |
import android.support.v7.app.AppCompatActivity | |
import kotlin.reflect.KProperty | |
fun <T> Fragment.selfClearing(valInitializer: (() -> T)? = null) = LifecycleDelegate(this.lifecycle, valInitializer) | |
fun <T> AppCompatActivity.selfClearing(valInitializer: (() -> T)? = null) = LifecycleDelegate(this.lifecycle, valInitializer) |
import android.arch.lifecycle.Lifecycle | |
import android.arch.lifecycle.LifecycleObserver | |
import android.arch.lifecycle.LifecycleOwner | |
import android.arch.lifecycle.OnLifecycleEvent | |
import android.content.Context | |
import android.util.AttributeSet | |
import com.wonderkiln.camerakit.* | |
/** | |
* Lifecycle aware view subclass of CameraView to allow automatic starting and stopping on lifecycle |
var resources: Resources? = null | |
val something by R.string.abc_capital_off<String>() | |
private inline operator fun <reified T> Int.invoke(): ReadOnlyProperty<Any, T> { | |
return when { | |
String is T -> StringResolvingDelegate(this) | |
else -> throw IllegalArgumentException("Unexpected resource type") | |
} as ReadOnlyProperty<Any, T> | |
} |
/** | |
* Extends LiveData allowing Kotlin DSL for onChanged callback usage | |
*/ | |
fun <T> LiveData<T>.observeNonNull(lifecycleOwner: LifecycleOwner, onItem: (T) -> Unit) { | |
this.observe(lifecycleOwner, object : NonNullObserver<T> { | |
override fun onChangedNonNull(t: T) { | |
onItem(t) | |
} | |
}) | |
} |
import android.arch.lifecycle.ViewModel | |
import android.arch.lifecycle.ViewModelProvider | |
import android.arch.lifecycle.ViewModelStoreOwner | |
import android.support.v4.app.Fragment | |
import android.support.v7.app.AppCompatActivity | |
import kotlin.reflect.KProperty | |
/** | |
* This class handles retention of any object using the ViewModel framework. An | |
* example of this method being used can be found in the Loader Manager framework |
I hereby claim:
To claim this, I am signing this object:
fun <T> Fragment.viewLifecycle(bindUntilEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY): ReadWriteProperty<Fragment, T> = | |
object: ReadWriteProperty<Fragment, T>, LifecycleObserver { | |
// A backing property to hold our value | |
private var binding: T? = null | |
private var viewLifecycleOwner: LifecycleOwner? = null | |
init { | |
// Observe the View Lifecycle of the Fragment |
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.Observer | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
fun <T> Fragment.viewLifecycleLazy(initialise: () -> T): ReadOnlyProperty<Fragment, T> = | |
object : ReadOnlyProperty<Fragment, T>, DefaultLifecycleObserver { |