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
struct APIError: NetworkError { | |
let json: JSON | |
let apiCode: Int? | |
let message: String? | |
let httpResponse: HTTPURLResponse |
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
protocol CaseCountable { } | |
extension CaseCountable where Self : RawRepresentable, Self.RawValue == Int { | |
static var count: Int { | |
var count = 0 | |
while let _ = Self(rawValue: count) { count+=1 } | |
return count | |
} |
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
// | |
// PublicationCenter.swift | |
// | |
// Created by Brian King on 5/17/16. | |
// Copyright © 2016 Raizlabs. All rights reserved. | |
// | |
import Foundation | |
/// PublicationCenter is an NSNotificationCenter style object that |
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
final class CenteringView: UIView { | |
// MARK: - Initialization | |
init(contentView: UIView) { | |
super.init(frame: .zero) | |
addSubview(contentView) | |
contentView.translatesAutoresizingMaskIntoConstraints = false | |
NSLayoutConstraint.activateConstraints([ |
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
namespace :housekeeping do | |
desc "Remove all header-comments" | |
task :remove_header_comments do | |
["Classes", "Tests"].each do |directory| | |
files = Dir["./#{directory}/**/*"].select { |value| File.file?(value) } | |
files.each do |file| | |
lines_array = File.open(file).readlines | |
if lines_array.first.match(/^\/\//) && !lines_array.first.match(/^\/\/ DO NOT EDIT/) | |
text = lines_array.drop_while { |line| line.match(/^\/\/|^\n/) } | |
File.open(file, 'w') do |f| |
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 conversionMap: [Character: Character] = [ | |
"\u{0021}" : "\u{00A1}", | |
"\u{0022}" : "\u{201E}", | |
"\u{0026}" : "\u{214B}", | |
"\u{0027}" : "\u{002C}", | |
"\u{0028}" : "\u{0029}", | |
"\u{002E}" : "\u{02D9}", | |
"\u{0033}" : "\u{0190}", | |
"\u{0034}" : "\u{152D}", | |
"\u{0036}" : "\u{0039}", |
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
#ifndef NS_DESIGNATED_INITIALIZER | |
#if __has_attribute(objc_designated_initializer) | |
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer)) | |
#else | |
#define NS_DESIGNATED_INITIALIZER | |
#endif | |
#endif |
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 the ability to verify key paths at compile time. | |
If "keyPath" does not exist, a compile-time error will be generated. | |
Example: | |
// Verifies "isFinished" exists on "operation". | |
NSString *key = SQKeyPath(operation, isFinished); | |
// Verifies "isFinished" exists on self. |
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
/* | |
* Calling math.h functions like `floor` and `floorf` on CGFloat variables | |
* becomes problematic when compiling the same code for both 32-bit and | |
* 64-bit platforms, since CGFloat is double on 64-bit, float on 32-bit. | |
* Hence, if you compile with -Wconversion set, `floorf` will give a warning | |
* on 64-bit, while `floor` gives a warning on 32-bit. | |
* | |
* Here's a suggested implementation of an architecture-independent `floor` | |
* function, written using plain old function overloading which is enabled | |
* using the `__attribute__((overloadable))` Clang language extension. |
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
function _hero_getRemoteNames(){ | |
git config --get-regexp remote.*.url heroku.com | | |
sed -E 's/^remote\.([^\.]*)\.url .*$/\1/' | |
} | |
function _hero_herokuAppFor(){ | |
git config --get remote.$1.url | | |
sed -E 's/^[email protected]:([^.]*)\.git/\1/' | |
} |
NewerOlder