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
// BridgeHeader.h | |
#import <unicode/uchar.h> | |
// UnicodeBlock.swift | |
import Foundation | |
class UnicodeBlock { | |
class var blocks: UnicodeBlock[] { |
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
// Playground - noun: a place where people can play | |
import UIKit | |
// MARK: Utilities | |
func take<T>(slice: Slice<T>, num: Int) -> Slice<T> { | |
let n = (num < slice.count) ? num : slice.endIndex | |
return slice[0..<n] | |
} |
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
enum ShiftKeyType { | |
case None | |
case Once | |
case Always | |
} | |
enum PunctuationSwitcherType { | |
case More | |
case Numeric | |
} |
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 bytes<T: IntegerType>(i: T) -> [UInt8] { | |
let p = UnsafeMutablePointer<T>.alloc(1) | |
p.memory = i | |
let b = unsafeBitCast(p, UnsafePointer<UInt8>.self) | |
let bytes = reduce(0..<sizeof(T), []) { $0 + [b[$1]] } | |
p.destroy() | |
return bytes | |
} |
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> | |
// convert a RFC3399 date (& time) into a NSDate object | |
// NOTE: This function ignores fractions of a second in the RFC3339 | |
// representation. | |
NSDate *getDateObject(NSString *rfc3339) | |
{ | |
// Date and Time representation in RFC3399: | |
// Pattern #1: "YYYY-MM-DDTHH:MM:SSZ" | |
// 1 |
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
// | |
// NSDate+RFC3339.h | |
// | |
// Created by Atsushi Nagase on 3/7/11. | |
// Copyright 2011 LittleApps Inc. All rights reserved. | |
// | |
@interface NSDate (RFC3339) |
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
# Copyright (c) 2011 Phil Plante <unhappyrobot AT gmail DOT com> | |
# | |
# 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 | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in |
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 NSObject (AMAssociatedObjects) | |
- (void)associateValue:(id)value withKey:(void *)key; // Retains value. | |
- (id)associatedValueForKey:(void *)key; | |
@end |
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
BOOL PSIsCrappyDevice(void) { | |
static BOOL isCrappyDevice = YES; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
BOOL isSimulator = NO; | |
BOOL isIPad2 = (PSIsIpad() && [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]); | |
BOOL hasRetina = [[UIScreen mainScreen] scale] > 1.f; | |
// enable animations on simulator |
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
@implementation MySharedThing | |
// Using method 1 | |
// | |
DEFINE_SHARED_INSTANCE_FOR_CLASS(MySharedThing) | |
// Using method 2 | |
// | |
+ (id)sharedInstance | |
{ |
OlderNewer