Skip to content

Instantly share code, notes, and snippets.

View faimin's full-sized avatar
👻
learning

Zero.D.Saber faimin

👻
learning
View GitHub Profile
//
// DarwinNotificationCenter.swift
//
// Created by Nonstrict on 2023-12-07.
//
import Foundation
import Combine
private let center = CFNotificationCenterGetDarwinNotifyCenter()
@MarcoEidinger
MarcoEidinger / findRequiredReasonAPIUsage.sh
Created August 21, 2023 19:55
A shell script to find if any "required reason API" are used in Swift or Objective-C files within that folder or subfolders
#!/bin/bash
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
searchTerms=(
# File timestamp APIs
"creationDate"
"modificationDate"
"fileModificationDate"
"contentModificationDateKey"
"creationDateKey"
@sh3l6orrr
sh3l6orrr / TCA_zh.md
Last active March 27, 2025 13:59
TCA

The Composable Architecture (可组装架构)

The Composable Architecture (简写为TCA) 让你用统一、便于理解的方式来搭建应用程序,它兼顾了组装,测试,以及功效。你可以在 SwiftUI,UIKit,以及其他框架,和任何苹果的平台(iOS、macOS、tvOS、和 watchOS)上使用 TCA。

@davidteren
davidteren / nerd_fonts.md
Last active April 27, 2025 13:47
Install Nerd Fonts via Homebrew [updated & fixed]
@yxztj
yxztj / TaskConcurrencyManifesto.md
Last active January 4, 2025 14:32 — forked from lattner/TaskConcurrencyManifesto.md
Swift Concurrency Manifesto 中文翻译
local function Chinese()
-- 简体拼音
hs.keycodes.currentSourceID("com.apple.inputmethod.SCIM.ITABC")
end
local function English()
-- ABC
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
end
@tayloraswift
tayloraswift / vectormanifesto.md
Last active June 28, 2020 01:54
the vector manifesto

Vector manifesto

Vectors, understood as 2, 3, or 4-component numerical aggregates, are a fundamental currency type across many domains of programming. This document seeks to lay out a cohesive vision for adding standard vector support to the Swift language, with consideration for relevant long-term goals for the language type system.

Past discussions: 1 2, 3, 4, 5

Past pitches: 1

Vectors and fixed-size arrays

// Note that this checker is always running, even when the app is in the background (where it doesn't matter if the main thread is blocked)
// You'll have to add more code if you don't want the checker to run while the app is in the background
final class ANRChecker {
private let ANRThreshold: CFTimeInterval = 5
// This variable may be accessed from multiple threads at the same time. It won't cause issues, but if you want prevent the thread sanitizer from complaining, you can add locking around it or w/e
private lazy var lastResponseTime: CFTimeInterval = CACurrentMediaTime()
func beginChecking() {
updateLastResponseTime()
#import "fishhook.h" // from https://github.com/facebook/fishhook
// Replace write and writev, the two "chokepoint" functions that writes to stderr and stdout will probably pass through
static int (*originalWritev)(int fd, const struct iovec *v, int n);
static int (*originalWrite)(int fd, const void *buf, size_t size);
void checkForBadConstraintsMessage(int fd, const char *string, size_t size) {
if (strnstr(string, "UIViewAlertForUnsatisfiableConstraints", size)) {
// Write it to the console anyways before crashing
originalWrite(fd, string, size);
@Skifary
Skifary / main.m
Last active October 22, 2020 13:50
修改block的实现,先打印参数,再输出原有实现
#import <Foundation/Foundation.h>
#import "ffi.h"
NSMutableArray *g_allocations;
ffi_cif g_cif;
ffi_closure *g_closure;
void *g_replacement_invoke;
void *g_origin_invoke;