Skip to content

Instantly share code, notes, and snippets.

View diegoventura's full-sized avatar

Diego Ventura diegoventura

View GitHub Profile
import SwiftUI
struct DialogButton {
enum ButtonType {
case destructive
case cancel
case `default`
}
let title: String
// Swift's untyped errors are a goddam PiTA. Here's the pattern I use to try to work around this.
// The goal is basically to try to guarantee that every throwing function in the app throws an
// ApplicationError instead of some unknown error type. We can't actually enforce this statically
// But by following this convention we can simplify error handling
enum ApplicationError: Error, CustomStringConvertible {
// These are application-specific errors that may need special treatment
case specificError1
case specificError2(SomeType)

macOS 10.12 Sierra Setup

Custom recipe to get macOS 10.12 Sierra running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.11 El Capitan setup recipe and 10.10 Yosemite setup recipe. I am currently tweaking this for 10.12 Sierra and expect to refine this gist over the next few weeks.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. I generally reinstall each computer from scratch every 6 months, and I do not perform upgrades between releases.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your o

@diegoventura
diegoventura / UIView+Extensions.swift
Last active November 11, 2023 10:35
Extension to add borders to a UIView with Auto Layout
public extension UIView {
func addBorder(to edges: UIRectEdge, color: UIColor = UIColor.white, thickness: CGFloat = 1) {
var borders = [UIView]()
func border() -> UIView {
let border = UIView(frame: CGRect.zero)
border.backgroundColor = color
border.translatesAutoresizingMaskIntoConstraints = false