Skip to content

Instantly share code, notes, and snippets.

@onmyway133
onmyway133 / arm64-apple-ios.swiftinterface
Created June 9, 2022 18:46
arm64-apple-ios16.swiftinterface
This file has been truncated, but you can view the full file.
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.7 (swiftlang-5.7.0.113.10 clang-1400.0.16.2)
// swift-module-flags: -target arm64-apple-ios16.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Osize -library-level api -library-level api -module-name SwiftUI
// swift-module-flags-ignorable: -user-module-version 4.0.66.3.102
import Accessibility
import Combine
import CoreData
import CoreFoundation
@_exported import CoreGraphics
@_exported import CoreTransferable
@simonbs
simonbs / UserDefault.swift
Last active March 3, 2024 11:38
Property wrapper that stores values in UserDefaults and works with SwiftUI and Combine.
/**
* I needed a property wrapper that fulfilled the following four requirements:
*
* 1. Values are stored in UserDefaults.
* 2. Properties using the property wrapper can be used with SwiftUI.
* 3. The property wrapper exposes a Publisher to be used with Combine.
* 4. The publisher is only called when the value is updated and not
* when_any_ value stored in UserDefaults is updated.
*
* First I tried using SwiftUI's builtin @AppStorage property wrapper
import SwiftUI
import Combine
public struct ChangeObserver<V: Equatable>: ViewModifier {
public init(newValue: V, action: @escaping (V) -> Void) {
self.newValue = newValue
self.newAction = action
}
private typealias Action = (V) -> Void
// Original article here: https://www.fivestars.blog/code/redacted-custom-effects.html
import SwiftUI
// MARK: Step 1: Create RedactionReason
public enum RedactionReason {
case placeholder
case confidential
@DreamingInBinary
DreamingInBinary / Best in Class iOS Checklist
Last active January 29, 2024 18:18
This is a public checklist updated every year after the latest version of iOS and iPadOS are shipped. It's a boiled down version of a "Best in Class" app checklist created by Jordan Morgan.
# A Best in Class Checklist
A boiled down checklist adapted from this [post](https://www.swiftjectivec.com/a-best-in-class-app/), created by @jordanmorgan10.
> To use this, create a Github Issue in your own repo, and simply copy and paste this text.
## iOS Core Technology
_Things any iOS app can benefit from_
- [ ] iCloud Sync
- [ ] Focus Filter Support
@douglashill
douglashill / updateSafeAreaForKeyboardFromNotification.swift
Last active June 25, 2023 16:11
Avoid the keyboard by leveraging additionalSafeAreaInsets.
// Avoids the keyboard in a UIKit app by leveraging additionalSafeAreaInsets.
// You can put this in the root view controller so the whole app will avoid the keyboard.
// Only tested on iOS 13.3.
// Made for https://douglashill.co/reading-app/
@objc func updateSafeAreaForKeyboardFromNotification(_ notification: Notification) {
guard let endFrameInScreenCoords = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else {
return
}
// Please consider whether the force unwrap here is safe for your own use case.
@chriseidhof
chriseidhof / sample.swift
Last active May 11, 2024 01:33
View Inspection
import SwiftUI
struct SizeKey: PreferenceKey {
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) {
value = value ?? nextValue()
}
}
struct ContentView: View {
@State var width: CGFloat? = nil
var body: some View {
@powersee
powersee / change-git.sh
Created October 21, 2019 13:05
批量更改 git commit 的 username email
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "要修改的@邮箱地址.com" ]
then
cn="想要改成的用户名"
@fnky
fnky / ANSI.md
Last active May 22, 2024 08:06
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@pavelmalik
pavelmalik / tensorflow_1_7_high_sierra_gpu.md
Last active November 15, 2021 22:45 — forked from mattiasarro/tensorflow_1_6_high_sierra_gpu.md
Install Tensorflow 1.7 on macOS High Sierra 10.13.3 with CUDA and stock python

Tensorflow 1.7 with CUDA on macOS High Sierra 10.13.3 and default python 2.7

Largely based on the Tensorflow 1.6 gist, this should hopefully simplify things a bit. Mixing homebrew python2/python3 with pip ends up being a mess, so here's an approach to uses the built-in python27.

Requirements

  • NVIDIA Web-Drivers 387.10.10.10.25.156 for 10.13.3
  • CUDA-Drivers 387.178
  • CUDA 9.1 Toolkit
  • cuDNN 7.0.5 (latest release for mac os)