I hereby claim:
- I am jarsen on github.
- I am jarsen (https://keybase.io/jarsen) on keybase.
- I have a public key ASA-ZqyUHPk5dr-lESy6TrMX4qO5hFqdGOKjBBqrP7qaqQo
To claim this, I am signing this object:
| defmodule MarkovChain do | |
| def create_chain(source, ngram_length) do | |
| source | |
| |> Stream.chunk_every(ngram_length + 1, 1) | |
| |> Stream.map(fn chunk -> Enum.split(chunk, ngram_length) end) | |
| |> Stream.scan(%{}, fn {ngram, word}, acc -> | |
| Map.update(acc, ngram, word, fn val -> val ++ word end) | |
| end) | |
| end | |
I hereby claim:
To claim this, I am signing this object:
| import Foundation | |
| // | |
| // MARK: - JSONError Type | |
| // | |
| public enum JSONError: ErrorType, CustomStringConvertible { | |
| case KeyNotFound(key: String) | |
| case NullValue(key: String) | |
| case TypeMismatch(expected: Any, actual: Any) |
| protocol StoryboardInstantiable { | |
| static var storyboardName: String { get } | |
| static var storyboardIdentifier: String { get } | |
| } | |
| extension StoryboardInstantiable { | |
| static func instantiateFromStoryboard() -> Self { | |
| let storyboard = UIStoryboard(name: storyboardName, bundle: nil) | |
| guard let vc = storyboard.instantiateViewControllerWithIdentifier(storyboardIdentifier) as? Self else { | |
| fatalError("Instantiated view controller does not match type") |
| import UIKit | |
| enum MyError: ErrorType { | |
| case Oooggh(String) | |
| } | |
| func errorProne() throws { | |
| throw MyError.Oooggh("nope") | |
| } |
| import Foundation | |
| // | |
| // MARK: - JSONError Type | |
| // | |
| public enum JSONError: ErrorType, CustomStringConvertible { | |
| case KeyNotFound(key: JSONKeyType) | |
| case NullValue(key: JSONKeyType) | |
| case TypeMismatch(expected: Any, actual: Any) |
| // MARK: - Keys | |
| import Foundation | |
| public protocol JSONKeyType { | |
| var JSONKey: String { get } | |
| } | |
| extension String: JSONKeyType { | |
| public var JSONKey: String { |
| func keyboardWillShow(notification: NSNotification) { | |
| print("Showing keyboard") | |
| guard let userInfo = notification.userInfo, | |
| rectValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue, | |
| rawCurve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? UInt, | |
| duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Double else { | |
| return | |
| } | |
| let keyboardFrame = rectValue.CGRectValue() |
| func attemptMap<T, U>(operation: T throws -> U) -> ReactiveCocoa.Signal<T, NSError> -> ReactiveCocoa.Signal<U, NSError> { | |
| return { signal in | |
| return Signal { observer in | |
| signal.observe(next: { value in | |
| do { | |
| sendNext(observer, try operation(value)) | |
| } | |
| catch { | |
| sendError(observer, error as NSError) |
| protocol Debuggable { | |
| var debug: Bool { get set } | |
| func debugPrint(message: String) | |
| } | |
| extension Debuggable { | |
| func debugPrint(message: String) { | |
| if debug { | |
| print(message) | |
| } |