Skip to content

Instantly share code, notes, and snippets.

GJNilsen / FlatButton.swift
Last active Apr 11, 2020
Subclass of NSButton
View FlatButton.swift
import AppKit
public class FlatButton: NSButton {
public var buttonColor: NSColor = NSColor(calibratedRed: 0.201, green: 0.404, blue: 0.192, alpha: 1)
public var onClickColor: NSColor = NSColor(calibratedRed: 0.304, green: 0.601, blue: 0.294, alpha: 1)
public var textColor: NSColor = NSColor.white
public override func draw(_ dirtyRect: NSRect) {
View regex.txt
Regex Collection
Norwegian Address Format
Street Name xx, zip City, Country
// PHP usage
preg_match("/([^,]+),\\s*(\\d{4})\\s*([^,]+)(?:,\\s*([^,]+))?/u", $location, $matches);
if ($matches) {
View NSFetchedResultsControllerDelegate_Boilerplate.swift
// MARK: NSFetchedResultsControllerDelegate
func controllerWillChangeContent(controller: NSFetchedResultsController) {
func controller(controller: NSFetchedResultsController,
didChangeObject anObject: AnyObject,
atIndexPath indexPath: NSIndexPath?,
forChangeType type: NSFetchedResultsChangeType,