Skip to content

Instantly share code, notes, and snippets.

View towry's full-sized avatar
🎯
Focusing

Towry Wang towry

🎯
Focusing
  • Shanghai, China
View GitHub Profile
@towry
towry / README-Template.md
Created February 15, 2017 06:00 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@towry
towry / link.md
Created February 24, 2017 13:48
ios SplitViewController example without storyboard
@towry
towry / build_run_ios_app_in_simulator_from_terminal.md
Created February 28, 2017 07:18
build and run ios app in simulator from terminal command line.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
padding-top: 3rem;
}

Keybase proof

I hereby claim:

  • I am towry on github.
  • I am towry (https://keybase.io/towry) on keybase.
  • I have a public key whose fingerprint is B48B 3AEB 954C 5CC4 F323 B0FE E6AA 531E C52D DED3

To claim this, I am signing this object:

@towry
towry / request_webpage_in.swift
Created June 21, 2017 01:52
swift: request a web page.
//: Playground - noun: a place where people can play
import Foundation
import PlaygroundSupport
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
let url = URL(string: "http://www.baidu.com")
let task = URLSession.shared.dataTask(with: url!) {data, response, error in
@towry
towry / monad_explain.js
Last active July 6, 2017 10:00
explain monad in js.
/*!
https://blog.jcoglan.com/2011/03/05/translation-from-haskell-to-javascript-of-selected-portions-of-the-best-introduction-to-monads-ive-ever-read/
this is a function with side effect, to dealing with side effect,
we can format it into return value, because pure function can only
have input and output (return) effect to outside world.
```js
/// https://github.com/apple/swift-evolution/blob/master/proposals/0142-associated-types-constraints.md
protocol SubContainer: Container {
associatedtype Item: Equatable
}
protocol Container {
associatedtype Item
// error: 'where' clause cannot be attached to an associated type declaration
// error: type may not reference itself as a requirement
@towry
towry / associatedobject.swift
Created July 12, 2017 08:09
associated objects demo in swift. objc_setAssociatedObject, objc_getAssociatedObject
// So associated objects just store object in anoter place, use property to
// associate the object with the class object.
import Foundation
let data: Data?
var dataKey: Void?
data = Data(count: 10)
data?.insert(9, at: 0)
@towry
towry / proxy_syntax_pattern.swift
Last active July 12, 2017 09:08
swift proxy pattern demo.
//
// https://medium.com/@jegnux/safe-collection-subsripting-in-swift-3771f16f883
// https://github.com/ReactiveX/RxSwift/issues/826
//
import Foundation
// we define a fire protocol.
protocol FireProtocol {