Skip to content

Instantly share code, notes, and snippets.

View Koze's full-sized avatar
:octocat:
Refactoring

Koze Koze

:octocat:
Refactoring
View GitHub Profile
@Koze
Koze / speechVoices.tsv
Last active March 27, 2024 11:48
List of AVSpeechSynthesisVoice.speechVoices() on iOS Device
Language Name Quality Identifier Class
ar-SA Maged Default com.apple.ttsbundle.Maged-compact AVSpeechSynthesisVoice
cs-CZ Zuzana Default com.apple.ttsbundle.Zuzana-compact AVSpeechSynthesisVoice
da-DK Sara Default com.apple.ttsbundle.Sara-compact AVSpeechSynthesisVoice
de-DE Anna Default com.apple.ttsbundle.Anna-compact AVSpeechSynthesisVoice
de-DE Helena Default com.apple.ttsbundle.siri_female_de-DE_compact AVSpeechSynthesisVoice
de-DE Martin Default com.apple.ttsbundle.siri_male_de-DE_compact AVSpeechSynthesisVoice
el-GR Melina Default com.apple.ttsbundle.Melina-compact AVSpeechSynthesisVoice
en-AU Catherine Default com.apple.ttsbundle.siri_female_en-AU_compact AVSpeechSynthesisVoice
en-AU Gordon Default com.apple.ttsbundle.siri_male_en-AU_compact AVSpeechSynthesisVoice
@Koze
Koze / 1-RunApplication.scpt
Last active December 9, 2023 20:07
Launch application, Quit application with AppleScript
# launch application
tell application "TextEdit" to run
@Koze
Koze / Basic.dvtcolortheme.plist
Created April 15, 2015 11:00
~/Library/Developer/Xcode/UserData/FontAndColorThemes/Basic.dvtcolortheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
@Koze
Koze / PhotosScreenshot.m
Last active November 30, 2022 22:12
Getting All Screenshots with Photos.framework
NSMutableArray *mArray = [NSMutableArray array];
// fetch all image assets
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"mediaType == %d", PHAssetMediaTypeImage];
PHFetchResult *result = [PHAsset fetchAssetsWithOptions:fetchOptions];
[result enumerateObjectsUsingBlock:^(PHAsset * __nonnull asset, NSUInteger idx, BOOL * __nonnull stop) {
// filter with subtype for screenshot
if (asset.mediaSubtypes & PHAssetMediaSubtypePhotoScreenshot) {
[mArray addObject:asset];
@Koze
Koze / CloseAllWindows.scpt
Last active November 1, 2022 17:11
Close all windows with AppleScript
tell application "Finder" to close windows
@Koze
Koze / URLSession.swift
Last active September 17, 2022 08:15
URLSession diff between Xcode 13.4.1 and 14.0
import CoreFoundation
/* NSURLSession.h
Copyright (c) 2013-2019, Apple Inc. All rights reserved.
*/
/*
NSURLSession is a replacement API for NSURLConnection. It provides
options that affect the policy of, and various aspects of the
@Koze
Koze / PrintMethodPropertyIvar.m
Created April 4, 2015 15:46
Print Method List, Property List, and Ivar List
#import <objc/runtime.h>
void PrintMethodList(Class cls) {
printf("// Method List of %s\n", class_getName(cls));
unsigned int outCount;
Method *methodList = class_copyMethodList(cls, &outCount);
for (unsigned int i=0; i<outCount; i++) {
Method m = methodList[i];
SEL sel = method_getName(m);
printf("%s\n", sel_getName(sel));
@Koze
Koze / WebViewGetUserAgent1.m
Last active May 23, 2022 09:49
Getting the user agent
// UIWebView
{
UIWebView *webView = [[UIWebView alloc] init];
[webView loadHTMLString:@"<html></html>" baseURL:nil];
NSString *appName = [webView stringByEvaluatingJavaScriptFromString:@"navigator.appName"];
NSLog(@"%@", appName);
// Netscape
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
@Koze
Koze / CKRecord+DynamicMemberLookup.swift
Created March 15, 2020 12:05
Type-safe CKRecord with dynamicMemberLookup
extension CKRecord {
subscript<Root, Value: CKRecordValueProtocol>(dynamicMember keyPath: WritableKeyPath<Root, Value>) -> Value? {
get {
let key = NSExpression(forKeyPath: keyPath).keyPath
return self[key]
}
set {
let key = NSExpression(forKeyPath: keyPath).keyPath
// Fatal error: Could not extract a String from KeyPath Swift.ReferenceWritableKeyPath
self[key] = newValue
@Koze
Koze / TableViewCell.swift
Last active July 27, 2021 13:46
Adding SwiftUI preview implementation to existing view class
//
// TableViewCell.swift
// iOS12App
//
// Created by Kazuma Koze on 2020/03/05.
// Copyright © 2020 Climb App. All rights reserved.
//
import UIKit
import SwiftUI