Skip to content

Instantly share code, notes, and snippets.

public extension NSLayoutConstraint.Priority {
public static func -(lhs: NSLayoutConstraint.Priority, rhs: Float) -> NSLayoutConstraint.Priority {
return NSLayoutConstraint.Priority(lhs.rawValue - rhs)
}
public static func +(lhs: NSLayoutConstraint.Priority, rhs: Float) -> NSLayoutConstraint.Priority {
return NSLayoutConstraint.Priority(lhs.rawValue + rhs)
}
}
@bjhomer
bjhomer / .gitconfig
Created April 27, 2018 20:19
git delete-merged
[alias]
delete-merged = !bash -c '\
REMOTE=$1 && \
REMOTE=${REMOTE:="origin"} && \
echo "Fetching $REMOTE" && \
git fetch $REMOTE --prune && \
git branch -vv | grep "gone]" | awk \"{ print \\$1 }\" | xargs git branch -d' -
# usage: `git delete-merged`
@bjhomer
bjhomer / enumFilter.swift
Created January 15, 2019 16:42
Is there a better way to do this?
enum Thing {
case empty
case int(Int)
}
let things: [Thing] = [.empty, .int(3), .int(7)]
// Surely there's a more concise way to write this `filter` closure?
let intThings = things.filter({
if case Thing.int = $0 { return true }
@bjhomer
bjhomer / cross-view-lines.swift
Last active November 5, 2022 05:31
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI