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 | |
import Accelerate | |
import ImageIO | |
import MobileCoreServices | |
extension UIImage { | |
/// Resamples the image using the Lanczos5 resampling method with the specified scale factor. | |
/// | |
/// - Parameter scale: The scale factor to be applied to the image during resampling. | |
/// - Returns: A new UIImage instance that is the result of the Lanczos5 resampling, or `nil` if the operation fails. |
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 modal | |
stub = modal.Stub("demo_multicontrolnet_failure") | |
modelsVolume = modal.SharedVolume() | |
# https://github.com/huggingface/diffusers/commit/f7b4f51cc2a423c96cb2a4c2282e55feba0be506 | |
GIT_SHA = "f7b4f51cc2a423c96cb2a4c2282e55feba0be506" | |
sd_image = ( | |
modal.Image.debian_slim(python_version="3.10") |
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
{# A template to generate initializer inline #} | |
{# Example: $sourcery --sources <path/to/source.swift> --templates <path/to/this/stencil> --output Output/ #} | |
{% for type in types.structs %} | |
{% set spacing %}{% if type.parentName %} {% endif %}{% endset %} | |
{% map type.storedVariables into parameters using var %}{{ var.name }}: {{ var.typeName }}{% if var.defaultValue %} = {{var.defaultValue}}{% elif var.typeName.isOptional %} = nil{% endif %}{% endmap %} | |
// sourcery:inline:auto:{{ type.name }}.AutoInit | |
{{spacing}} {{ type.accessLevel }} init({{ parameters|join:", " }}) { | |
{{spacing}} {% for variable in type.storedVariables %} | |
{{spacing}} self.{{ variable.name }} = {{ variable.name }} | |
{{spacing}} {% endfor %} |
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 Dictionary where Key: Comparable { | |
func keyOrderMap<T>(_ transform: @escaping ((key: Key, value: Value)) throws -> T) rethrows -> [T] { | |
return try keys.sorted().map { try transform(($0, self[$0]!)) } | |
} | |
} |
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
// https://www.youtube.com/watch?v=d9TpRfDdyU0 | |
let 🖋 = "🖋" | |
let 🍎 = "🍎" | |
let 🍍 = "🍍" | |
func verse(_ s1: String, _ s2: String) -> String { | |
return [s1,s2].map { "I have \(singular($0))" }.joined(separator: ", ") + "\nUh \(s2) \(s1)" | |
} |
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
// | |
// UIImage+OrientationFix.swift | |
// | |
// Created by Sihao Lu on 4/22/15. | |
// Copyright (c) 2015 DJ.Ben. All rights reserved. | |
// | |
import UIKit | |
extension UIImage { |
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
enum Emoji: String { | |
case Copyright = "\u{00A9}" | |
case Registered = "\u{00AE}" | |
case Bangbang = "\u{203C}" | |
case Interrobang = "\u{2049}" | |
case Tm = "\u{2122}" | |
case InformationSource = "\u{2139}" | |
case LeftRightArrow = "\u{2194}" | |
case ArrowUpDown = "\u{2195}" | |
case ArrowUpperLeft = "\u{2196}" |
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
func curry<T, U, V>(value: T, body: (T, U) -> V) -> U -> V { | |
let curried: U -> V = { | |
b in | |
return body(value, b) | |
} | |
return curried | |
} | |
// Examples | |
func add(a: Int, b: Int) -> Int { |