I hereby claim:
- I am leptos-null on github.
- I am leptos_null (https://keybase.io/leptos_null) on keybase.
- I have a public key ASA0dcmIggGRcMrdxDzFRDAutr7TdLveEOWsHbCkWeWN0Qo
To claim this, I am signing this object:
struct GenericError: Error, CustomStringConvertible, CustomDebugStringConvertible, Equatable, Codable { | |
let description: String | |
let file: String | |
let function: String | |
let line: Int | |
init(message m: String, file f: String = #file, function n: String = #function, line l: Int = #line) { | |
description = m; file = f; function = n; line = l | |
} | |
#import <Foundation/Foundation.h> | |
#import <mach-o/loader.h> | |
#if __has_include(<Kernel/kern/cs_blobs.h>) | |
# import <Kernel/kern/cs_blobs.h> | |
#else | |
/* some Darwin distributions don't provide the cs_blobs header | |
* copy it from the macOS SDK if available, otherwise one of | |
* https://opensource.apple.com/source/xnu/xnu-4903.221.2/osfmk/kern/cs_blobs.h.auto.html | |
* https://github.com/apple/darwin-xnu/blob/a449c6a3b8014d9406c2ddbdc81795da24aa7443/osfmk/kern/cs_blobs.h |
@implementation UIImage (UIImageUnicode) | |
+ (UIImage *)imageFromUnicodePoint:(unichar)codepoint compatibleWithTraitCollection:(UITraitCollection *)traitCollection API_AVAILABLE(ios(10.0)) { | |
NSString *str = [NSString stringWithCharacters:&codepoint length:1]; | |
UIFont *weightRef = [UIFont preferredFontForTextStyle:UIFontTextStyleBody compatibleWithTraitCollection:traitCollection]; | |
UIFont *sizeRef = [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2 compatibleWithTraitCollection:traitCollection]; | |
NSAttributedString *drawReady = [[NSAttributedString alloc] initWithString:str attributes:@{ | |
NSFontAttributeName : [weightRef fontWithSize:sizeRef.pointSize] | |
}]; | |
UIGraphicsBeginImageContextWithOptions([drawReady size], NO, 0); |
@import Foundation; | |
@import MobileCoreServices; | |
API_AVAILABLE(ios(5.0)) | |
@interface LSApplicationWorkspace : NSObject | |
+ (instancetype)defaultWorkspace; | |
- (BOOL)openApplicationWithBundleID:(NSString *)bundleID API_AVAILABLE(ios(7.0)); | |
@end |
@import Foundation; | |
int main(int argc, const char *argv[]) { | |
const char *const arg = argv[1]; | |
if (arg) { | |
if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0 || argc > 2) { | |
printf("Usage: %s [PATH]\n" | |
"Walk through PATH and find any repeated file names. " | |
"A different PATH can be provided by passing it in as the first argument.\n", argv[0]); | |
return 1; |
static NSDate *watchPreviewDate() { | |
static NSDateComponents *comps; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
comps = [NSDateComponents new]; | |
comps.calendar = NSCalendar.autoupdatingCurrentCalendar; | |
comps.timeZone = NSTimeZone.localTimeZone; | |
comps.year = 2014; | |
comps.month = 9; | |
comps.day = 9; |
I hereby claim:
To claim this, I am signing this object:
import SwiftUI | |
extension ForEach { | |
init<Base: Sequence>(enumerated base: Base, @ViewBuilder content: @escaping (Data.Element) -> Content) where Data == Array<EnumeratedSequence<Base>.Element>, ID == Base.Element, Content: View, ID: Identifiable { | |
self.init(Array(base.enumerated()), id: \.element, content: content) | |
} | |
init<Base: Sequence>(enumerated base: Base, id: KeyPath<Base.Element, ID>, @ViewBuilder content: @escaping (Data.Element) -> Content) where Data == Array<EnumeratedSequence<Base>.Element>, Content: View { | |
let basePath: KeyPath<EnumeratedSequence<Base>.Element, Base.Element> = \.element | |
self.init(Array(base.enumerated()), id: basePath.appending(path: id), content: content) | |
} |
import Foundation | |
func redirectStdout(to path: String) throws { | |
let (openResult, posixErrorCode) = path.withCString { | |
// idea thanks to https://github.com/leptos-null/ClassDumpRuntime/blob/31e3601/classdumpctl/main.m#L456-L459 | |
// error checking thanks to https://github.com/leptos-null/Forest/blob/ba4b89a/Shared/Tar.swift#L172-L174 | |
let result = open($0, O_WRONLY | O_CREAT | O_TRUNC, 0o644) | |
let globalError = errno // copy errno since it may change before we access it again later | |
return (result, globalError) | |
} |