Skip to content

Instantly share code, notes, and snippets.

@AvatarHurden
AvatarHurden / AppDelegate.swift
Last active August 13, 2018 02:37
Coordinator with navigation and service functions
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let window = UIWindow(frame: UIScreen.main.bounds)
self.window = window
@maxcampolo
maxcampolo / GlobalConstant.swift
Created August 10, 2016 14:58
Global constants with swift extensions and Implicit Member Expression.
extension Double {
public static let kRectX = 30.0
public static let kRectY = 30.0
public static let kRectWidth = 30.0
public static let kRectHeight = 30.0
}
public func makeRect() -> CGRect {
return CGRect(x: .kRectX, y: .kRectY, width: .kRectWidth, height: .kRectHeight)
}
let _0_delay = 3.0 * Double(NSEC_PER_SEC)
let _0_time = DispatchTime.now() + Double(Int64(_0_delay)) / Double(NSEC_PER_SEC)
DispatchQueue.main.acyncAfter(deadline: _0_time, execute: {
})
DispatchQueue.main.acyncAfter(deadline: DispatchTime.now() + Double(Int64(3.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: {
})
@ktanaka117
ktanaka117 / PokemonTypeErasure.swift
Created March 6, 2016 13:22
try! Swift 2016のGwendolyn WestonさんによるType Erasureセッションの復習
import Foundation
// 💡: 元の例では型が指定されてなかったけど、この場合多分enumかな
enum Element {
case Electric, Fire
}
/********** Abstract Pokemon **********/
import Foundation
import XCTest
class Ref {
var success = false
}
@rnapier
rnapier / erasure.swift
Created August 4, 2015 20:10
A Little Respect for AnySequence (http://robnapier.net/erasure)
import Swift
/*:
A simple type-erased sequence
*/
let seq = AnySequence([1,2,3])
/*:
## Who Needs Types Like That?
@ericelliott
ericelliott / fp-lingo.md
Last active February 2, 2023 23:33
A Guide to Functional Programming Lingo for JavaScripters

A Guide to Functional Programming Lingo for JavaScripters

Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.

The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!

All examples using ES6 syntax. wrap (foo) => bar means:

function wrap (foo) {
@sooop
sooop / Monads.swift
Last active February 3, 2020 16:20
Monad in Swift : 모나드 개념을 Swift로 구현해본다.
/*
모나드는 특정한 타입을 감싸는 타입이며,
raw한 값을 감싸는 함수와
raw한 값을 모나드 값으로 바꾸는 어떤 함수에 바인딩된다.
이를 바탕으로 모나드 프로토콜을 정의하면 다음과 같다.
*/
protocol Monad {
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing