This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSBlockInit.swift | |
// XjSwiftLab | |
// | |
// Created by Jason Jobe on 3/19/16. | |
// Copyright (c) 2016 Jason Jobe. All rights reserved. | |
// https://gist.github.com/wildthink/48cce4cd2f27695ebb08 | |
// | |
// Thanks to Mike Ash for his expertise and support of the community | |
// https://www.mikeash.com/pyblog/friday-qa-2015-12-25-swifty-targetaction.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Relay.swift | |
// XjSwiftLab | |
// | |
// Created by Jason Jobe on 5/11/15. | |
// Copyright (c) 2015 Jason Jobe. All rights reserved. | |
// https://gist.github.com/wildthink/19d43871964821c4f293 | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-- This is an introduction to Transducers in Swift, inspired by | |
// Talk: https://www.youtube.com/watch?v=estNbh2TF3E | |
// Code: https://github.com/mbrandonw/learn-transducers-playground | |
// Updated with Swift 2 | |
/** | |
* Define a few test methods | |
*/ | |
/// REDUCER | |
func append <A> (xs: [A], x: A) -> [A] { return xs + [x] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you want types initializable from String literals | |
// but don't want to implement three separate initializers. | |
extension ExpressibleByUnicodeScalarLiteral where Self: ExpressibleByStringLiteral, Self.StringLiteralType == String { | |
public init(unicodeScalarLiteral value: String) { | |
self.init(stringLiteral: value) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am jason_ at onename.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# By Steve Hanov, 2011. Released to the public domain. | |
# Updated 2014 to use DAWG as a mapping. | |
import sys | |
import time | |
DICTIONARY = "/usr/share/dict/words" | |
QUERY = sys.argv[1:] | |
# This class represents a node in the directed acyclic word graph (DAWG). It |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Domain.swift | |
// Inspired by Eve | |
// | |
// Created by Jason Jobe on 11/26/16. | |
// Copyright © 2016 Jason Jobe. All rights reserved. | |
// https://gist.github.com/wildthink/b911a5b8e0d7dc6ef190fd8fe4f7a2ee | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension String { | |
/** | |
Returns a country flag from an **uppercased** ISO Alpha-2 country code String | |
Example usage: "US".flag | |
@return A flag emoji. Example: 🇺🇸 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat ScaleToAspectFitRectInRect(CGRect rfit, CGRect rtarget) | |
{ | |
// first try to match width | |
CGFloat s = CGRectGetWidth(rtarget) / CGRectGetWidth(rfit); | |
// if we scale the height to make the widths equal, does it still fit? | |
if (CGRectGetHeight(rfit) * s <= CGRectGetHeight(rtarget)) { | |
return s; | |
} | |
// no, match height instead | |
return CGRectGetHeight(rtarget) / CGRectGetHeight(rfit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSViewController { | |
var document: AnyObject? { | |
if let target = self.parent, target.responds (to: #selector(getter: self.document)) { | |
return target.perform(#selector(getter: self.document)) as AnyObject? | |
} | |
return self.view.window?.windowController?.document | |
} | |
var managedObjectContext: NSManagedObjectContext? { |
OlderNewer