Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.
You've got two main options:
# ------------------------------------------------------------------ | |
# EDIT: I eventually found a faster way to run SD on macOS, via MPSGraph (~0.8s / step on M1 Pro): | |
# https://github.com/madebyollin/maple-diffusion | |
# The original CoreML-related code & discussion is preserved below :) | |
# ------------------------------------------------------------------ | |
# you too can run stable diffusion on the apple silicon GPU (no ANE sadly) | |
# | |
# quick test portraits (each took 50 steps x 2s / step ~= 100s on my M1 Pro): | |
# * https://i.imgur.com/5ywISvm.png |
func preprocessImage() -> UIImage{ | |
var image = canvasView.drawing.image(from: canvasView.drawing.bounds, scale: 10.0) | |
if let newImage = UIImage(color: .black, size: CGSize(width: view.frame.width, height: view.frame.height)){ | |
if let overlayedImage = newImage.image(byDrawingImage: image, inRect: CGRect(x: view.center.x, y: view.center.y, width: view.frame.width, height: view.frame.height)){ | |
image = overlayedImage | |
} | |
} | |
} |
/* | |
*** Academy Engraved LET *** | |
AcademyEngravedLetPlain | |
--------------------- | |
*** Al Nile *** | |
AlNile | |
AlNile-Bold | |
--------------------- | |
*** American Typewriter *** | |
AmericanTypewriter |
import Foundation | |
protocol Settings { | |
subscript(key: String) -> AnyObject? { get nonmutating set } | |
} | |
struct Defaults: Settings { | |
typealias Set = (String, AnyObject?) -> Void | |
typealias Get = (String) -> AnyObject? | |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
// It is important to declare your variables. | |
(function() { | |
var foo = 'Hello, world!'; | |
print(foo); //=> Hello, world! | |
})(); | |
// Because if you don't, the become global variables. | |
(function() { |