Skip to content

Instantly share code, notes, and snippets.

View keitaito's full-sized avatar

Keita Ito keitaito

View GitHub Profile
@inamiy
inamiy / recursive-struct.swift
Created February 9, 2021 06:23
Recursive struct in Swift using Box (indirect struct)
@propertyWrapper
class Box<T> {
var wrappedValue: T
var projectedValue: Box<T> {
Box(wrappedValue)
}
init(_ value: T) {
self.wrappedValue = value
@kiding
kiding / HDRGainMap.swift
Last active April 2, 2024 08:32
Extracting HDR Gain Map from iOS 14.1+ (iPhone 12+) photos
import UIKit
import MobileCoreServices.UTCoreTypes
if #available(iOS 14.1, *) {
let input = Bundle.main.url(forResource: "IMG_0037", withExtension: "HEIC")!
let output = FileManager().temporaryDirectory.appendingPathComponent("IMG_0037.GAIN_MAP.BMP")
let source = CGImageSourceCreateWithURL(input as CFURL, nil)!
// urn:com:apple:photo:2020:aux:hdrgainmap
let dataInfo = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source, 0, kCGImageAuxiliaryDataTypeHDRGainMap)! as Dictionary
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *tokenString;
if (@available(iOS 13.0, *)) {
NSUInteger dataLength = deviceToken.length;
if (dataLength == 0) {
return;
}
const unsigned char *dataBuffer = deviceToken.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
@azu
azu / README.md
Last active March 15, 2024 09:59
スタートアップ/企業の調べ方
@nanoxd
nanoxd / run.sh
Last active June 10, 2019 19:44
[Xcode Diet] Clean up after Xcode's voracious hard drive appetite
#!/usr/bin/env sh
set -e
fancy_echo() {
local fmt="$1"; shift
printf "\n$fmt\n" "$@"
}
@harishgonnabattula
harishgonnabattula / WWDC.json
Created August 25, 2018 20:34
WWDC 2015-2018 Video urls and summary
[
{"url": "https://devstreaming-cdn.apple.com/videos/wwdc/2018/236mwbxbxjfsvns4jan/236/236_hd_avspeechsynthesizer_making_ios_talk.mp4?dl=1", "title": "AVSpeechSynthesizer: Making iOS Talk", "summary": "Speech can enhance the audio experience of your app, whether you are generating spoken feedback for accessibility, or providing critical information beyond simple alerts or notifications. AVSpeechSynthesizer produces synthesized speech from text and allows you to control and monitor the progress of ongoing speech. Learn the ins and outs of AVSpeechSynthesizer and how to add computer-generated speech output to your app."},
{"url": "https://devstreaming-cdn.apple.com/videos/wwdc/2018/405bjty1j94taqv8ii/405/405_hd_measuring_performance_using_logging.mp4?dl=1", "title": "Measuring Performance Using Logging", "summary": "Learn how to use signposts and logging to measure performance. Understand how the Points of Interest instrument can be used to examine logged data. Get an introduction into creating and using custo
@milseman
milseman / Swift5StateOfString.md
Created January 10, 2018 19:49
State of String: ABI, Performance, Ergonomics, and You!

State of String: ABI, Performance, Ergonomics, and You!

Hello, I’ve been working on implementing, optimizing, and improving String in preparation for ABI stability, and I thought I’d share the current status of String in Swift 5 and some potential directions to go. This is the product of conversations with open source contributors and my colleagues on the Swift standard library team at Apple.

The primary area of focus is stabilizing String’s ABI, but we’d be remiss if we couldn’t also fit in performance and ergonomic improvements. String’s ergonomics in particular is one area where we think the status quo is woefully inadequate, and over half of this email is devoted to that topic. At the end, there’s a section about a community initiative that we hope can help users of String as well as guide future development.

(Note: I’m sending this to swift-dev because much of the contents revolve around implementation concerns. I’ll also cross-reference on swift-evolution and swift-users. See also the [StringManife

@inamiy
inamiy / typed-error-poem.md
Last active November 8, 2018 13:58
Swift Poem: Why I prefer typed error (for https://github.com/apple/swift-evolution/pull/757)

Typed error can be useful in certain cases, especially when accompanied with NoError type.

For example, in reactive programming, https://github.com/ReactiveCocoa/ReactiveSwift (typed error) allows us to create UI bindings only if Error is NoError, i.e.:

static func <~ <Source: BindingSource> (provider: Self, source: Source) -> Disposable? 
    where Source.Value == Value, Source.Error == NoError { ... }
    
// example
let alphaSignal: Signal = ...
@shunirr
shunirr / criminal_jc.md
Last active February 26, 2024 05:51
女子中学生チケット詐欺事件

criminal_jc

@0xmachos
0xmachos / Keychain.md
Last active February 19, 2024 06:50
Useful resources for working with iOS/ macOS Keychain API

Keychain API

kSecAttrAccessible Mapping

Protection Domain (pdmn) Keychain Accessibility Values
ck kSecAttrAccessibleAfterFirstUnlock
cku kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
dk kSecAttrAccessibleAlways
akpu kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly