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 ImageDownsampler { | |
private static let pixelSize = 2_000 | |
/// - URL: https://christianselig.com/2020/09/phpickerviewcontroller-efficiently/ | |
static func downsample(imageAt url: URL) -> Data? { | |
let sourceOptions: [CFString: Any] = [kCGImageSourceShouldCache: false] | |
let downsampleOptions: [CFString: Any] = [ | |
kCGImageSourceCreateThumbnailFromImageAlways: true, | |
kCGImageSourceCreateThumbnailWithTransform: true, | |
kCGImageSourceThumbnailMaxPixelSize: pixelSize |
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
let a = IdentifiableItem(User(id: 1)) | |
let b = IdentifiableItem(User(id: 1), id: \.id) | |
@dynamicMemberLookup | |
struct IdentifiableItem<Item, ID: Hashable>: Identifiable { | |
var item: Item | |
let id: ID | |
init(_ item: Item) where ID == UUID { | |
self.item = item |
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
#!/usr/bin/env sh | |
extract_name() { | |
echo "$1" | sed -rn 's/.*\/(.*)\.colorset.*/\1/p' | |
} | |
extract_hex() { | |
FILE_CONTENTS=$(cat "$1") | |
COMPONENTS=$(echo "$FILE_CONTENTS" | jq '.colors[0].color.components') |
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
tell application "Xcode" to activate | |
tell application "System Events" | |
keystroke "8" using command down -- Show all breakpoints | |
keystroke "a" using command down -- Select all breakpoints | |
keystroke (ASCII character 127) -- Delete with backspace key | |
end tell |
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
pre_install do |installer| | |
installer.pod_targets.each do |pod| | |
if !dynamic_frameworks.include?(pod.name) | |
puts "Overriding the static_framework? method for #{pod.name}" | |
def pod.static_framework?; | |
true | |
end | |
end | |
end | |
end |
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
#!/usr/bin/env sh | |
PLIST_BUDDY="/usr/libexec/PlistBuddy" | |
INFO_PLIST_PATH="app/Info.plist" | |
CURRENT_FULL_VERSION=$("$PLIST_BUDDY" -c "Print CFBundleVersion" "$INFO_PLIST_PATH") | |
CURRENT_MARKETING_VERSION=$("$PLIST_BUDDY" -c "Print CFBundleShortVersionString" "$INFO_PLIST_PATH") | |
ALL_INFO_PLIST_FILES=$(git grep --files-with-matches "CFBundleVersion" -- "*Info.plist") | |
for INFO_PLIST_FILE in $ALL_INFO_PLIST_FILES; do |
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
infix operator ??? | |
extension Optional where Wrapped == String { | |
var isEmptyOrNil: Bool { | |
return self == nil || self == "" | |
} | |
static func ???(lhs: String?, rhs: String) -> String { | |
guard let lhs = lhs, lhs != "" else { | |
return rhs |
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
// Swift safety | |
/// Type safety | |
let i: UInt8 = 1 | |
let x: Int = 4 | |
// Error | |
// let result = i*x |
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 Foundation | |
import PlaygroundSupport | |
// Model | |
struct Character: Decodable { | |
let name: String | |
} | |
// NW |
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 Foundation | |
struct Regex: ExpressibleByStringLiteral { | |
private let pattern: String | |
private var nsRegularExpression: NSRegularExpression? { | |
return try? NSRegularExpression(pattern: pattern) | |
} | |
typealias StringLiteralType = String |
NewerOlder