Skip to content

Instantly share code, notes, and snippets.

View regnerjr's full-sized avatar

John Regner regnerjr

View GitHub Profile
@regnerjr
regnerjr / DaysOfSwiftUI.md
Last active September 24, 2019 20:15
100 Days of Swift UI Notes

100 Days of Swift UI my notes and tracking my progress

  • Day 1
    • Oh yeah you can use _ as a number separator in Int's
    • Some easy getting started stuff about var vs. let Double Int Bool String and multi line string declarations
    • You can use mulit line string even when you dont want mulit line output by escaping the newlines.
  • Day 2
    • Tuples are fixed in size and fixed in type once you create them let tup = ("one", 1) will always be of type (String, Int) you can not change the type of either of the items or add more to the beginning or end.
  • Syntax for adding a default when doing a dictionary lookup let value = mydict["key", default: 3] wonder why this syntax exists? How is it different from let value = mydict["missing_key"] ?? 3
@regnerjr
regnerjr / main.swift
Created January 7, 2019 18:05
For decoupled unit tests
import UIKit
private func delegateClassName() -> String? {
guard NSClassFromString("TestBundleName.TestingAppDelegate") == nil else {
// when running fast tests, use a nil AppDelegate
return nil
}
return NSStringFromClass(AppDelegate.self)
}
@regnerjr
regnerjr / UIView+Extensions.swift
Created January 2, 2019 21:24
Exercise Ambiguous Views in Swift
+#if DEBUG
+extension UIView {
+ @available(*, deprecated, message: "This warning is here so you don't ship this code")
+ @objc func exerciseAmbiguityInLayoutRepeatedly() {
+ if self.hasAmbiguousLayout {
+ Timer.scheduledTimer(timeInterval: 0.5,
+ target: self,
+ selector: #selector(UIView.exerciseAmbiguityInLayout),
+ userInfo: nil,
+ repeats: true)
@regnerjr
regnerjr / WorkMorningChecklist.md
Last active April 2, 2019 23:18
The check list I use to reduce stress and get my self started on the important things.
  • Email Inbox
  • Personal Calendar
  • Work Calendar
  • Slack
  • Github PR's waiting for my review
  • Github PR's I have awaiting Review
  • Other github messages and checkup
  • Currently open Safari Tabs.
  • Omnifocus Review Tab
  • Work through Omnifocus Inbox
@regnerjr
regnerjr / swfit_test.sh
Created January 7, 2018 23:04
Swift test output is ugly, so pipe it through xcpretty.
swift test 2>&1 | xcpretty -t
# Thanks to Keith Smiley
# https://twitter.com/SmileyKeith/status/949865525374418944
@regnerjr
regnerjr / LoadingVC
Created December 6, 2017 20:40
A little view controller that shows a loading indicator. (great for using as a placeholder VC while your parent does a network request)
class LoadingVC: UIViewController {
lazy var loadingIndicator: UIActivityIndicatorView = {
let loading = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
return loading
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
@regnerjr
regnerjr / JiggleViews.swift
Created December 6, 2017 18:45
A UIView Extension to help debug auto layout issues
extension UIView {
func exerciseAmbiguityInLayoutRepeatedly(_ recursive: Bool) {
#if DEBUG
if hasAmbiguousLayout {
Timer.scheduledTimer(timeInterval: 0.5,
target: self,
selector: #selector(exerciseAmbiguityInLayout),
userInfo: nil,
repeats: true)
}
@regnerjr
regnerjr / swiftFunctionCurry.swift
Created September 28, 2017 23:50
Simple example showing Function Currying in swift
// (Int, Int) -> Int
func add(num1: Int, num2: Int) -> Int {
return num1 + num2
}
// increment just adds to any other number
let curried: (Int) -> ((Int) -> Int) = { num in
return { num2 in
return add(num1: num, num2: num2)
}
import UIKit
class PossibleView: UIView {
let header: UILabel = {
let label = UILabel(frame: .zero)
label.translatesAutoresizingMaskIntoConstraints = false
label.backgroundColor = .brown
label.numberOfLines = 0
@regnerjr
regnerjr / currentErgoDoxLayout.json
Last active November 4, 2016 19:49
My ergodox layout
{
"header": {
"Name": "MDErgo1",
"Layout": "Default",
"Base": "Blank",
"Version": "0.1",
"Author": "HaaTa (Jacob Alexander) 2015",
"KLL": "0.3c",
"Date": "2015-09-12",
"Generator": "KIICONF 0.2"