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
@chuganzy
chuganzy / gist:38c0b13068992ffe20e9
Last active Aug 29, 2015
OS X ServerでXcodeの設定をするとオフにしていても_xcsbuilddが勝手にログイン状態になる
View gist:38c0b13068992ffe20e9
sudo xcrun xcscontrol --reset
@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'
@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
}
}
View gist:649abb7aa6cea5af6d00
struct Person {
let name: String
func isValid() -> Bool {
return !name.characters.isEmpty
}
}
let validPerson = Person(name: "Tom")
let invalidPerson = Person(name: "")
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
@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 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: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 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 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()
You can’t perform that action at this time.