Skip to content

Instantly share code, notes, and snippets.

View owensd's full-sized avatar

David Owens II owensd

View GitHub Profile
{
"attacks": [
{
"attackBonus": "strengthMod + proficiencyBonus",
"charId": "34HGdP9BywJezCywL",
"color": "q",
"damage": "1d8 + {strengthMod}",
"damageType": "slashing",
"enabled": true,
"name": "Cone of Cold",
@owensd
owensd / composite.swift
Created November 29, 2016 17:05
Full playground posting for blog post: Composite Validators - Refined
//: Playground - noun: a place where people can play
import Cocoa
enum Result<ValueType> {
case ok(ValueType)
case error(Error)
}
protocol Validator {
@owensd
owensd / protocols.swift
Created October 1, 2015 17:55
Need some help
//: 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
enum Keys: String {
case uniqueID = "uniqueID"
}
Keys.uniqueID
extension Array {
func first() -> T {
return self[0]
}
func last() -> T {
return self[self.count - 1]
}
}
struct SPerson {
var name: String
init(_ name: String) { self.name = name }
}
class CPerson {
var name: String
init(_ name: String) { self.name = name }
}
// 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
NSDictionary *dict = @{ @"key1: @"value1",
@"key2: @"value2",
// ...
@"keyN: @"valueN" };
class MyDoubleDouble : FloatLiteralConvertible {
var double : Double
init(_ value: Double) {
double = value * 2
}
class func convertFromFloatLiteral(value: Double) -> MyDoubleDouble {
return MyDoubleDouble(value)
}
var json = [
"stat": "ok",
"blogs": [
"blog": [
[
"id" : 73,
"name" : "Bloxus test",
"needspassword" : true,
"url" : "http://remote.bloxus.com/"
],