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
// Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
// Copyright (c) 2013 Peter Steinberger. All rights reserved. | |
// Licensed under MIT (http://opensource.org/licenses/MIT) | |
// | |
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
#import <objc/runtime.h> | |
#import <objc/message.h> | |
// Compile-time selector checks. |
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
// | |
// PSPDFThreadSafeMutableDictionary.m | |
// | |
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is |
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
// | |
// NSURL_Networking.swift | |
// swiftTools | |
// | |
// Created by Zachry Thayer on 6/3/14. | |
// Copyright (c) 2014 Zachry Thayer. All rights reserved. | |
// | |
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
// | |
// KVOTests.swift | |
// SwiftStuff | |
// | |
// Created by Venkat Peri on 8/11/14. | |
// Copyright (c) 2014 vperi. All rights reserved. | |
// | |
import Cocoa | |
import XCTest |
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
let array = ["P","Q","R","S","T","P","R","A","T","B","C","P","P","P","P","P","C","P","P","J"] | |
extension Array { | |
func unique<T: Equatable>() -> [T] { | |
return self.reduce([T](), combine: { (array, value) -> [T] in | |
var result = array | |
let valAsT = value as T | |
if (!contains(array, valAsT)) { | |
result.append(valAsT) | |
} |
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 fetchAll<T:NSManagedObject>(type:T.Type, predicate:NSPredicate?, sorts:[AnyObject]?=nil)->[T]{ | |
let entityName = NSStringFromClass(type); | |
let request = NSFetchRequest(entityName:entityName); | |
request.predicate = predicate; | |
request.sortDescriptors = sorts; | |
var error:NSError?=nil; | |
if let rows = context.executeFetchRequest(request, error:&error) { | |
return rows as [T]; | |
}else{ | |
DDLogError("\(error)"); |
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
// CGContextABCD(context!, ...) becomes context?.ABCD(...) | |
import Cocoa | |
extension CGContext { | |
func saveGState() { CGContextSaveGState(self) } | |
func restoreGState() { CGContextRestoreGState(self) } | |
func scaleCTM( sx: CGFloat, sy: CGFloat) { CGContextScaleCTM(self, sx, sy) } | |
func translateCTM( tx: CGFloat, ty: CGFloat) { CGContextTranslateCTM(self, tx, ty) } | |
func rotateCTM( angle: CGFloat) { CGContextRotateCTM(self, angle) } |
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/Foundation.h> | |
@interface NSArray (UniqueObjects) | |
-(NSArray*) uniqueObjects; | |
-(NSArray*) uniqueObjectsSortedUsingSelector: (SEL)comparator; | |
-(NSArray*) uniqueObjectsSortedUsingFunction: (NSInteger (*)(id, id, void *)) comparator |
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
#! /bin/bash | |
# | |
# This script repairs Mac OS X site_ruby and ruby symbolic links if they are broken. | |
# For more information on this problem please see: http://openradar.appspot.com/9202152 | |
# | |
set -e | |
set -u | |
timestamp=$(date +%s) |
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/Foundation.h> | |
// clang -fobjc-arc -Wall -Wformat -Weverything -Wno-format-nonliteral -framework Foundation -o log log.m | |
// Compiler likes explicit function prototypes prior to first use. | |
// Add an attribute to get additional checking from the compiler | |
extern void QuietLog (NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); | |
// !!! The attribute above isn't warning like it should, but NSLog's _is_ working. | |
// This is NSLog's attribute. I'm currently baffled. |
OlderNewer