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 notify | |
import Combine | |
enum Notify {} | |
extension Notify { | |
struct Status: Error { | |
let rawValue: UInt32 | |
init(_ rawValue: UInt32) { | |
self.rawValue = rawValue |
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 Task where Failure == Error { | |
// Start a new Task with a timeout. If the timeout expires before the operation is | |
// completed then the task is cancelled and an error is thrown. | |
init(priority: TaskPriority? = nil, timeout: TimeInterval, operation: @escaping @Sendable () async throws -> Success) { | |
self = Task(priority: priority) { | |
try await withThrowingTaskGroup(of: Success.self) { group -> Success in | |
group.addTask(operation: operation) | |
group.addTask { | |
try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * 1_000_000_000)) |
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 | |
#if canImport(UIKit) | |
import UIKit | |
#elseif canImport(AppKit) | |
import AppKit | |
#elseif canImport(WatchKit) | |
import WatchKit | |
#endif |
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
@propertyWrapper | |
public struct AnyProxy<EnclosingSelf, Value> { | |
private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value> | |
public init(_ keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) { | |
self.keyPath = keyPath | |
} | |
@available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.") | |
public var wrappedValue: Value { |
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
#!/bin/sh | |
RESET=`tput sgr0` | |
RED=`tput setaf 1` | |
GREEN=`tput setaf 2` | |
if [ "$1" ]; then | |
if ! [ -e "$1" ] | |
then |
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 Error { | |
public var legibleDescription: String { | |
switch errorType { | |
case .swiftError(.enum?): | |
return "\(type(of: self)).\(self)" | |
case .swiftError: | |
return String(describing: self) | |
case .swiftLocalizedError(let msg): | |
return msg | |
case .nsError(_, "kCLErrorDomain", 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
import UIKit | |
final class ExampleViewController: UViewController { | |
private var usersBrightness = UIScreen.main.brightness | |
private var willEnterForegroundWasCalled = false | |
private var viewWillDisappearWasCalled = false | |
override func viewDidLoad() { |
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
# setup | |
# pip install cryptography pyjwt | |
# ref. | |
# http://gobiko.com/blog/token-based-authentication-http2-example-apns/ | |
import jwt | |
import time | |
ALGORITHM = 'ES256' |
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
So you'd like to manage your iOS devices by command line? | |
You can use libimobiledevice tools for that. | |
Easy on Linux. Let's see how it is on Mac OS X. | |
You'll need to: | |
1. install Xcode | |
2. start Xcode and agree to it's license | |
3. install Xcode command line tools (Start Xcode, Go to Preferences -> Downloads tab) | |
4. install homebrew by this command (sudo password will be prompted) | |
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" |