A layout guide for iOS 10 that is very similar to the safeAreaLayoutGuide from iOS 11.
extension UIView {
///
private final class LayoutGuide : UILayoutGuide {}
///
var guardedAreaLayoutGuide: UILayoutGuide {
if #available(iOS 11, *) {| // This example shows how higher-kinded types can be emulated in Swift today. | |
| // It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation. | |
| // The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism | |
| // by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf | |
| /// `ConstructorTag` represents a type constructor. | |
| /// `Argument` represents an argument to the type constructor. | |
| struct Apply<ConstructorTag, Argument> { | |
| /// An existential containing a value of `Constructor<Argument>` | |
| /// Where `Constructor` is the type constructor represented by `ConstructorTag` |
| import Foundation | |
| import SwiftSyntax | |
| func main() throws { | |
| guard CommandLine.arguments.count > 1 else { | |
| print("usage: swift-format [file]") | |
| exit(-1) | |
| } | |
| let url = URL(fileURLWithPath: CommandLine.arguments[1]) |
| #!/bin/bash | |
| # This a simple bash script to run `cargo clean` recursively. | |
| # | |
| # Usage: `bash cargo-clean.sh target_dir` | |
| clean_recursive() { | |
| # First, check whether current directiry is the root of a cargo project. | |
| if [ -f "Cargo.toml" ]; then | |
| echo "Cleaning \"$(pwd)\"" |
| import Foundation | |
| extension String { | |
| func hyphenated(languageCode: String) -> String { | |
| let locale = Locale(identifier: languageCode) | |
| return self.hyphenated(locale: locale) | |
| } | |
| func hyphenated(locale: Locale) -> String { |
A layout guide for iOS 10 that is very similar to the safeAreaLayoutGuide from iOS 11.
extension UIView {
///
private final class LayoutGuide : UILayoutGuide {}
///
var guardedAreaLayoutGuide: UILayoutGuide {
if #available(iOS 11, *) {| /*: | |
| This is an implementation of Algorithm W, as found in [Principal Types for functional programs](http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_types.pdf). | |
| We'll start by defining literals and expressions: | |
| */ | |
| enum Literal { | |
| case string(String) | |
| case int(Int) |
| /// Playground - noun: a place where people can play | |
| /// I am the very model of a modern Judgement General | |
| //: # Algorithm W | |
| //: In this playground we develop a complete implementation of the classic | |
| //: algorithm W for Hindley-Milner polymorphic type inference in Swift. | |
| //: ## Introduction |
| #!/bin/bash | |
| # Merge multiple repositories into one big monorepo. Migrates every branch in | |
| # every subrepo to the eponymous branch in the monorepo, with all files | |
| # (including in the history) rewritten to live under a subdirectory. | |
| # | |
| # To use a separate temporary directory while migrating, set the GIT_TMPDIR | |
| # envvar. | |
| # | |
| # To access the individual functions instead of executing main, source this |
| // | |
| // DisplayLink.swift | |
| // MetalMac | |
| // | |
| // Created by Jose Canepa on 8/18/16. | |
| // Copyright © 2016 Jose Canepa. All rights reserved. | |
| // | |
| import AppKit |