I hereby claim:
- I am zhigang1992 on github.
- I am zhigang1992 (https://keybase.io/zhigang1992) on keybase.
- I have a public key whose fingerprint is 0103 7CA4 43F7 C8AE 7AD8 4DC6 CED9 7610 6867 A1C0
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
struct JSON { | |
var value: Optional<NSObject> | |
subscript(index: Int) -> JSON { | |
get { | |
return JSON(value: value.flatMap({ value in | |
return (value as? NSArray).flatMap({ | |
if $0.count > index && index >= 0 { | |
return $0[index] as? NSObject |
function fakePromise(time, value) { | |
return new Promise((resolve) => { | |
setTimeout(()=>resolve(value), time) | |
}) | |
} | |
function* networkRequest() { | |
const value = yield fakePromise(1000, 123) | |
return yield fakePromise(1000, value + 123) | |
} |
import UIKit | |
precedencegroup PipingPrecedence { | |
associativity: left | |
higherThan: LogicalConjunctionPrecedence | |
} | |
infix operator |> : PipingPrecedence | |
func |><A,B>(a:A, function: (A)->B) -> B { |
import UIKit | |
precedencegroup PipingPrecedence { | |
associativity: left | |
higherThan: LogicalConjunctionPrecedence | |
} | |
infix operator |> : PipingPrecedence | |
func |><A,B>(a:A, function: (A)->B) -> B { |
#!/bin/sh | |
dest="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/" | |
installed="$dest/installed" | |
echo $1 | |
if [ "$1" == "--reset" ]; then | |
pushd "$dest" | |
for F in $(cat ./installed) ; do | |
echo $F |
// if you coming from the Argo Talk from WTB Swift | |
// here is the actual playground code: https://github.com/zhigang1992/ArgoTalk | |
import Foundation | |
struct Parser<T> { | |
let parse: (AnyObject) -> T? | |
} |
enum Lazy<T> { | |
case Function(()->T) | |
case Value(T) | |
var value: T { | |
switch self { | |
case .Function(let f): return f() | |
case .Value(let v): return v | |
} | |
} |
//data | |
import Foundation | |
let input:NSDictionary = [ | |
"id": 123, | |
"name": "Awesome Name", | |
"createdAt": "2011-12-12", | |
"avatar": [ | |
"url": "http://www.google.com", | |
"size": [ |
[{ | |
"name": "Hello, World" | |
}] |