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 React from 'react'; | |
| import Spinner from 'react-spinner'; | |
| export default function loadable(hasLoadedTest, Component) { | |
| return (props) => { | |
| if (hasLoadedTest(props)) { | |
| return <Component { ...props } />; | |
| } | |
| else { | |
| return <Spinner />; |
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 Foundation | |
| protocol StageProtocol { | |
| func perform() throws -> Self? | |
| var queue: dispatch_queue_t { get } | |
| func run(completion: (() throws -> Self) -> ()) | |
| } |
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
| enum Fruit { | |
| case apple, pear, orange, plum | |
| } | |
| extension Fruit { | |
| var cents: Int { | |
| return switch self [ | |
| .apple: 70, | |
| .pear: 85, | |
| .orange: 40, |
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
| //: Types for currency conversion | |
| // https://www.natashatherobot.com/swift-money-phantom-types/ | |
| import Foundation | |
| struct Money { | |
| enum Currency { | |
| case GBP, EUR, USD | |
| } |
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
| struct Person { | |
| var firstName, lastName: String | |
| mutating func makeScottishClan() { | |
| lastName = "mc\(lastName)" | |
| } | |
| } | |
| // Person.Mutation gets automatically created (like an enum) | |
| // .firstName(String) |
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
| //: Responder chain in Swift using enums | |
| protocol CommandProtocol {} | |
| protocol Responder: class { | |
| var nextResponder: Responder? { get } | |
| func performerForCommand | |
| <Command : CommandProtocol> | |
| (command: Command) -> (() -> ())? |
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
| public struct Person { | |
| public var firstName: String | |
| public var middleName: String? | |
| public var lastName: String | |
| public var ageInYears: Int | |
| public var fullName: String { | |
| return [firstName, middleName, lastName].flatMap{ $0 }.joinWithSeparator(" ") | |
| } | |
| } |
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
| FROM ruby:2.4-alpine | |
| ENV PATH /root/.yarn/bin:$PATH | |
| RUN apk update && apk upgrade && \ | |
| apk add --no-cache bash git openssh build-base nodejs tzdata | |
| RUN apk update \ | |
| && apk add curl bash binutils tar gnupg \ | |
| && rm -rf /var/cache/apk/* \ |
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
| //: Playground - noun: a place where people can play | |
| import Foundation | |
| struct ExampleStruct : Codable { | |
| var title: String | |
| var something: Int | |
| public func encode(to encoder: Encoder) throws { |
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
| interface State { | |
| counter: number | |
| } | |
| const counterModel = { | |
| initial(): State { | |
| return { | |
| counter: 0 | |
| }; | |
| }, |