View shuffle_lunch.coffee
# Description: | |
# シャッフルランチの管理をします | |
# | |
# Dependencies: | |
# None | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: |
View NSString+Surrogate.swift
import Foundation | |
extension NSString { | |
func utf16IndexForIndex(index: Int) -> Int { | |
var index = index | |
var result = 0 | |
while result < index { | |
if result + 1 < self.length && | |
CFStringIsSurrogateHighCharacter(self.characterAtIndex(result)) && | |
CFStringIsSurrogateLowCharacter(self.characterAtIndex(result + 1)) { |
View AVCaptureSession+Rx.swift
import Foundation | |
import AVFoundation | |
import RxSwift | |
import RxCocoa | |
extension AVCaptureSession { | |
var rx_runnning: AnyObserver<Bool> { | |
return RxBindingObserver(element: self) { element, value in | |
if value { | |
element.startRunning() |
View RxCaptureMetadataOutputObjectsDelegateProxy.swift
import Foundation | |
import AVFoundation | |
import RxSwift | |
import RxCocoa | |
private let associatedkey = UnsafePointer<Void>(malloc(1)) | |
class RxCaptureMetadataOutputObjectsDelegateProxy: DelegateProxy, DelegateProxyType, AVCaptureMetadataOutputObjectsDelegate { | |
static func setCurrentDelegate(delegate: AnyObject?, toObject object: AnyObject) { | |
(object as! AVCaptureMetadataOutput) |
View APIKit+Himotoki.swift
import Foundation | |
import APIKit | |
import Himotoki | |
extension RequestType where Response: Decodable, Response.DecodedType == Response { | |
func responseFromObject(object: AnyObject, URLResponse: NSHTTPURLResponse) -> Response? { | |
return try? decode(object) | |
} | |
} |
View UIVisualEffectView+EffectColor.swift
extension UIVisualEffectView { | |
var effectColor: UIColor? { | |
get { | |
return self.colorEffectView()?.backgroundColor | |
} | |
set { | |
self.colorEffectView()?.backgroundColor = newValue | |
} | |
} | |
private func colorEffectView() -> UIView? { |
View APIKit+Rx.swift
import Foundation | |
import APIKit | |
import RxSwift | |
extension Session { | |
func rx_sendRequest<T: RequestType>(request: T) -> Observable<T.Response> { | |
return Observable.create { observer in | |
let task = self.sendRequest(request) { result in | |
switch result { | |
case .Success(let res): |
View UniversalLinksUITests.m
#import <XCTest/XCTest.h> | |
@interface XCTestCase (Private) | |
- (void)_enqueueFailureWithDescription:(id)arg1 inFile:(id)arg2 atLine:(unsigned long long)arg3 expected:(_Bool)arg4; | |
@end | |
@interface UniversalLinksUITests : XCTestCase | |
@property (assign, nonatomic) BOOL ignoreFailure; | |
@end |
View gist:acc59af0e04bf31188dc
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool { | |
guard let url = request.URL else { | |
return true | |
} | |
if url.scheme.rangeOfString("^https?", options: .RegularExpressionSearch) != nil { | |
return true | |
} | |
if !UIApplication.sharedApplication().canOpenURL(url) { | |
// iOS9でInfo.plistに登録してないとfalseになるのでここに来る | |
return false |
View gist:fe383dce2c8be3c8ac3c
extension String { | |
func isValidMyNumber() -> Bool { | |
enum Error: ErrorType { | |
case NonNumber | |
} | |
let numbers: [Int] | |
do { | |
numbers = try self.characters.map { (char) -> Int in | |
guard let value = Int(String(char)) else { | |
throw Error.NonNumber |
NewerOlder