This file contains 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
while(true) { | |
// 5: Wait for a request | |
let fd = accept(sock, nil, nil) | |
print("Connection made") | |
guard fd >= 0 else { | |
print("Can't accept connection") |
This file contains 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
// 1. Create a socket reference | |
let sock = socket(AF_INET, SOCK_STREAM, 0) // or use AF_INET6 for IPv6 | |
guard sock >= 0 else { | |
fatalError("Failed to open socket") | |
} | |
// 2. Set socket options | |
// (SO_REUSEADDR allows reusing the port if server was shutdown while port active) |
This file contains 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
{ | |
"case_studies": [ | |
{ | |
"client": "TfL", | |
"teaser": "Testing Tube brakes, with TfL Decelerator", | |
"vertical": "Public Sector", | |
"is_enterprise": true, | |
"title": "A World-First For Apple iPad", | |
"hero_image": "https://az759258.vo.msecnd.net/media/2221/decelerator_header-image-2x.jpg", | |
"sections": [ |
This file contains 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
guard let cell = tableView.dequeueReusableCell(withIdentifier: "ProductCell", for: indexPath) as? ProductCell else { | |
// unlikely to happen, but better safe than sorry! | |
assertionFailure("Unable to dequeue cell") | |
return UITableViewCell() | |
} |
This file contains 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
let cell = tableView.dequeueReusableCell(withIdentifier: "ProductCell", for: indexPath) as! ProductCell | |
// use cell as non-optional |
This file contains 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 XCTest | |
@testable import Recipeasy | |
class ExampleTests: XCTestCase { | |
override func setUp() { | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
} | |
override func tearDown() { |
This file contains 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 HomeViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
} | |
/* | |
// MARK: - Navigation |
This file contains 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 | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
} |
This file contains 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
// the first person whose street address is empty | |
people.first(where: ~\.address.street.isEmpty) | |
// => Returns the Person object for "Dick" |
This file contains 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 Bool { | |
/// Returns true for false and false for true | |
var inverted: Bool { | |
return !self | |
} | |
} | |
// only people with non-empty street | |
people.filter(~\.address.street.isEmpty.inverted) |