Skip to content

Instantly share code, notes, and snippets.

@rnystrom
rnystrom / example.swift
Created January 18, 2021 00:30
Show the keyboard as a UISearchController in a modal is displayed
View example.swift
class ViewController: UIViewController {
@IBAction func onSearch(_ sender: Any) {
let fakeWindow = UIWindow(windowScene: view.window!.windowScene!)
let fakeTextField = UITextField()
fakeTextField.autocorrectionType = .no
fakeWindow.addSubview(fakeTextField)
fakeWindow.makeKeyAndVisible()
fakeTextField.becomeFirstResponder()
@rnystrom
rnystrom / purge.md
Last active August 13, 2020 13:26
Purge inactive testflight users with fastlane
View purge.md

Purging inactive users from TestFlight

Pretty hacky flow, but this will remove anyone that was invited but not accepted their TestFlight invitation.

Start the Ruby REPL

$ irb
View gist:9cbde71736425b4f88af7dbf0fdac785
Date/Time: 2019-09-06 20:24:09.836 -0400
OS Version: Mac OS X 10.14.6 (18G95)
Report Version: 12
Bridge OS Version: 3.6 (16P6571)
Anonymous UUID: 2F39EFFF-A558-172D-A389-1B5A4D92497B
Sleep/Wake UUID: 2C691F51-7554-49E4-9814-D24C14443882
Time Awake Since Boot: 320000 seconds
Time Since Wake: 1200 seconds
@rnystrom
rnystrom / Cell.swift
Last active June 9, 2019 17:36
Self-sizing UITableViewCell with an h-scrolling UITextView
View Cell.swift
class Cell: UITableViewCell {
let textView = UITextView()
let scrollView = UIScrollView()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.alwaysBounceHorizontal = true
scrollView.scrollsToTop = false
@rnystrom
rnystrom / ViewController.swift
Created May 29, 2018 01:16
Interactive NSAttributedString link highlighting with TextKit
View ViewController.swift
import UIKit
public extension CGSize {
func snapped(scale: CGFloat) -> CGSize {
var size = self
size.width = ceil(size.width * scale) / scale
size.height = ceil(size.height * scale) / scale
return size
}
View gist:93bcd2da6b0ad113f840fd0cc312c0b9
$ bash -l -c "$(curl -sfL https://raw.githubusercontent.com/bitrise-tools/codesigndoc/master/_scripts/install_wrap-xcode.sh)" 18-05-04 12:54:54
=> Creating a temporary directory for codesigndoc ...
=> Downloading version: 2.1.0
=> Downloading codesigndoc from (https://github.com/bitrise-tools/codesigndoc/releases/download/2.1.0/codesigndoc-Darwin-x86_64) to (/var/folders/cp/3k3452xn2w9223mgpchm2059krf8ch/T/codesigndocXXXXXX.REa5smBc/codesigndoc) ...
######################################################################## 100.0%
=> Making it executable ...
=> codesigndoc version: 2.1.0
=> Running codesigndoc scan ...
View ListSwiftExample.swift
// ListSwiftAdapterDataSource.swift
public class Value {
public let value: ListSwiftDiffable
public let constructor: () -> ListSectionController
public init<T>(value: T, constructor: @escaping () -> ListSwiftSectionController<T>) {
self.value = value
self.constructor = constructor
}
View gist:88d1a3284be5950190a4d2913d9a83fb
FAILED=false
if [ -z "${BUDDYBUILD_BUILD_NUMBER}" ]; then
echo "Script is not being run on CI"
exit 0
fi
if [ -z "${GITHUB_CLIENT_ID}" ]; then
echo "${SRCROOT}/Classes/Systems/Secrets.swift:14:1: warning: Missing GitHub Client ID"
FAILED=true
View StyledText-Scratchpad.swift
import UIKit
extension UIContentSizeCategory {
var multiplier: CGFloat {
switch self {
case .accessibilityExtraExtraExtraLarge: return 23 / 16
case .accessibilityExtraExtraLarge: return 22 / 16
case .accessibilityExtraLarge: return 21 / 16
case .accessibilityLarge: return 20 / 16
View KeyboardTransition.swift
//
// KeyboardTransition.swift
// ViewControllerKeyboardAnimated
//
// Created by Ryan Nystrom on 11/7/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit