This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let displayLink = CADisplayLink(target: self, selector: Selector("update:")) | |
displayLink.addToRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1. リストを引数に取って、length に π (=3.1415)を返す関数 | |
pieTime x = fromIntegral (length x) + (pi :: Float) | |
-- 2. 2つの文字列を引数にとって、数値として足し算する関数 | |
addString x y = (read x::Int) + (read y::Int) | |
-- 3. 文字列を逆する関数 | |
reverse' x = [x !! z | z <- [((length x) - 1), ((length x) - 2)..0]] | |
-- 4. 文字列が回文かどうかを判定する関数 isPalindrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
#Xcode上の不要なファイルを抽出するスクリプト | |
puts "- start class file #{Time.now.strftime("%Y/%m/%d %H:%M:%S")}" | |
class_waste_count = 0 | |
#クラスファイルの一覧を取得 | |
result = `find ~/SampleProject -type f -name "*.h" -exec basename {} \\; | sort` | |
class_filenames = result.split("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy) | |
// id object: プロパティを持たせたいオブジェクト | |
// void *key: プロパティのアドレス (static で宣言した不変なローカルな静的変数を指定する) | |
// id value: 保持させるのオブジェクト | |
// objc_AssociationPolicy policy: 関連付けの方法 (後述) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func reduce<T,R>(list: [T], block: (([R],T) -> R?)) -> [R]? { | |
var acc = [R]() | |
for x in list { | |
if let val = block(acc, x) { | |
acc += [val] | |
} | |
} | |
return acc | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"sort" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Extension<Base> { | |
public let base: Base | |
public init(_ base: Base) { | |
self.base = base | |
} | |
} | |
public struct StaticExtension<Base> { } | |
public protocol ExtensionCompatible { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
import UIKit | |
final class TimerIndicator: UIView { | |
deinit { | |
displayLink?.invalidate() | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PlaygroundSupport | |
import UIKit | |
final class LoadingIndicator: UIView { | |
var color: UIColor = .blue | |
private var index: Int = 0 | |
private let lap: TimeInterval = 2 | |
private let movingAngle: CGFloat = 5 / 6 * .pi2 | |
private let rotationCount: Int = 6 | |
private let minimumAngle: CGFloat = .pi2 / 24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PlaygroundSupport | |
import UIKit | |
final class RippleCheckmark: UIView { | |
private let circleLayer: CAShapeLayer = .init() | |
private let rippleLayer: CAShapeLayer = .init() | |
private let checkmarkLayer: CAShapeLayer = .init() | |
private var completion: (() -> Void)? | |
var fillColor: UIColor = .blue { | |
didSet { update() } |
OlderNewer