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
async function xxx() { | |
for (page of window.__pg) { | |
const blob = await fetch(window.__info.servers[window.__info.img.server] + window.__info.img.url + page.u).then(res => res.blob()); | |
const blob_url = URL.createObjectURL(blob); | |
const a = document.createElement("a"); | |
a.href = blob_url; | |
a.download = window.__info.current.number + '_' + page.u; | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); |
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
static func _compile(data: Data, configuration: MLModelConfiguration = .init()) async throws -> MLModel { | |
let tmp = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) | |
try data.write(to: tmp, options: .atomic) | |
let url = try await MLModel.compileModel(at: tmp) | |
try FileManager.default.removeItem(at: tmp) | |
let model = try MLModel(contentsOf: url, configuration: configuration) | |
try FileManager.default.removeItem(at: url) | |
return model | |
} |
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 sys | |
import os | |
import clang.cindex | |
shaders_file = sys.argv[1] | |
assert(shaders_file.endswith(“.metal”)) | |
ast_file = shaders_file.rstrip(“.metal”) + “.ast” | |
os.system(f”xcrun metal -emit-ast {shaders_file}“) | |
xcode_path = os.popen(“xcode-select -p”).read().rstrip() |
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
swiftformat \ | |
--self insert \ | |
--wrapcollections before-first \ | |
--wraparguments before-first \ | |
--wrapparameters before-first \ | |
--header strip \ | |
--ifdef no-indent \ | |
--enable wrapSwitchCases \ | |
--enable organizeDeclarations \ | |
--swiftversion 5.3 . |
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
struct EnumSet<T: RawRepresentable & CaseIterable>: OptionSet where T.RawValue == Int { | |
let rawValue: T.RawValue | |
init(rawValue: T.RawValue) { | |
self.rawValue = rawValue | |
} | |
init(_ value: T) { | |
self.rawValue = 1 << value.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
--self insert | |
--wrapcollections after-first | |
--wraparguments after-first | |
--wrapparameters after-first | |
--header strip | |
--enable wrapSwitchCases | |
--enable organizeDeclarations |
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 STS | |
final class Registry { | |
// MARK: Internal | |
func register<T: AnyObject>(_ value: T) { | |
self.lock.execute { | |
let key = ObjectIdentifier(T.self) | |
assert(self.objects[key] == nil) | |
assert(self.factories[key] == nil) |
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 CoreVideo | |
import Alloy | |
import Foundation | |
import Accelerate | |
enum MetalCVPixelBuffer { | |
static func transform(texture input: MTLTexture, | |
transformer: @escaping (CVPixelBuffer) throws -> CVPixelBuffer, | |
cache: CVMetalTextureCache) throws -> MTLTexture { | |
guard let inputPixelBuffer = input.pixelBuffer else { |
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 final class ThreadSafe<Root> { | |
private let lock = OSUnfairLock() | |
private var value: Root | |
public init(wrappedValue: Root) { | |
self.value = wrappedValue | |
} |
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
@available(iOS 3.0, *) | |
public enum Code : Int { | |
public typealias _ErrorType = SKError | |
case unknown = 0 | |
case clientInvalid = 1 // client is not allowed to issue the request, etc. | |
case paymentCancelled = 2 // user cancelled the request, etc. |
NewerOlder