Skip to content

Instantly share code, notes, and snippets.

View GJNilsen's full-sized avatar

GJ Zwart GJNilsen

View GitHub Profile
@GJNilsen
GJNilsen / FlatButton.swift
Last active May 14, 2023 15:24
Subclass of NSButton
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) {
super.draw(dirtyRect)
@GJNilsen
GJNilsen / regex.txt
Last active February 27, 2016 14:47
Regex Collection
Norwegian Address Format
/([^,]+),\s*(\d{4})\s*([^,]+)(?:,\s*([^,]+))?/u
Street Name xx, zip City, Country
// PHP usage
preg_match("/([^,]+),\\s*(\\d{4})\\s*([^,]+)(?:,\\s*([^,]+))?/u", $location, $matches);
if ($matches) {
// MARK: NSFetchedResultsControllerDelegate
func controllerWillChangeContent(controller: NSFetchedResultsController) {
self.tableView.beginUpdates()
}
func controller(controller: NSFetchedResultsController,
didChangeObject anObject: AnyObject,
atIndexPath indexPath: NSIndexPath?,
forChangeType type: NSFetchedResultsChangeType,