Skip to content

Instantly share code, notes, and snippets.

View niw's full-sized avatar
🐱
Meow

Yoshimasa Niwa niw

🐱
Meow
  • San Francisco, CA
  • X @niw
View GitHub Profile
@niw
niw / LICENSE
Last active May 14, 2023 15:35
macOS Big Sur Icon Template for Affinity Photo
macOS Big Sur Icon Template for Affinity Photo (c) by Yoshimasa Niwa
macOS Big Sur Icon Template for Affinity Photo is licensed under a
Creative Commons Attribution 4.0 International License.
You should have received a copy of the license along with this
work. If not, see <http://creativecommons.org/licenses/by/4.0/>.
@niw
niw / swift_corelibs_foundation_windows_build-ja.md
Last active August 28, 2020 09:25
Swift の swift-corelibs-foundation を Windows で手軽にビルドするためのメモ

Swift の swift-corelibs-foundation を Windows で手軽にビルドするためのメモ

ここ に移動しました。

@niw
niw / UITextView_and_accessibility.md
Last active June 28, 2020 06:51
UITextView accessibility is unique

UITextView and Accessibility

isAccessibilityElement

isAccessibilityElement は Voice Over などが稼働して、UIKit.axbundleが読み込まれて始めて true になる。

  • See also:
    • -[UITextViewAccessibility isAccessibilityElement] (UIKit.axbundle)

isEditable

@niw
niw / README.md
Last active June 21, 2020 15:02
Text View の内容を変更したりすると Undo でクラッシュしたりする原因はこれ

特定のタイミングで setText: すると Undo がおかしくなる、場合によってはクラッシュする問題

  • setText: などの変更は、Text Storage の NSTextStorageDidProcessEditingNotification によって、undoManagergroupingLevel0 の時だけ removeAllActions を呼ぶ。
  • groupingLevel はキーボードから入力があった時は RunLoop が終わらないと 0 にならない。
  • キーボードから入力したときには、coalesceInTextView:affectedRange:replacementRange:replacementText: で、 まず最初に undoManager に Text Storage を target_UITextUndoOperationTypingobject にした Undo が登録される。
  • 次回の入力以降、coalesceInTextView:affectedRange:replacementRange:replacementText: では、 NSUndoManager_shouldCoalesceTypingForText:: (これは::二回で正しい、2つめの引数は名前がない。) を呼んで、 前回の_UITextUndoOperationTyping に変更を追記する方法で入力の Undo を結合するか、新しい Undo を登録するか決めている。 改行の直後などでは新しい Undo が追加される。
@niw
niw / why_RTIDocumentState_crashes_the_app.md
Last active May 25, 2020 21:24
Describes why `RTIDocumentState` crashes your app.

RTIDocumentState and related method calls can crash app. Why?

Short version

A pointer to RTIDocumentState is read and written on multi threads.

Long version

When the application launches, it establishes XPC connection with so called RTIInputSystemService and creates a RTIInputSystemServiceSession.

@niw
niw / TextView.swift
Last active May 23, 2020 05:07
`textInputMode` is not working on iOS 13.0 to iOS 13.3.
final class TextView: UITextView {
private var preferredTextInputModePrimaryLanguage: String?
/**
Use given primary language for the preferred text input mode when next time text view becomes first responder.
- Parameters:
- primaryLanguage: `String` represents a primary language for the preferred text input mode. Use `"emoji"` to use Emoji keyboard.
*/
func usePreferredTextInputModePrimaryLanguage(_ primaryLanguage: String) {
preferredTextInputModePrimaryLanguage = primaryLanguage
@niw
niw / netlify_cli_knoen_issues.md
Last active May 18, 2020 05:34
`netlify-cli` knwon issues

netlify-cli known issues

A memo about netlify-cli. Too lazy to file issues or create pull requests for now.

Headers

Looks like it has no ability to read headers in netlify.toml

@niw
niw / a.c
Last active April 28, 2020 11:41
Demonstrate how iCloud Drive is surprisingly unreliable.
#include <stdio.h>
#include <time.h>
#include <unistd.h>
/*
This super simple C code demonstrates how iCloud Drive is unreliable.
Obviously, this code is creating a temporary file first, then creating a backup then rename it to original one.
This is actually used in [OBS Studio](https://obsproject.com/) settings file writing.
Build this command with `clang`,
extension Optional: CVarArg {
}
extension OSLog {
static let meow = OSLog(subsystem: "cat", category: "meow")
@inlinable
static func log(type: OSLogType, log: OSLog, _ message: StaticString) {
os_log(message, log: log, type: type)
import Foundation
let JSONString = """
{
"AAPL": {
"quote": {
"cat": "meow",
"isMarketOpen": true
},
"latestPrice": [