Skip to content

Instantly share code, notes, and snippets.

David Owens II owensd

View GitHub Profile
View character.json
{
"attacks": [
{
"attackBonus": "strengthMod + proficiencyBonus",
"charId": "34HGdP9BywJezCywL",
"color": "q",
"damage": "1d8 + {strengthMod}",
"damageType": "slashing",
"enabled": true,
"name": "Cone of Cold",
@owensd
owensd / composite.swift
Created Nov 29, 2016
Full playground posting for blog post: Composite Validators - Refined
View composite.swift
//: Playground - noun: a place where people can play
import Cocoa
enum Result<ValueType> {
case ok(ValueType)
case error(Error)
}
protocol Validator {
View protocols.swift
//: Playground - noun: a place where people can play
import Cocoa
enum Error : ErrorType {
case NIY
}
protocol LangValue {
mutating func set(object object: LangValue, forKey key: String) throws
View better_keys.swift
enum Keys: String {
case uniqueID = "uniqueID"
}
Keys.uniqueID
View reverse.swift
extension Array {
func first() -> T {
return self[0]
}
func last() -> T {
return self[self.count - 1]
}
}
View mutable.swift
struct SPerson {
var name: String
init(_ name: String) { self.name = name }
}
class CPerson {
var name: String
init(_ name: String) { self.name = name }
}
View conversion.swift
// playground1 contents
// import Foundation
let items = [4, 2.3] // this is of type Array<Double>
// playground2 contents
import Foundation
let items = [4, 2.3] // this is of type NSArray
View spaces_tabs.m
NSDictionary *dict = @{ @"key1: @"value1",
@"key2: @"value2",
// ...
@"keyN: @"valueN" };
View MyDoubleDouble.swift
class MyDoubleDouble : FloatLiteralConvertible {
var double : Double
init(_ value: Double) {
double = value * 2
}
class func convertFromFloatLiteral(value: Double) -> MyDoubleDouble {
return MyDoubleDouble(value)
}
View json.swift
var json = [
"stat": "ok",
"blogs": [
"blog": [
[
"id" : 73,
"name" : "Bloxus test",
"needspassword" : true,
"url" : "http://remote.bloxus.com/"
],
You can’t perform that action at this time.