Skip to content

Instantly share code, notes, and snippets.

Gabriel Peal gpeal

  • Tonal
  • San Francisco, CA
Block or report user

Report or block gpeal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gpeal
gpeal / stack.txt
Created Jun 14, 2019
MvRx reflection ConcurrentModiifcationException
View stack.txt
java.util.ConcurrentModificationException: null
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$KeyIterator.next(HashMap.java:814)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:266)
at java.util.jar.JarFile.getInputStream(JarFile.java:380)
at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
at java.net.URL.openStream(URL.java:470)
at java.util.ServiceLoader$ServiceIterator.readClass(ServiceLoader.java:224)
at java.util.ServiceLoader$ServiceIterator.hasNext(ServiceLoader.java:202)
at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:220)
@gpeal
gpeal / convert.js
Last active Jun 5, 2019
This will convet a Lottie json file that doesn't have "ty" properties at the beginning of the object to one that does.
View convert.js
const fs = require('fs');
convert = (json) => {
if (typeof json != "object") {
return json
}
for (var key in json) {
if (json.hasOwnProperty(key)) {
json[key] = convert(json[key])
}
View CoroutineExecute.kt
fun <T : Any?> execute(
fn: suspend () -> T,
onError: (suspend (Exception) -> Unit)? = null,
dispatcher: CoroutineDispatcher = Dispatchers.Default,
reducer: S.(Async<T>) -> S
) {
uiScope.launch(dispatcher) {
setState { reducer(Loading()) }
try {
val result = fn()
View CounterFragment.kt
package com.airbnb.mvrx.counter
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.BaseMvRxFragment
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MvRxState
View gist:3b6cb4aaac2468aca407f81fe9193db3
Repo: https://github.com/airbnb/lottie-android.git
Start time: 2018-11-15T17:46:26Z
$ docker "run" "-v" "/var/run/docker.sock:/var/run/docker.sock" "-v" "/bitrise:/bitrise" "-v" "/tmp/bitrise-agent270117773:/.bitrise-config" "--privileged" "--network=host" "--name=bitrise-main-container" "bitriseio/android:pinned" "bitrise" "run" "--config" "/.bitrise-config/bitrise.yml" "--inventory" "/.bitrise-config/bitrise.secrets.yml" "--json-params-base64" "eyJ3b3JrZmxvdyI6InZhbGlkYXRpb25fd29ya2Zsb3dfbm9fc3NoIn0="
██████╗ ██╗████████╗██████╗ ██╗███████╗███████╗
██╔══██╗██║╚══██╔══╝██╔══██╗██║██╔════╝██╔════╝
██████╔╝██║ ██║ ██████╔╝██║███████╗█████╗
██╔══██╗██║ ██║ ██╔══██╗██║╚════██║██╔══╝
██████╔╝██║ ██║ ██║ ██║██║███████║███████╗
View ViewBinders.kt
package com.yourapp
import android.support.annotation.IdRes
import android.support.v4.app.Fragment
import android.view.View
import android.view.ViewGroup
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
private object UNINITIALIZED
View HelloWorldFragment.kt
data class HelloWorldState(val title: String = "Hello World") : MvRxState
class HelloWorldViewModel(initialState: HelloWorldState) : MvRxViewModel<HelloWorldState>(initialState) {
fun getMoreExcited() = setState { copy(title = "$title!") }
}
class HelloWorldFragment : BaseFragment() {
private val viewModel by fragmentViewModel(HelloWorldViewModel::class)
override fun EpoxyController.buildModels() = withState(viewModel) { state ->
View MvRxMapExtensions.kt
/**
* Returns a new immutable map with the provided keys set/updated.
*/
fun <K, V> Map<K, V>.copy(vararg pairs: Pair<K, V>) = HashMap<K, V>(size + pairs.size).apply {
putAll(this@copy)
pairs.forEach { put(it.first, it.second) }
}
/**
* Returns a new map with the provided keys removed.
@gpeal
gpeal / MvRxFragment.kt
Created Jul 24, 2018
MvRxFragmentExtension
View MvRxFragment.kt
fun <S : MvRxState> MvRxViewModel<S>.subscribe(
shouldUpdate: ((S, S) -> Boolean)? = null,
observerScheduler: Scheduler = AndroidSchedulers.mainThread(),
subscriber: ((S) -> Unit)? = null
) = subscribe(this@MvRxFragment, shouldUpdate, observerScheduler, subscriber ?: { if (readyToInvalidate()) invalidate() })
View Epoxy.swift
override func itemModel(forDataID dataID: DemoDataID) -> EpoxyableModel? {
switch dataID {
case .header:
return DocumentMarquee.epoxyModel(
content: DocumentMarquee.Content(titleText: "Edit Profile"),
style: .standard,
dataID: DemoDataID.header)
case .inputRow:
return InputRow.epoxyModel(
content: InputRow.Content(
You can’t perform that action at this time.