This file contains hidden or 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
const { runTest } = require('./t') | |
let testCache = {} | |
const ctxId = runDirtyTests() | |
module.hot.accept(ctxId, runDirtyTests) | |
module.hot.accept() | |
module.hot.dispose(() => { testCache = {} }) |
This file contains hidden or 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
// @flow | |
import React, { Component } from 'react' | |
type State = { s: StartState | EndState } | |
type StartState = { stage: 'start' } | |
type EndState = { stage: 'end' } | |
// c.f. http://stackoverflow.com/questions/41604525/do-flow-refinements-not-propagate-up | |
export default class App extends React.Component { |
This file contains hidden or 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
// @flow | |
import React from 'react' | |
import type { AdminProof } from './User' | |
export default function AdminOnly(props: { proof: AdminProof }) { | |
return <p>Secret admin stuff!</p> | |
} |
This file contains hidden or 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 Control.Monad.Except (ExceptT, runExceptT) | |
import Control.Monad.State.Class (get, put) | |
import Control.Monad.State.Strict (StateT, evalStateT) | |
import Data.Attoparsec.ByteString | |
import qualified Data.Attoparsec.ByteString as A | |
import Data.ByteString (ByteString) | |
import qualified Data.ByteString as BS | |
import Data.Monoid ((<>)) | |
import qualified Data.Streaming.Zlib as Z |
This file contains hidden or 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
object Quick { | |
def sort(xs: Array[Int]): Unit = { | |
def go(start: Int, end: Int): Unit = { | |
if (end - start > 1) { | |
val i = partition(start, end) | |
go(start, i) | |
go(i + 1, end) | |
} | |
} |
This file contains hidden or 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
object Quick { | |
def sort(xs: Array[Int]): Unit = { | |
def go(lo: Int, hi: Int): Unit = { | |
if (lo < hi) { | |
val p = partition(xs, lo, hi) | |
go(lo, p - 1) | |
go(p + 1, hi) | |
} | |
} |
This file contains hidden or 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 RxSwift | |
import RxSwiftExt | |
class Signal<E>: ObservableConvertibleType { | |
private let _out: Variable<E> | |
var value: E { return _out.value } | |
init(out: Variable<E>) { | |
_out = out | |
} | |
func map<R>(selector: E -> R) -> Signal<R> { |
This file contains hidden or 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 SimpleSignal<E> { | |
private let _v: Variable<E> | |
var value: E { return _v.value } | |
private let _disposeBag = DisposeBag() | |
init(initialValue: E, subsequentValues: Observable<E>) { | |
_v = Variable(initialValue) | |
subsequentValues.bindTo(self._v).addDisposableTo(_disposeBag) | |
} | |
This file contains hidden or 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 RxSwift | |
import RxSwiftExt | |
class Signal<Element>: ObservableConvertibleType, DriverConvertibleType { | |
typealias E = Element | |
private let _v: Variable<E> | |
var value: E { return _v.value } | |
init(initialValue: E, subsequentValues: Observable<E>) { |
This file contains hidden or 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 Variable { | |
func debug() -> Self { | |
_ = self.asObservable().debug().subscribeNext { _ in } | |
return self | |
} | |
static func combineLatest<A, B>(a: Variable<A>, _ b: Variable<B>, resultSelector: (A, B) -> E) -> Variable<E> { | |
let v = Variable(resultSelector(a.value, b.value)) | |
_ = Observable.combineLatest(a.asObservable().skip(1), b.asObservable().skip(1), resultSelector: resultSelector).subscribeNext { e in | |
v.value = e |