Skip to content

Instantly share code, notes, and snippets.

View zhigang1992's full-sized avatar
:octocat:
Focusing

Kyle zhigang1992

:octocat:
Focusing
View GitHub Profile

Keybase proof

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:

@zhigang1992
zhigang1992 / SwiftyJSON.swift
Created December 18, 2016 05:47
SwiftyJSON performant alternative
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
@zhigang1992
zhigang1992 / argo.swift
Last active September 6, 2016 02:12
Argo Talk
// 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?
}
@zhigang1992
zhigang1992 / Contents.swift
Last active June 8, 2016 09:15
Lazy Monad
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": [
@zhigang1992
zhigang1992 / load.json
Created May 17, 2016 13:58
React Native Workshop
[{
"name": "Hello, World"
}]