Skip to content

Instantly share code, notes, and snippets.

Takeru Chuganji chuganzy

Block or report user

Report or block chuganzy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View URLSession+Combine.swift
import Foundation
import Combine
private let defaultError = NSError(domain: "jp.ganzy.URLSession+Combine", code: -1, userInfo: nil)
extension URLSession {
func data(with request: URLRequest) -> Publishers.Future<(Data, URLResponse), Error> {
var task: URLSessionDataTask?
let future = Publishers.Future<(Data, URLResponse), Error> { c in
task = self.dataTask(with: request) { data, response, error in
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? {
@chuganzy
chuganzy / APIKit+Rx.swift
Last active Apr 24, 2017
RxSwift x APIKit
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
You can’t perform that action at this time.