Skip to content

Instantly share code, notes, and snippets.

View mosluce's full-sized avatar

mosluce mosluce

View GitHub Profile
@mosluce
mosluce / ProtocolNotofication.swift
Created November 22, 2016 13:15 — forked from pofat/ProtocolNotofication.swift
Deal with notification with protocol-oriented programing in Swift
//: Playground - noun: a place where people can play
import UIKit
// This is for dmoe, you can use a generice type to limit your observer to an UIViewController for common usage.
protocol Notifiable {
var name: Notification.Name { get }
func observe(by observer: Any, withSelector selector: Selector, object: Any?)
func post(object: Any? ,userInfo: [AnyHashable: Any]?)
static func remove(observer: Any)
@mosluce
mosluce / gist:a95a63e193f69cb9a5b7ab036f38e8bd
Created October 17, 2016 07:21
虎航查詢Form攔截到的input內容
radioRoundTrip : RoundTrip
radioOneWay : OneWay
promoCode :
selOriginPicker : 台北 (TPE)
selOrigin : TPE
selDestPicker : 東京(成田及羽田機場)
selDest : XX1
dateDepart : 18 Oct 2016
dateReturn : 22 Oct 2016
TT_TripKind : return
<?xml version="1.0" encoding="UTF-8"?>
<flights>
<flight>
<flight_id>{6A49933F-7FD3-44F1-9278-78E0509B41C0}</flight_id>
<airline_rcd>MM</airline_rcd>
<flight_number>1028</flight_number>
<origin_rcd>TPE</origin_rcd>
<destination_rcd>HND</destination_rcd>
<fare_id>{35C514B6-FFBB-49FC-96F7-1B25FCDA26CA}</fare_id>
<transit_airline_rcd />
//
// ViewController.swift
// Promise
//
// Created by 默司 on 2016/10/12.
// Copyright © 2016年 默司. All rights reserved.
//
import UIKit
import PromiseKit
@mosluce
mosluce / firebase_problem2.swift
Last active October 6, 2016 18:08 — forked from lizolni/firebase_problem2.swift
firebase problem2
import UIKit
import Firebase
class StoreTableViewController: UITableViewController {
let flavorSet = NSUserDefaults.standardUserDefaults()
let conditionRef = FIRDatabase.database().reference()
var stores = [Stores]()
@mosluce
mosluce / MapViewController.swift
Last active September 20, 2016 04:38
MapKit Demo: 地圖加Annotation以及畫線
//
// ViewController.swift
// NewMapKit
//
// Created by 默司 on 2016/9/20.
// Copyright © 2016年 默司. All rights reserved.
//
import UIKit
import MapKit
var express = require('express');
var router = express.Router();
var Promise = require('bluebird');
var moment = require('moment');
var _ = require('lodash');
var mongoose = require('mongoose'),
Verification = mongoose.model('Verification'),
Account = mongoose.model('Account');
var appKey = 'APPLICATION_KEY';
@mosluce
mosluce / swift_function.swift
Created August 18, 2016 05:08
Swift Function: 無限參數
//: Playground - noun: a place where people can play
import UIKit
func hello(people: String...) {
for person in people {
let str = "Hello \(person)"
print(str)
}
}
@mosluce
mosluce / swift_closure.swift
Last active August 18, 2016 04:57
Swift Closure: How / Why - 剛開始接觸 Closure 應該很多人被書裡寫的弄到頭昏腦脹,不知道到底怎樣寫才對,這邊用案例說明
//: Playground - noun: a place where people can play
import UIKit
var closure: ((a: Int, b: Int) -> Int)!
//基本型
closure = {(a: Int, b: Int) -> Int in
return a + b
}
//
// ViewController.swift
// SwiftPicker
//
// Created by 默司 on 2016/8/8.
// Copyright © 2016年 默司. All rights reserved.
//
import UIKit