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
sealed class Either<out L, out R> { | |
companion object { | |
fun <L> left(left: L): Left<L, Nothing> = Left(left) | |
fun <R> right(right: R): Right<Nothing, R> = Right(right) | |
} | |
fun left(): L? = when (this) { | |
is Left -> this.l | |
is Right -> null |
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
public protocol Apply {} | |
extension Apply where Self: Any { | |
//let f = Foo().apply { | |
// $0.foo = 10 | |
// $0.bar = "bar" | |
//} | |
public func apply(_ block: (inout Self) -> Void) -> Self { | |
var copy = self |
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
/* | |
* Copyright (C) 2010 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 |
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
//swift | |
protocol Addable { | |
func add(lhs: Self, rhs: Self) -> Self | |
} | |
extension String: Addable { | |
func add(lhs: String, rhs: String) -> String { | |
return lhs + rhs | |
} |
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
" Colemak stuff | |
nnoremap k h | |
nnoremap n j | |
nnoremap e k | |
nnoremap i l | |
nnoremap d v | |
nnoremap D V | |
nnoremap s d | |
nnoremap S D |
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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <memory> | |
using namespace std; | |
class Possible { | |
vector<bool> _b; | |
public: | |
Possible() : _b(9, true) {} |
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
class RxJavaActivity : AppCompatActivity() { | |
val cities = Observable.just("Warsaw", "Paris", "London", "Madrid", "Tokyo") | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
concatMap() | |
// flatMap() |
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
#include <string> | |
#include <chrono> | |
#include <thread> | |
#include <iostream> | |
using namespace std::chrono; | |
auto calculation1(std::string d) { | |
std::this_thread::sleep_for(seconds(5)); | |
return "cal1_" + d; |
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 io.reactivex.Observable | |
import io.reactivex.Scheduler | |
import io.reactivex.annotations.CheckReturnValue | |
import io.reactivex.disposables.Disposable | |
import io.reactivex.schedulers.Schedulers | |
import io.reactivex.subjects.PublishSubject | |
interface Action | |
interface State |