Skip to content

Instantly share code, notes, and snippets.

View freddi-kit's full-sized avatar
🏠
WFH

freddi(Yuki Aki) freddi-kit

🏠
WFH
View GitHub Profile
#Atom-settings
@freddi-kit
freddi-kit / margeSort.swift
Last active July 10, 2018 15:06
MargeSort implemented by Swift
//: Playground - noun: a place where people can play
import UIKit
func mergeSort<T: Comparable>(array: inout Array<T>, low: Int, high: Int){
guard low < high else {
return
}
@freddi-kit
freddi-kit / file0.swift
Last active August 12, 2018 06:15
Scroll Viewのページングでのページ追加を簡単にできるようにした ref: https://qiita.com/freddi_/items/63e2592c8a18794650a8
// ViewController内
// 1. ページ数
let pageCount = 2
// 3. StackViewの作成
let contentView = UIStackView()
// 2. 紐づけたScroll View
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
protocol APIClient {
associatedtype GetDataType
func get()
}
//
// TouchWebViewController.swift
//
// Created by 秋勇紀 on 2018/11/17.
// Copyright © 2018 勇者野良猫の部屋. All rights reserved.
//
import UIKit
import WebKit
class TouchWebViewController: UIViewController {
import UIKit
protocol Redirectable where Self: UIViewController {
associatedtype Input
associatedtype Result
associatedtype Next
var nextVC: Next { get set }
func inject(input: Input)
@freddi-kit
freddi-kit / Peano.swift
Last active December 22, 2019 15:45
ペアノ自然数上の足し算と掛け算の推論規則をSwiftのenumで無理やりしたやつ
// ペアノ自然数
indirect enum N {
// N + 1
case S(N)
// 0
case Z
// デバッグ用、ペアノ自然数 -> アラビア数字
func print() -> Int {
var selfValue: N = self
//
// ViewController.swift
// test
//.
//
import UIKit
class ViewController: UIViewController {
extension SomeClass {
#if DEBUG
@available(*, deprecated, message: "Replace before releasing")
static func waitingReplace<X>(_ x: X) -> X {
return x
}
#else
@inline(__always)
@available(*, unavailable, message: "Replace before releasing")
static func waitingReplace<X>(_: X) -> X {
import Foundation
class SomeCallable {
var completion: () -> Void = { }
func call(completion: @escaping () -> Void) {
// Do something
self.completion = completion
}
}
class SomeClass {
var value: Int = 1