Skip to content

Instantly share code, notes, and snippets.

View fumiyasac's full-sized avatar
🎯
Focusing

Fumiya Sakai fumiyasac

🎯
Focusing
View GitHub Profile
@rummelonp
rummelonp / faraday.md
Last active May 20, 2022 12:23
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた

// 詳しい解説は下記
// https://trifort.jp/blog/development/%E6%8E%A2%E6%A4%9C%EF%BC%81swiftyjson-%E5%89%8D%E7%B7%A8/
struct SampleStruct {
var object:Any?
}
// ここに実装を追加していきます
// [] を実装
extension SampleStruct {
extension CollectionType {
func shuffled() -> [Generator.Element] {
var source = Array(self)
var result : [Generator.Element] = []
while !source.isEmpty {
let index = Int(arc4random()) % source.count
result.append(source[index])
source.removeAtIndex(index)
}
return result
@akuraru
akuraru / 休日一覧.md
Last active August 18, 2017 04:57
祝日についての覚書
休日 期日 適用開始年 適用終了年
元日 1月1日 1948年7月20日 -
元始祭 1月3日 1873年10月14日 1948年7月20日
新年宴会 1月5日 1873年10月14日 1948年7月20日
成人の日 1月15日 1948年7月20日 2000年1月1日
成人の日 1月の第2月曜日 2000年1月1日 -
孝明天皇祭 1月30日 1873年10月14日 1912年
紀元節 2月11日 1873年10月14日 1948年7月20日
@KyleGoslan
KyleGoslan / UIImage+Extension.swift
Created November 27, 2016 21:47
Resize UIImage Swift 3
import UIKit
extension UIImage {
func resizeWith(percentage: CGFloat) -> UIImage? {
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: size.width * percentage, height: size.height * percentage)))
imageView.contentMode = .scaleAspectFit
imageView.image = self
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
import UIKit
class HeaderView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setUp()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
import UIKit
import PlaygroundSupport
protocol WaterfallLayoutDelegate: AnyObject {
    func numberOfColumns() -> Int
    func columnsSize(at indexPath: IndexPath) -> CGSize
    func columnSpace() -> CGFloat
}
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource {
import UIKit
import PlaygroundSupport
protocol WaterfallLayoutDelegate: AnyObject {
    func numberOfColumns() -> Int
    func columnsSize(at indexPath: IndexPath) -> CGSize
    func columnSpace() -> CGFloat
}
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource {