Skip to content

Instantly share code, notes, and snippets.

View mosluce's full-sized avatar

mosluce mosluce

View GitHub Profile
import Foundation
import UIKit
print("==== Basic ====")
// Automatic Reference Counting
class A {
func hello() -> String {
return "world"
@mosluce
mosluce / Example.swift
Last active January 14, 2017 04:41
對於常用的 WebAPI 呼叫方式進行擴充 URLSession
/// 範例中使用了 SVProgressHUD, SwiftyJSON
/// 另外 UIAlertController 有 extension
func request(_ path: String, method: HttpMethod = .get, parameters: [String: Any]? = nil, localizedStatus: String? = NSLocalizedString("資料處理中", comment: "呼叫API讀取狀態文字"), _ completion: @escaping (_ json: JSON) -> Void) {
// 顯示 ActivityIndicator
if let status = localizedStatus { SVProgressHUD.show(withStatus: status) }
// 待會使用 GCD 版本所以要 Dispatch 到其他 thread
DispatchQueue.global().async {
@mosluce
mosluce / Muti2One.swift
Last active January 19, 2017 05:36
Multi ViewControllers to One
class AVC: UIViewController {
weak var delegate: AVCDelegate?
// TODO: implement
func hello() {
// 請 Main 幫忙做點事
self.delegate?.somethingFromA(self)
}
@mosluce
mosluce / VideoViewController.swift
Last active March 3, 2017 03:01
仿 Youtube 試做
//
// VideoViewController.swift
// SideMenuCALayerDemo
//
// Created by 默司 on 2017/3/1.
// Copyright © 2017年 默司. All rights reserved.
//
import UIKit
import AVFoundation
.yt-live-chat-renderer-0 {
background: transparent;
}
.yt-live-chat-renderer {
height: 0;
padding: 0;
font-size: 0;
}
@mosluce
mosluce / 回呼.js
Last active May 3, 2017 14:20 — forked from matt0224/回呼
var Home = {
Box: function () {
this.color = 'black';
this.paint = function (value, cb) {
// delay 3 seconds.
//var now = new Date().getTime();
//while (new Date().getTime() < now + 3000) {
// /* do nothing */
//}
this.color = value;
import UIKit
extension UIView {
@discardableResult func constraint(attribute attr1: NSLayoutAttribute, relatedBy: NSLayoutRelation = .equal, toItem: Any? = nil, attribute attr2: NSLayoutAttribute? = nil, multiplier: CGFloat = 1, constant: CGFloat = 0) -> NSLayoutConstraint {
self.translatesAutoresizingMaskIntoConstraints = false
let attr = attr2 ?? attr1
return NSLayoutConstraint(item: self, attribute: attr1, relatedBy: relatedBy, toItem: toItem, attribute: attr, multiplier: multiplier, constant: constant)
//
// GalleryTools.h
// Unity-iPhone
//
// Created by 默司 on 2017/5/9.
//
//
#import <Foundation/Foundation.h>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.Networking;
namespace Azure
{
public class Authentication
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;