Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
@chriseidhof
chriseidhof / presentation.md
Created June 28, 2014 13:00
MobileOptimized Presentation

[fit] Functional Programming in

[fit] Swift

Chris Eidhof - objc.io - June 28, Minsk



@hectormatos2011
hectormatos2011 / UIGestureRecognizer+Closures.swift
Last active December 24, 2016 20:27
UIGestureRecognizer+Closures.swift
//
// UIGestureRecognizer+Closures.swift
// Closures
//
// Created by Hector on 7/23/14.
// Copyright (c) 2014 Hector Matos. All rights reserved.
//
import Foundation
@chriseidhof
chriseidhof / parsing.swift
Last active April 16, 2023 02:38
JSON Parsing in Swift
// This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html
//
// As of Beta5, the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
@andymatuschak
andymatuschak / CollectionViewDataSource.swift
Last active February 12, 2021 09:44
Type-safe value-oriented collection view data source
//
// CollectionViewDataSource.swift
// Khan Academy
//
// Created by Andy Matuschak on 10/14/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
typealias verFunc = @convention(c) ()->UnsafePointer<CChar>
let libz = dlopen("libz.dylib", RTLD_LAZY)
let ret = dlsym(libz, "zlibVersion")
let zLibVersion = unsafeBitCast(ret, verFunc.self)
print("\(String.fromCString(zLibVersion())!)")
@chriseidhof
chriseidhof / TypedExpr.swift
Last active February 3, 2018 23:01
Typed Expressions in Swift
// Variables just contain an integer. We can have a maximum of `Int.max` variables in our program. ¯\_(ツ)_/¯
private struct Var {
static var freshVarIx = 0
let ix: Int
init() {
Var.freshVarIx+=1
ix = Var.freshVarIx
}
}