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
| // | |
| // Client.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network |
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 SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| Button("Server") { | |
| server?.start() | |
| } | |
| Spacer() | |
| Button("Client") { |
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
| // | |
| // Server.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network | |
| import UIKit |
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
| func combineAsyncCalls(completionHandler: @escaping (String)->()) { | |
| var text = "" | |
| let semaphore = DispatchSemaphore(value: 0) | |
| DispatchQueue.global().async { | |
| fetchData(0, delay: 0.4) { | |
| text += $0 | |
| semaphore.signal() | |
| } | |
| fetchData(1, delay: 0.2) { | |
| text += $0 |
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 express = require('express') | |
| const app = express() | |
| const port = 3000 | |
| const increment = function () { | |
| counter ++ | |
| setTimeout(increment, 1000); | |
| } | |
| var maxAge = 4 |
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 | |
| URLCache.shared.removeAllCachedResponses() // start each "experiment" with empty cache | |
| let timer = Timer(timeInterval: 1, repeats: true) { _ in | |
| fetch(title: "useProtocolCachePolicy", policy: .useProtocolCachePolicy) | |
| fetch(title: "returnCacheDataElseLoad", policy: .returnCacheDataElseLoad) | |
| fetch(title: "reloadIgnoringLocalCacheData", policy: .reloadIgnoringLocalCacheData) | |
| // fetch(title: "returnCacheDataDontLoad", policy: .returnCacheDataDontLoad) | |
| } |
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 express = require('express') | |
| const app = express() | |
| const port = 3000 | |
| const recursive = function (req, res) { | |
| counter ++ | |
| setTimeout(recursive, 300); | |
| } | |
| recursive() |
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 UIKit | |
| import PlaygroundSupport | |
| class MyViewController : UIViewController { | |
| override func loadView() { | |
| let view = UIView() | |
| view.backgroundColor = .white | |
| let label = UILabel() | |
| label.frame = CGRect(x: 150, y: 200, width: 200, height: 20) |
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
| // | |
| // CVPixelBuffer+CMSampleBuffer+Copy.swift | |
| // VideoDelaySwift | |
| // | |
| // Created by michal on 16/07/2019. | |
| // Copyright © 2019 michal. All rights reserved. | |
| // | |
| import AVFoundation |
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 AppKit | |
| import AVFoundation | |
| import MetalKit | |
| class PlayerView: MTKView { | |
| private var ciImage: CIImage? { | |
| didSet { | |
| renderImage() | |
| } |