Skip to content

Instantly share code, notes, and snippets.

Avatar

Takeru Chuganji chuganzy

View GitHub Profile
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 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 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)
}
}
@chuganzy
chuganzy / gist:d88d56e9b402153d687a
Last active Mar 4, 2016
Carthageの面倒な作業をどうにかする
View gist:d88d56e9b402153d687a
#!/usr/bin/env ruby
require 'xcodeproj'
require 'colorize'
Dir.chdir "#{__dir__}/../"
class LibraryUpdateManager
attr_accessor :update_carthage, :update_cocoapods, :acknowledgements_path
def initialize
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 / gist:fe383dce2c8be3c8ac3c
Last active Dec 13, 2015
マイナンバー チェックデジット
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
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:649abb7aa6cea5af6d00
struct Person {
let name: String
func isValid() -> Bool {
return !name.characters.isEmpty
}
}
let validPerson = Person(name: "Tom")
let invalidPerson = Person(name: "")
@chuganzy
chuganzy / gist:85743eee8609a80dd35a
Last active Sep 7, 2015
uuid_generate_time in Swift
View gist:85743eee8609a80dd35a
extension NSUUID {
class func timeBasedUUID() -> NSUUID {
let uuidSize = sizeof(uuid_t)
let uuidPointer = UnsafeMutablePointer<UInt8>.alloc(uuidSize)
uuid_generate_time(uuidPointer)
let uuid = NSUUID(UUIDBytes: uuidPointer)
uuidPointer.dealloc(uuidSize)
return uuid
}
}
@chuganzy
chuganzy / gist:1f74224d7c62f01654ec
Last active Aug 29, 2015
xcdatamodeldからSwiftのコードをいい感じに吐く
View gist:1f74224d7c62f01654ec
#!/usr/bin/env ruby
require 'nokogiri'
require 'colorize'
require 'erubis'
class Manager
class SwiftConverter
def to_swift
raise 'Error: method `to_swift` is not implemented'
You can’t perform that action at this time.