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 isUpdateAvailable(completion: @escaping (Bool?, Error?) -> Void) throws -> URLSessionDataTask { | |
print("\(String(describing: type(of: self))) \(#function)", level: .info) | |
guard let info = Bundle.main.infoDictionary, | |
let currentVersion = info["CFBundleShortVersionString"] as? String, | |
let identifier = info["CFBundleIdentifier"] as? String, | |
let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(identifier)") else { | |
throw VersionError.invalidBundleInfo | |
} | |
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in | |
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
/** | |
* Check a password in the [haveibeenpwned](https://haveibeenpwned.com/Passwords) database. | |
* | |
* Uses a secure mechanism for sending passwords according to the API spec. First, the password is hashed using the | |
* SHA-1 secure hash algorithm. Then, the first 5 characters are sent to the API. The API returns a list of possible | |
* matches and the calculated hash is used to check if the password exists in the returned list. | |
* | |
* @async | |
* @author Khan Winter (https://github.com/thecoolwinter) | |
* @license MIT |
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
// | |
// NSLabel.swift | |
// | |
// | |
// Created by Khan Winter on 4/8/22. | |
// | |
import AppKit | |
class NSLabel: NSView { |
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
/// The `DelayedTask` waits to execute an action, and will only call it's `onEnd` completion if the | |
/// `action` has been performed. | |
/// | |
/// This allows for situations where you may `await` for a cache item that could take a small amount of time, | |
/// but it could also require a network call. An example of such a situation is below: | |
/// ```swift | |
/// Task { | |
/// self.showLoadingIndicator() | |
/// let data = await ResourceManager.getData() | |
/// self.removeLoadingIndicator() |
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 Fluent | |
extension SchemaBuilder { | |
enum TimestampTypes: Equatable { | |
case createdAt(_ fieldName: String = "createdAt") | |
case updatedAt(_ fieldName: String = "updatedAt") | |
case deletedAt(_ fieldName: String = "deletedAt") | |
} | |
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 zsh | |
previous_val=$(defaults read com.apple.finder CreateDesktop) | |
if [ "$previous_val" = "true" ] | |
then | |
previous_val=$(echo 'false'); | |
else | |
previous_val=$(echo 'true') | |
fi |
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 | |
final class ContentSizedTableView: UITableView { | |
override var contentSize:CGSize { | |
didSet { | |
invalidateIntrinsicContentSize() | |
} | |
} |
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
// | |
// ExtraCodable.swift | |
// | |
// Created by Khan Winter on 3/16/21. | |
// Copyright © 2021 WindChillMedia. All rights reserved. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
// | |
// PercentageField.swift | |
// | |
// Created by Khan Winter on 8/16/20. | |
// | |
import UIKit | |
class PercentageField: UITextField { |
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 | |
public class CodableStorage { | |
fileprivate init() { } | |
enum Directory { | |
case documents | |
case caches | |
case shared // Use for sharing files between containers. Eg, with an app extension. |