Skip to content

Instantly share code, notes, and snippets.

View Pash237's full-sized avatar

Pavel Alexeev Pash237

View GitHub Profile
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active May 2, 2024 13:56
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@jfuellert
jfuellert / ScrollableView.swift
Last active April 11, 2024 17:57
A scrollable SwiftUI view, UIScrollView wrapper. ScrollableView lets you read and write content offsets for scrollview in SwiftUI, with and without animations.
import SwiftUI
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable {
// MARK: - Coordinator
final class Coordinator: NSObject, UIScrollViewDelegate {
// MARK: - Properties
private let scrollView: UIScrollView
var offset: Binding<CGPoint>
@hotpaw2
hotpaw2 / RecordAudio.swift
Last active April 3, 2024 03:10
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright © 2017,2019 HotPaw Productions. All rights reserved.
@zacwest
zacwest / ios-font-sizes.swift
Last active March 27, 2024 07:16
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@yageek
yageek / Simplify.swift
Created June 14, 2018 12:40 — forked from lachlanhurst/Simplify.swift
Simplification of a 3D polyline using the Ramer–Douglas–Peucker algorithm in Swift
//
// Simplify.swift
//
// Simplification of a 3D-polyline.
// A port of https://github.com/hgoebl/simplify-java for Swift
//
//
// The MIT License (MIT)
//
// Created by Lachlan Hurst on 10/02/2015.
@Amzd
Amzd / Binding+didSet.swift
Last active September 20, 2023 05:27
SwiftUI Binding wrappers for willSet and didSet
extension Binding {
/// Wrapper to listen to didSet of Binding
func didSet(_ didSet: @escaping ((newValue: Value, oldValue: Value)) -> Void) -> Binding<Value> {
return .init(get: { self.wrappedValue }, set: { newValue in
let oldValue = self.wrappedValue
self.wrappedValue = newValue
didSet((newValue, oldValue))
})
}
@Amzd
Amzd / PreferenceUIHostingController.swift
Last active September 8, 2023 12:14
PreferenceUIHostingController. Adds hiding home indicator and deferring system edge gestures to SwiftUI. (Don't work at the same time but I think that's normal?)
extension View {
/// Controls the application's preferred home indicator auto-hiding when this view is shown.
func prefersHomeIndicatorAutoHidden(_ value: Bool) -> some View {
preference(key: PreferenceUIHostingController.PrefersHomeIndicatorAutoHiddenPreferenceKey.self, value: value)
}
/// Controls the application's preferred screen edges deferring system gestures when this view is shown. Default is UIRectEdgeNone.
func edgesDeferringSystemGestures(_ edge: UIRectEdge) -> some View {
preference(key: PreferenceUIHostingController.PreferredScreenEdgesDeferringSystemGesturesPreferenceKey.self, value: edge)
}
@dive
dive / xed_xcode_invocation_tool.md
Last active July 27, 2023 15:23
Xcode invocation tool - xed

Xcode invocation tool - xed

xed is a command-line tool that launches the Xcode application and opens the given documents (xcodeproj, xcworkspace, etc.), or opens a new document, optionally with the contents of standard input.

If you work from the command line, this tool is a better option than open (which can open Xcode projects as well). Why?

  • xed knows about the current selected Xcode version (open behaves unpredictably if you have multiple Xcode installed)
  • You can use it open all files from a specific commit (with a little help explained below). It is useful on code-reviews or when you want to explore significant changes in the repository
  • You can use it as a "quick open" helper. Helps with monorepo phenomena, when you have hundreds of projects in the repository (I will show you an example below)
@MTuner
MTuner / fix-sublimetext-subpixel.txt
Last active March 31, 2023 21:44
Fixing font rendering/aliasing in Sublime Text in MacOS Mojave
Apple removed colored sub-pixel antialiasing in MacOS Mojave
(https://developer.apple.com/videos/play/wwdc2018/209/ starting from ~28min)
To make fonts look normal in Sublime Text, add to Preferences:
// For the editor
"font_options": [ "gray_antialias" ],
// For the sidebar / other elements
"theme_font_options": [ "gray_antialias" ],
@janselv
janselv / UIBezierPathLength.swift
Last active March 8, 2023 08:20
Get total iOS CGPath length as an extension of UIBezierPath written in swift
// The MIT License (MIT)
//
// Copyright (c) 2016 Jansel Valentin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: