Skip to content

Instantly share code, notes, and snippets.

View ryokosuge's full-sized avatar
football

ryokosuge ryokosuge

football
View GitHub Profile
@ryokosuge
ryokosuge / ViewController.swift
Last active August 15, 2018 01:36
【iOS】バーコードリーダーをSwiftで作ってみた ref: https://qiita.com/ryokosuge/items/c903e04da555294299ae
import UIKit
import AVFoundation
final class ViewController: UIViewController {
@IBOutlet weak var captureView: UIView?
private lazy var captureSession: AVCaptureSession = AVCaptureSession()
private lazy var captureDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
private lazy var capturePreviewLayer: AVCaptureVideoPreviewLayer = {
@ryokosuge
ryokosuge / CarthagePlayground.playground
Created January 13, 2016 14:32
【iOS】Carthageで入れたframeworkをPlaygroundで使用する ref: http://qiita.com/ryokosuge/items/2551cd4faa9dca324342
//: Playground - noun: a place where people can play
import UIKit
import Himotoki
var str = "Hello, playground"
struct Person: Decodable {
let name: String
@ryokosuge
ryokosuge / Cartfile
Created December 19, 2015 15:29
【iOS】MarkdownをHTMLにレンダリングするライブラリを使って、Qiitaの記事をMarkdownで表示してみた ref: http://qiita.com/ryokosuge/items/64bb6df23fbf98325c5c
## Himotoki
## source: https://github.com/ikesyo/Himotoki
github "ikesyo/Himotoki" ~> 1.3
## Alamofire
## source: https://github.com/Alamofire/Alamofire
github "Alamofire/Alamofire" ~> 3.0
## BrightFutures
## source https://github.com/Thomvis/BrightFutures
@ryokosuge
ryokosuge / NavigationAnimator.swift
Last active December 19, 2015 02:58
【iOS】Swipeで簡単に戻れるNavigationControllerを作ってみた ref: http://qiita.com/ryokosuge/items/e3cee04cf8ff0c138719
import UIKit
protocol NavigationAnimatorDelegate: class {
func popViewController()
func shouldBeginGesture(gesture: UIGestureRecognizer) -> Bool
}
class NavigationAnimator: UIPercentDrivenInteractiveTransition {
@ryokosuge
ryokosuge / Cat.swift
Last active September 19, 2018 03:44
【iOS】配列の要素をユニークにしてみる ref: https://qiita.com/ryokosuge/items/39bc83465e2ac9a003f2
class Cat: Equatable {
let name: String
init(name: String) {
self.name = name
}
}
// これを実装します
func ==(lhs: Cat, rhs: Cat) -> Bool {
@ryokosuge
ryokosuge / file0.sh
Last active December 8, 2015 10:27
【iOS】MDCSwipeToChooseを使ってTinderUIと戯れてみた ref: http://qiita.com/ryokosuge/items/f924816b7e5a4c68b3ba
% pod search MDCSwipeToChoose
-> MDCSwipeToChoose (0.2.3)
Swipe to "like" or "dislike" any view, just like Tinder.app. Build a
flashcard app, a photo viewer, and more, in minutes, not hours!
pod 'MDCSwipeToChoose', '~> 0.2.3'
- Homepage: https://github.com/modocache/MDCSwipeToChoose
- Source: https://github.com/modocache/MDCSwipeToChoose.git
- Versions: 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.0 [master repo]
@ryokosuge
ryokosuge / Persion.swift
Created October 14, 2015 04:02
【CoreData】あるEntityのあるPropertyの最大値、最小値を取得するのSwift版 ref: http://qiita.com/ryokosuge/items/022b878f0776adacd260
import Foundation
import CoreData
class Person: NSManagedObject {
// Insert code here to add functionality to your managed object subclass
}
@ryokosuge
ryokosuge / MaxValue.m
Last active October 14, 2015 04:03
【CoreData】あるEntityのあるPropertyの最大値、最小値を取得する ref: http://qiita.com/ryokosuge/items/95577cbdd9df80d1dcaa
/// maxの値のkey
NSString *expressionName = @"maxWeight";
/// お決まりのやつ
/// 生成方法は各自でお任せです
NSManagedObjectContext *context = [CoreData sharedInstance].managedObjectContext;
/// fetch requestの生成
NSFetchRequest *fetchRequest = [NSFetchRequest new];
@ryokosuge
ryokosuge / Util.h
Created October 13, 2015 06:46
【iOS】OSのバージョン確認用のメソッド ref: http://qiita.com/ryokosuge/items/4045c4f29e40c064e70b
#import <Foundation/Foundation.h>
@interface Util : NSObject
/**
* デバイスのOSバージョンが指定したバージョン以上かどうかを確認してBOOLで返す
* @param majorVersion メジャーバージョン
* @param minorVersion マイナーバージョン
* @param patchVersion バッジバージョン
* @return BOOL 引数で渡したOSバージョン以上だった場合,YES それより下の場合はNO
@ryokosuge
ryokosuge / APIArrayResult.swift
Created July 16, 2015 01:15
【Swift】Genericとtypealiasを使ったら"compiler segmentation fault when building"が起きた ref: http://qiita.com/ryokosuge/items/8738ad76200831b6bcc6
import UIKit
class APIResult<T: ModelType> {
var model: Optional(T.ModelType) = nil
init(response: AnyObject!) {
self.model = T.toModel(response: response)
}