Skip to content

Instantly share code, notes, and snippets.

@chriswill0w
chriswill0w / macos-recovery-server.md
Created February 20, 2018 23:51
Fixing "The recovery server could not be contacted" in MacOS High Sierra

I was trying to reinstall High Sierra on an older MacBook Air using internet recovery and I kept on getting an error message when trying to reinstall High Sierra.

The recovery server could not be contacted

It appears that this has to do with the time on the machine not being synchronized, so when the MacBook tries to reach out to the recovery server the certificates do not validate and we get this useless error message.

To fix this.

  1. Open up a Terminal from the utilities menu
  2. Enter the following command
objective-c
po [[[UIWindow keyWindow] rootViewController] _printHierarchy]
swift
expr -l objc++ -O -- [[[UIWindow keyWindow] rootViewController] _printHierarchy]
@chriswill0w
chriswill0w / Fonts.swift
Last active September 20, 2018 10:48 — forked from khanlou/Fonts.swift
Print all fonts in Swift 4 UIFont
for family in UIFont.familyNames {
let sName: String = family as String
print("family: \(sName)")
for name in UIFont.fontNames(forFamilyName: sName) {
print("name: \(name as String)")
}
}
extension UIViewController {
func add(_ child: UIViewController) {
addChildViewController(child)
view.addSubview(child.view)
child.didMove(toParentViewController: self)
}
func remove() {
guard parent != nil else {
return
}
extension UIViewController {
func add(_ child: UIViewController) {
addChildViewController(child)
view.addSubview(child.view)
child.didMove(toParentViewController: self)
}
func remove() {
guard parent != nil else {
return
}
extension Data {
var sizeMB: String{
let formatter = ByteCountFormatter()
formatter.allowedUnits = [.useMB]
formatter.countStyle = .file
return formatter.string(fromByteCount: Int64(self.count))
}
}
@chriswill0w
chriswill0w / AppStoryboard.swift
Created July 26, 2018 08:49 — forked from Gurdeep0602/AppStoryboard.swift
AppStoryboard enumeration
//
// AppStoryboards.swift
// AppStoryboards
//
// Created by Gurdeep on 15/12/16.
// Copyright © 2016 Gurdeep. All rights reserved.
//
import Foundation
import UIKit
import UIKit
import PureLayout
extension UIViewController {
func addChildController(_ controller: UIViewController, containerView: UIView) {
addChild(controller)
// When your custom container calls the addChild(_:) method, it automatically calls the willMove(toParent:) method of the view controller to be added as a child before adding it.
containerView.addSubview(controller.view)
controller.view.translatesAutoresizingMaskIntoConstraints = false
controller.view.autoPinToSuperviewEdges()
import Foundation
import UIKit
/// Checkbox is a simple, animation free checkbox and UISwitch alternative designed
/// to be performant and easy to implement.
public class Checkbox: UIControl {
// MARK: - Enums
/// Shape of the center checkmark that appears when `Checkbox.isChecked == true`.