Skip to content

Instantly share code, notes, and snippets.

View chuganzy's full-sized avatar

Takeru Chuganji chuganzy

View GitHub Profile
#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
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()
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 March 4, 2016 06:57
Carthageの面倒な作業をどうにかする
#!/usr/bin/env ruby
require 'xcodeproj'
require 'colorize'
Dir.chdir "#{__dir__}/../"
class LibraryUpdateManager
attr_accessor :update_carthage, :update_cocoapods, :acknowledgements_path
def initialize
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 December 13, 2015 14:11
マイナンバー チェックデジット
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
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
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 September 7, 2015 06:09
uuid_generate_time in Swift
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 August 29, 2015 14:19
xcdatamodeldからSwiftのコードをいい感じに吐く
#!/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'