Skip to content

Instantly share code, notes, and snippets.

View adamkuipers's full-sized avatar

Adam Kuipers adamkuipers

View GitHub Profile
# Create new address
curl \
-v \
-H "Content-Type: application/json" \
-X POST \
-d '{
"id": "GARBAGE",
"customerId": "5a57604e-e717-11e5-a529-5f344b5b4cee",
"firstName": "The Sweetest",
"lastName": "Ever",
import UIKit
protocol Bar {
var layoutOrientation: NSTextLayoutOrientation { get }
}
extension Bar {
var layoutOrientation: NSTextLayoutOrientation {
return .Horizontal
}
@adamkuipers
adamkuipers / dynamic.swift
Last active December 9, 2015 21:28
Dynamic Dispatch with objc protocols
import Foundation
@objc
protocol Bimpy: NSObjectProtocol {
func bimp() -> String
}
@objc
protocol DefaultBimpy: Bimpy {
func bimp() -> String
@adamkuipers
adamkuipers / heterogeneous.swift
Created December 8, 2015 20:44
Heterogeneous List in Swift
//: Playground - noun: a place where people can play
protocol HList {}
struct HNil: HList {}
struct HCons<Element, List: HList>: HList {
let head: Element
let tail: List
}
infix operator |*| { associativity right }
scala> val x1: Float = Long.MaxValue
x1: Float = 9.223372E18
scala> val x2 = Long.MaxValue - Int.MaxValue
x2: Long = 9223372034707292160
scala> x1 == x2
res0: Boolean = true
class Parser<T> : StringLiteralConvertible {
typealias StringLiteralType = Swift.StringLiteralType
typealias ExtendedGraphemeClusterLiteralType = ExtendedGraphemeClusterType
typealias UnicodeScalarLiteralType = UnicodeScalarType
let token: String
required init(stringLiteral value: StringLiteralType) {
self.token = value
}
@adamkuipers
adamkuipers / hk.swift
Last active December 8, 2015 19:46
Higher-kinded types encoded as path-dependent types
// Based off of https://gist.github.com/runarorama/33986541f0f1ddf4a3c7
protocol λ {
typealias α
}
struct K<L: λ>: λ {
typealias α = L.α
}
@adamkuipers
adamkuipers / FunctionOverloading.swift
Created October 9, 2015 19:55
Function overloading swift bug
// Doesn't work.
func doBimpy(f1: Bimpy, _ f2: Bimpy) -> Bimpy {
return Bimpy()
}
// Works
func doBimpy2(f1: Bimpy, _ f2: Bimpy) -> Bimpy {
return Bimpy()
}
@adamkuipers
adamkuipers / gist:5d50202dd2ef5959e86e
Last active August 29, 2015 14:26
ondir GIT_COMMITTER_EMAIL change
adamkuipers@Adams-MacBook-Pro ~
% echo $GIT_COMMITTER_EMAIL
adamkuipers@Adams-MacBook-Pro ~
% cd development/sps/PrintStudio-iOS
adamkuipers@Adams-MacBook-Pro ~/development/sps/PrintStudio-iOS [country-picker *]
± % echo $GIT_COMMITTER_EMAIL
adam@socialprintstudio.com
@adamkuipers
adamkuipers / readableweb
Created July 1, 2015 06:06
The Readable Web
adamkuipers@Adams-MacBook-Air ~
% curl https://www.google.com/\#q\=elm+lang !10002
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="/images/google_favicon_128.png" itemprop="image"><title>Google</title><script>(function(){window.google={kEI:'jIKTVYOpE5bioASHj4SoDw',kEXPI:'3700268,4010073,4029815,4032235,4032500,4032677,4032998,4033307,4033344,4036363,4036366,4036425,4036471,4036486,4036847,4036948,4037333,4037457,4037855,4037921,4037960,4038216,4038417,4038464,4038961,4039016,4039046,4039263,4039280,4039382,4039386,4039403,4039879,4039908,4040020,4040028,4040117,4040136,8300096,8300200,8300202,8500394,8501258,8501295,8501407,8501489,10200083',authuser:0,kscs:'c9c918f0_10'};google.kHL='en';})();(functio