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 Foundation | |
enum PPAP { | |
case Start | |
indirect case Pen(PPAP), Apple(PPAP), Pineapple(PPAP), Finish(PPAP) | |
var output: String { | |
switch self { | |
case .Start: return "ピッピッピコ ピコ太郎〜♪" | |
case .Pen(let p): return "\(p.output)\nI have a ✏️" | |
case .Apple(let p): return "\(p.output)\nI have an 🍎" |
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
fun Reader.forEachChars(block: (Char) -> Unit) { | |
while (true) { | |
val c = read() | |
if (c != -1) { | |
block(c.toChar()) | |
} else return | |
} | |
} | |
fun <R> Reader.mapEachChars(transform: (Char) -> R): List<R> { |
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 java.io.File | |
import java.io.InputStream | |
import java.io.OutputStream | |
import java.io.Reader | |
enum class Token { | |
NEXT, PREV, INC, DEC, GET, PUT, LOOP, JUMP, ROOT | |
} | |
interface Parser { |
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 * as React from "react" | |
import * as Rx from "rxjs" | |
export class Action<T> { | |
constructor(public key: string) {} | |
} | |
interface FluxContext { | |
dispatch: <T extends any>(action: Action<T>, value: T) => void | |
} |
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 DeployGateTree : Timber.Tree() { | |
override fun log(priority: Int, taf: String?, message: String, t: Throwable?) { | |
when (priority) { | |
Log.VERBOSE -> DeployGate.logVerbose(message) | |
Log.INFO -> DeployGate.logInfo(message) | |
Log.DEBUG -> DeployGate.logDebug(message) | |
Log.WARN -> DeployGate.logWarn(message) | |
Log.ERROR -> DeployGate.logError(message) | |
} |
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
extension Unicode.Scalar { | |
var width: UInt32 { | |
let code = self.value | |
if (code >= 0 && code <= 128) { | |
return 1 | |
} else { | |
return 2 | |
} | |
} | |
} |
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
extension Sequence { | |
func zipWith<S2: Sequence>(_ seq2: S2) -> Zip2Sequence<Self, S2> { | |
return zip(self, seq2) | |
} | |
} |
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
extension Sequence { | |
func sumBy(selector: (Element) -> Int) -> Int { | |
return self.reduce(into: 0) { (sum, element) in | |
sum += selector(element) | |
} | |
} | |
} |
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
extension Sequence { | |
func associate<K, V>(_ transform: (Element) -> (K, V)) -> [K: V] { | |
return self.reduce(into: [:]) { (dict, element) in | |
let (key, value) = transform(element) | |
dict[key] = value | |
} | |
} | |
func associateBy<K>(_ keySelector: (Element) -> K) -> [K: Element] { |
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
extension PrimitiveSequenceType where Self: ObservableConvertibleType, Self.TraitType == SingleTrait { | |
func flatMapCompletable(_ selector: @escaping (E) -> Completable) -> Completable { | |
return self | |
.asObservable() | |
.flatMap { e -> Observable<Never> in | |
selector(e).asObservable() | |
} | |
.asCompletable() | |
} |