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
-- View an Aperture photo on flickr | |
-- Assumes a custom metadata field in Aperture named "Flickr URL" exists. | |
tell application "Aperture" | |
-- selection always returns image versions | |
set selectedImages to (get selection) | |
if (count of items in selectedImages) > 0 then | |
repeat with i from 1 to count of selectedImages | |
tell library 1 | |
set img to item i of selectedImages |
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
sed `perl -e "print $RANDOM"`"q;d" /usr/share/dict/words | tr -d '\n' | pbcopy |
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
describe "just another afternoon” do | |
jeff = Factory.create(:loser) | |
artie = Cat.new(:name => "Artie", :size => "long", :color => "black”) | |
helpeless_victim = Victim.new(:type => ['Mouse, 'Bird', 'Mole', 'Rat'].sample) | |
artie.catch(helpless_victim) | |
while helpeless_victim.is_alive? | |
artie.torture(victim) | |
sleep 10 |
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
func logPretty(message: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: StaticString = __FUNCTION__) { | |
var pretty = "\((file as NSString).lastPathComponent)(\(line)) : \(function)" | |
if let message = message where !message.isEmpty { | |
pretty += " ☞ \(message)" | |
} | |
print(pretty) | |
} |
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 CLLocation { | |
/// Compass bearing from a known location | |
/// | |
/// Shamelessly stolenfrom // https://stackoverflow.com/questions/26998029/calculating-bearing-between-two-cllocation-points-in-swift | |
/// | |
/// - Parameter location: The `CLocation` to calculate the bearing from. | |
/// - Returns: The `CLLocationDirection` representing the compass bearing. | |
func bearing(from location: CLLocation) -> CLLocationDirection { | |
func degreesToRadians(degrees: CLLocationDirection) -> CLLocationDirection { return degrees * .pi / 180.0 } |
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
/// Provides convenience accesors to some info dictionary keys | |
extension Bundle { | |
var identifier: String? { | |
return string(forInfoDictionaryKey: "CFBundleIdentifier") | |
} | |
var displayName: String? { | |
return string(forInfoDictionaryKey: "CFBundleDisplayName") | |
} | |
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
// | |
// NSPersonNameComponents.swift | |
// | |
import Foundation | |
extension NSPersonNameComponents { | |
// Because the web is generally xenophobic… | |
var xenophobicName: (firstName: String, lastName: String)? { | |
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 String { | |
/// Replace all instances of characters in a character set. | |
/// | |
/// - Parameters: | |
/// - characterSet: The `CharacterSet` containing the characters to replace in the string. | |
/// - replacementString: The `String` to replace the matched characters with. | |
/// - Returns: A new `String` with all characters in the character set replaced by the replacement string. | |
func replacingCharacters(in characterSet: CharacterSet, with replacementString: String = "") -> String { | |
return self.components(separatedBy: characterSet).joined(separator: replacementString) | |
} |
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 Locale { | |
/// The calling code or "country dial in code" of the locale. | |
/// See https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_listing_by_country_or_region | |
var countryCallingCode: String? { | |
return isdCode | |
} | |
/// The international subscriber dialling (ISD) code of the locale. | |
var isdCode: String? { | |
guard let regionCode = self.regionCode else { return nil } |
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 Locale { | |
/// An emoji representation of the locale's region. | |
var emoji: String? { | |
return regionalIndicatorSymbol | |
} | |
/// The regional indicator symbols are a set of 26 alphabetic Unicode characters (A–Z) intended to be used to encode | |
/// ISO 3166-1 alpha-2 two-letter country codes in a way that allows optional special treatment. | |
/// | |
/// These were defined as part of the Unicode 6.0 support for emoji, as an alternative to encoding separate characters for each |
OlderNewer