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 | |
| class Timer { | |
| private let source: DispatchSourceTimer | |
| private let block: () -> () | |
| public let isRepeating: Bool | |
| init(_ interval: DispatchTimeInterval, repeat shouldRepeat: Bool = false, block: @escaping () -> ()) { | |
| self.source = DispatchSource.makeTimerSource() |
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 Cocoa | |
| import Combine | |
| class Timer: Cancellable, Publisher { | |
| enum Error: Swift.Error { | |
| case cancelled | |
| } | |
| typealias Output = Never | |
| typealias Failure = Error |
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
| Check it out |
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
| {{- $original := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) -}} | |
| {{- if findRE ".*@2x*." $original.Name -}} | |
| {{- .Scratch.Set "image" ($original.Fit "2400x2400 q40") -}} | |
| {{- else if findRE ".*@3x*." $original.Name -}} | |
| {{- .Scratch.Set "image" ($original.Fit "3600x3600 q40") -}} | |
| {{- else -}} | |
| {{- .Scratch.Set "image" ($original.Fit "1200x1200 q55") -}} | |
| {{- 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
| name: now | |
| on: | |
| push: | |
| jobs: | |
| deploy-prod: | |
| name: Deploy prod | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' | |
| steps: |
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
| 🎉 |
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 hyperx = require('hyperx') | |
| const hx = hyperx((componentName, properties, children) => { | |
| return ['createElement', componentName, properties, children] | |
| }, (children) => { | |
| return ['createFragment', children] | |
| }) | |
| class Header { | |
| async fetch (ctx) { |
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
| function sorter () { return 0.5 - Math.random() } | |
| var styles = [ 'blaze', 'sunshine', 'dusk', 'blood', 'puce' ] | |
| function colorize () { | |
| var style = styles.sort(sorter)[0] | |
| document.body.className = style | |
| } | |
| colorize() | |
| setInterval(colorize, 10000) |
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 URL { | |
| func appendingQueryItems(_ items: [String: String]) -> URL { | |
| guard var components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { | |
| fatalError() | |
| } | |
| var query = components.queryItems ?? [] | |
| items.forEach { (name, value) in | |
| query.append(URLQueryItem(name: name, value: value)) |
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 Names: SimplePublisher { | |
| typealias Output = Result<String, Error> | |
| var subscriptions = [SimpleSubscription<Output, Failure>]() | |
| let names = ["Alice", "Bob", "Claris", "Doug"] | |
| shoutName() { | |
| if let name = names.randomElement() { | |
| publish(.success(name)) | |
| } else { | |
| assertionFailure("There are def some names in there...") |