Enter this in the search box along with your search terms:
Get all gists from the user santisbon.
user:santisbon
Find all gists with a .yml extension.
extension:yml
Find all gists with HTML files.
language:html
| fun <T> backoff(times: Int = Int.MAX_VALUE, predicate: (Throwable, Int) -> Boolean = { _, _ -> true }): ObservableTransformer<T, T> { | |
| return ObservableTransformer { | |
| it.retryWhen { attempts -> | |
| val counter = AtomicInteger() | |
| attempts.takeWhile { e -> counter.getAndIncrement() < times && predicate(e, counter.get()) } | |
| .flatMap { Observable.timer(counter.get().toLong(), TimeUnit.SECONDS) } | |
| } | |
| } | |
| } |
| // | |
| // UIView+Extensions.swift | |
| // | |
| // Created by Luis Ramos on 17/5/18. | |
| // | |
| import UIKit | |
| extension UIView { | |
Enter this in the search box along with your search terms:
Get all gists from the user santisbon.
user:santisbon
Find all gists with a .yml extension.
extension:yml
Find all gists with HTML files.
language:html
| package com.your.package | |
| import android.app.Dialog | |
| import android.os.Bundle | |
| import com.your.package.R | |
| import com.google.android.material.bottomsheet.BottomSheetDialog | |
| import com.google.android.material.bottomsheet.BottomSheetDialogFragment | |
| /** | |
| * BottomSheetDialog fragment that uses a custom |
| // //////////////////////////////// | |
| // How to use? | |
| // 1. Make sure you've ran the `sequelize init` before (It should create `config`,`seeders`,`migrations` folders). | |
| // 2. Run it with `node sequelize-schema-file-generator.js` | |
| // 3. Review the generated migrations inside of the `migrations` folder. | |
| // //////////////////////////////// | |
| /* jscs:disable */ | |
| /* jshint ignore:start */ | |
| var path = require('path') |
| /* | |
| * Copyright (C) 2017 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| private val callback = object : RoomDatabase.Callback() { | |
| override fun onCreate(db: SupportSQLiteDatabase) { | |
| try { | |
| // First time to database was created, check if user upgraded from a previous | |
| // version of the app that was using ORMLite and migrate data if needed. | |
| val context = TradeMeApp.getContext() | |
| val previousDB = context.applicationContext.getDatabasePath(PREVIOUS_DATABASE_FILE) | |
| if (previousDB.exists()) { | |
| MigrateToRoom(previousDB, context.component.database).execute() | |
| } |
| /* | |
| * Copyright (c) 2017 Halcyon Mobile | |
| * http://www.halcyonmobile.com | |
| * All rights reserved. | |
| */ | |
| import android.databinding.DataBindingUtil | |
| import android.databinding.OnRebindCallback | |
| import android.databinding.ViewDataBinding | |
| import android.support.annotation.CallSuper | |
| import android.support.annotation.LayoutRes |
| /** | |
| * 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) | |
| } | |
| }) | |
| } |
| class MainViewModel { | |
| val visible = ObservableBoolean(false) | |
| } |