This was taken from http://rxwiki.wikidot.com/101samples, because I wanted to be able to read it more comfortable with syntax highlighting.
Here's the unedited original, translated to Github Markdown glory:
| this += repository.getImages(params) | |
| .compose(applySingleAsync()) | |
| .subscribe { result -> | |
| result.fold( | |
| onSuccess = { }, | |
| onFailure = { } | |
| ) | |
| } |
| internal class ImagesRepositoryImpl(private val source: ImageDataSource) : ImagesRepository { | |
| override fun getImages(params: Map<String, String>): Single<Result<ImagesResponse>> { | |
| return source.getImages(params) | |
| .map { Result.success(it) } | |
| .compose(applyRetryPolicy(TIMEOUT, maxRetries = 5, interval = 2, unit = TimeUnit.SECONDS) { Single.just(Result.failure(it)) }) | |
| } | |
| } |
| internal typealias RETRY_PREDICATE = (Throwable) -> Boolean | |
| internal const val MAX_RETRIES = 3L | |
| internal const val DEFAULT_INTERVAL = 1L | |
| internal val TIMEOUT: RETRY_PREDICATE = { it is SocketTimeoutException } | |
| internal val NETWORK: RETRY_PREDICATE = { it is IOException } | |
| internal val SERVICE_UNAVAILABLE: RETRY_PREDICATE = { it is HttpException && it.code() == 503 } | |
| internal fun <T> applyRetryPolicy( |
| import 'dart:io'; | |
| import 'dart:ui' as ui; | |
| import 'package:flutter/material.dart'; | |
| import 'package:path_provider/path_provider.dart'; | |
| void main() => runApp(MyApp()); | |
| String FILENAME = 'timg.jpeg'; |
This was taken from http://rxwiki.wikidot.com/101samples, because I wanted to be able to read it more comfortable with syntax highlighting.
Here's the unedited original, translated to Github Markdown glory:
| lazy var accessoryToolbarWithDoneButton: UIToolbar = { | |
| let toolbar = UIToolbar(frame: CGRect.zero) | |
| //only needs to be flexible in the dimension(s) you want it to be | |
| //https://stackoverflow.com/questions/31822504/how-can-i-increase-the-height-of-an-inputaccessoryview | |
| toolbar.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
| let leftSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) | |
| let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(keyboardDoneButtonTapped(_:))) | |
| toolbar.items = [leftSpace, doneButton] |
| #!/bin/bash | |
| # A bash script to create a time machine disk image suitable for | |
| # backups with OS X 10.6 (Snow Leopard) | |
| # This script probably only works for me, so try it at your own peril! | |
| # Use, distribute, and modify as you see fit but leave this header intact. | |
| # (R) sunkid - September 5, 2009 | |
| # | |
| # This will create a time machine ready disk image named with your | |
| # computer's name with a maximum size of 600GB and copy it to | |
| # /Volumes/backup. The image "file" (it's a directory, really) will |
| server { | |
| listen 80; | |
| server_name localhost; | |
| root /Users/YOUR_USERNAME/Sites; | |
| access_log /usr/local/var/log/nginx/default.access.log main; | |
| location / { | |
| include /usr/local/etc/nginx/conf.d/php-fpm; | |
| } |
| apply plugin: 'kotlin-kapt' | |
| // ...(중략)... | |
| dependencies { | |
| // for async logic | |
| implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' | |
| // Room | |
| implementation "androidx.room:room-runtime:2.2.2" |
| // | |
| // UIViewController+Rotation.m | |
| // Ulysses | |
| // | |
| // Created by Götz Fabian on 12.10.17. | |
| // Copyright © 2017 Ulysses GmbH & Co. KG. All rights reserved. | |
| // | |
| #import "UIViewController+Rotation.h" |