(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# The trick is to link the DeviceSupport folder from the beta to the stable version. | |
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :) | |
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5: | |
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport | |
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions | |
# (A similar approach works for older versions too, just change the version number after DeviceSupport) |
import Cocoa | |
// Missing isWord | |
func isWord(string: String) -> Bool { | |
if let _ = Int(string) { return false } | |
let range = NSSpellChecker.shared().checkSpelling(of: string, startingAt: 0) | |
return range.location == NSNotFound | |
} | |
/*: |
import UIKit | |
// Swift rewrite challenge | |
// Starting point: https://gist.github.com/jkereako/200342b66b5416fd715a#file-scale-and-crop-image-swift | |
func scaleAndCropImage( | |
image: UIImage, | |
toSize size: CGSize, | |
fitImage: Bool = true | |
) -> UIImage { |
import Foundation | |
// Extend String to support regex searching by conforming | |
// to CustomStringConvertible | |
extension String: CustomStringConvertible { | |
public var description: String {return self} | |
} | |
// Regex support for keys | |
public extension Dictionary where Key: CustomStringConvertible { |
#! /usr/bin/env python | |
# coding: utf-8 | |
''' | |
auto switch keyboard between different applications | |
if you want to change the app list, modify the var 'ignore_list' | |
''' | |
from AppKit import NSWorkspace, NSWorkspaceDidActivateApplicationNotification, NSWorkspaceApplicationKey |
import Cocoa | |
// Note: use of enumeration var in generic is instadeath | |
// Note: use of static var in generic is not yet supported | |
public protocol EnumConvertible: Hashable { | |
init?(hashValue hash: Int) | |
static func countMembers() -> Int | |
static func members() -> [Self] | |
} |
// | |
// main.swift | |
// pggrep - updated 12/4/15 | |
// Created by Erica Sadun on 6/17/15. | |
// Copyright © 2015 Erica Sadun. All rights reserved. | |
// | |
import Foundation | |
extension String { |
import Cocoa | |
/// A wrapper around any type to make Result compile | |
class Box<T> { | |
let unbox: T | |
init(_ value: T) { | |
self.unbox = value | |
} | |
} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.