Skip to content

Instantly share code, notes, and snippets.

View keitaoouchi's full-sized avatar

Keita Oouchi keitaoouchi

  • kakaku.com
  • Tokyo
View GitHub Profile
@keitaoouchi
keitaoouchi / iap_gas_server.js
Last active August 24, 2021 05:34
Logging server for in-app purchase's server to server notification on google app script
function doGet(e) {
var row = defineRow(e);
var cell = getCell(row);
return ContentService.createTextOutput(cell).setMimeType(ContentService.MimeType.JSON);
}
function doPost(e) {
if (e == null || e.postData == null || e.postData.contents == null) { return; }
var body = e.postData.contents;
@keitaoouchi
keitaoouchi / AVLTree.swift
Last active June 23, 2021 02:08
Implement AVLTree with conditional insert where element is comparable
import Foundation
final class MutableAVLTree<T> {
typealias Process = ((MutableAVLTree<T>) -> ())
var value: T?
var height: Int = 0
var left: MutableAVLTree?
var right: MutableAVLTree?
init() {
@keitaoouchi
keitaoouchi / KeyboardManager.swift
Last active December 2, 2020 02:38
まぁまぁ再利用しがちなキーボードマネージャー
import UIKit
/// キーボードイベントを監視し、キーボードの開閉に合わせてviewをtransformで上下移動させる
final class KeyboardManager {
private var view: UIView
/// キーボード開閉時に可能なら表示されるように画面スライド位置が調整されるビュー
/// 縦長フォームの一番下にあるサブミットボタンみたいなやつを想定
private var subFocusView: UIView?
@keitaoouchi
keitaoouchi / poptransition.swift
Created June 14, 2018 06:48
Custom popup presenting transition
import Foundation
import UIKit
final class PopupTransition: NSObject, UIViewControllerAnimatedTransitioning {
enum Mode {
case present
case dismiss
}
@keitaoouchi
keitaoouchi / qiita-swagger.yaml
Created May 15, 2018 10:37
Swagger definition for Qiita API
swagger: '2.0'
info:
version: 0.0.1
title: Qiita API
host: 'qiita.com'
basePath: '/api/v2'
@keitaoouchi
keitaoouchi / keybase.md
Created April 2, 2018 01:28
Keybase.md

Keybase proof

I hereby claim:

  • I am keitaoouchi on github.
  • I am keeeita (https://keybase.io/keeeita) on keybase.
  • I have a public key ASCEz-ejBvg97RXT9iqKRWpZGZ0bdbHdG6eHGwC6g3Bw4wo

To claim this, I am signing this object:

@keitaoouchi
keitaoouchi / PlaceholderTextView.swift
Created October 13, 2017 07:34
PlaceholderTextView.swift
import UIKit
@IBDesignable
final class PlaceholderTextView: UITextView, UITextViewDelegate {
private let _TAG = 100
override open var bounds: CGRect {
didSet {
self.resizePlaceholder()
@keitaoouchi
keitaoouchi / moya_status_code.swift
Created September 26, 2017 01:32
moya_status_code.swift
extension MoyaError {
var is401: Bool {
switch self {
case .underlying(
Alamofire.AFError.responseValidationFailed(
Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(401)
)
): return true
default:
return false
@keitaoouchi
keitaoouchi / DotsLoader.swift
Last active March 17, 2018 13:10
Dotが3つくらいふわふわするアニメーションつきのローダー
import UIKit
import IoniconsKit
final class DotsLoader: UIViewController {
@IBOutlet weak var animationView: UIView!
@IBOutlet weak var statusLabel: UILabel!
var dots: [CALayer]?
// MARK: - configurable properties
var onSuccessImage: UIImage = UIImage.ionicon(
@keitaoouchi
keitaoouchi / SMSVerificationViewController.swift
Created July 26, 2017 05:43
SMSのPINコード認証したりする感じのViewController
import UIKit
import RxSwift
final class SMSVerificationViewController: UIViewController {
@IBOutlet weak var digits1TextField: UITextField!
@IBOutlet weak var digits2TextField: UITextField!
@IBOutlet weak var digits3TextField: UITextField!
@IBOutlet weak var digits4TextField: UITextField!
@IBOutlet weak var resendButton: UIButton!
@IBOutlet weak var submitButton: UIButton!